6ae9ed
From a1901b36addfb7a064a5d451e1cfb47d5737c8eb Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <a1901b36addfb7a064a5d451e1cfb47d5737c8eb@dist-git>
6ae9ed
From: John Ferlan <jferlan@redhat.com>
6ae9ed
Date: Mon, 25 Jul 2016 12:43:00 -0400
6ae9ed
Subject: [PATCH] qemu: Add luks support for domain disk
6ae9ed
6ae9ed
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1301021
6ae9ed
6ae9ed
Generate the luks command line using the AES secret key to encrypt the
6ae9ed
luks secret. A luks secret object will be in addition to a an AES secret.
6ae9ed
6ae9ed
For hotplug, check if the encinfo exists and if so, add the AES secret
6ae9ed
for the passphrase for the secret object used to decrypt the device.
6ae9ed
6ae9ed
Modify/augment the fakeSecret* in qemuxml2argvtest in order to handle
6ae9ed
find a uuid or a volume usage with a specific path prefix in the XML
6ae9ed
(corresponds to the already generated XML tests). Add error message
6ae9ed
when the 'usageID' is not 'mycluster_myname'. Commit id '1d632c39'
6ae9ed
altered the error message generation to rely on the errors from the
6ae9ed
secret_driver (or it's faked replacement).
6ae9ed
6ae9ed
Add the .args output for adding the LUKS disk to the domain
6ae9ed
6ae9ed
Signed-off-by: John Ferlan <jferlan@redhat.com>
6ae9ed
(cherry picked from commit da86c6c22674ccc147224afa2740e33d8cbdbf22)
6ae9ed
6ae9ed
NB: The .args output was modified from upstream since the downstream
6ae9ed
    does not contain commit id 'e114b09157b7fcca12b218b531debfbc0c3a09d7'
6ae9ed
    which adds ",sockets=1,cores=1,threads=1" to the "-smp 1" on the
6ae9ed
    command line
6ae9ed
6ae9ed
Signed-off-by: John Ferlan <jferlan@redhat.com>
6ae9ed
---
6ae9ed
 src/qemu/qemu_command.c                            |  9 +++
6ae9ed
 src/qemu/qemu_domain.c                             | 25 +++++++-
6ae9ed
 src/qemu/qemu_hotplug.c                            | 68 ++++++++++++++++++++++
6ae9ed
 .../qemuxml2argvdata/qemuxml2argv-luks-disks.args  | 36 ++++++++++++
6ae9ed
 tests/qemuxml2argvtest.c                           | 24 +++++++-
6ae9ed
 5 files changed, 156 insertions(+), 6 deletions(-)
6ae9ed
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-luks-disks.args
6ae9ed
6ae9ed
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
6ae9ed
index 0ee1d34..6c91e53 100644
6ae9ed
--- a/src/qemu/qemu_command.c
6ae9ed
+++ b/src/qemu/qemu_command.c
6ae9ed
@@ -1087,6 +1087,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
6ae9ed
     int actualType = virStorageSourceGetActualType(disk->src);
6ae9ed
     qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
6ae9ed
     qemuDomainSecretInfoPtr secinfo = diskPriv->secinfo;
6ae9ed
+    qemuDomainSecretInfoPtr encinfo = diskPriv->encinfo;
6ae9ed
     bool emitDeviceSyntax = qemuDiskBusNeedsDeviceArg(disk->bus);
6ae9ed
 
6ae9ed
     if (idx < 0) {
6ae9ed
@@ -1226,6 +1227,10 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
6ae9ed
                               secinfo->s.aes.alias);
6ae9ed
         }
6ae9ed
 
6ae9ed
+        if (encinfo)
6ae9ed
+            virQEMUBuildLuksOpts(&opt, &disk->src->encryption->encinfo,
6ae9ed
+                                 encinfo->s.aes.alias);
6ae9ed
+
6ae9ed
         if (disk->src->format > 0 &&
6ae9ed
             disk->src->type != VIR_STORAGE_TYPE_DIR)
6ae9ed
             virBufferAsprintf(&opt, "format=%s,",
6ae9ed
@@ -1928,6 +1933,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
6ae9ed
         virDomainDiskDefPtr disk = def->disks[i];
6ae9ed
         qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
6ae9ed
         qemuDomainSecretInfoPtr secinfo = diskPriv->secinfo;
6ae9ed
+        qemuDomainSecretInfoPtr encinfo = diskPriv->encinfo;
6ae9ed
 
6ae9ed
         /* PowerPC pseries based VMs do not support floppy device */
6ae9ed
         if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
6ae9ed
@@ -1956,6 +1962,9 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
6ae9ed
         if (qemuBuildDiskSecinfoCommandLine(cmd, secinfo) < 0)
6ae9ed
             return -1;
6ae9ed
 
6ae9ed
+        if (qemuBuildDiskSecinfoCommandLine(cmd, encinfo) < 0)
6ae9ed
+            return -1;
6ae9ed
+
6ae9ed
         virCommandAddArg(cmd, "-drive");
6ae9ed
 
6ae9ed
         optstr = qemuBuildDriveStr(disk,
6ae9ed
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
6ae9ed
index 27158f4..26d0d12 100644
6ae9ed
--- a/src/qemu/qemu_domain.c
6ae9ed
+++ b/src/qemu/qemu_domain.c
6ae9ed
@@ -946,7 +946,8 @@ qemuDomainSecretSetup(virConnectPtr conn,
6ae9ed
 {
6ae9ed
     if (virCryptoHaveCipher(VIR_CRYPTO_CIPHER_AES256CBC) &&
6ae9ed
         virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_SECRET) &&
6ae9ed
-        secretUsageType == VIR_SECRET_USAGE_TYPE_CEPH) {
6ae9ed
+        (secretUsageType == VIR_SECRET_USAGE_TYPE_CEPH ||
6ae9ed
+         secretUsageType == VIR_SECRET_USAGE_TYPE_VOLUME)) {
6ae9ed
         if (qemuDomainSecretAESSetup(conn, priv, secinfo, srcalias,
6ae9ed
                                      secretUsageType, username,
6ae9ed
                                      seclookupdef, isLuks) < 0)
6ae9ed
@@ -1006,11 +1007,14 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
6ae9ed
                             virDomainDiskDefPtr disk)
6ae9ed
 {
6ae9ed
     virStorageSourcePtr src = disk->src;
6ae9ed
+    qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
6ae9ed
     qemuDomainSecretInfoPtr secinfo = NULL;
6ae9ed
 
6ae9ed
-    if (conn && qemuDomainSecretDiskCapable(src)) {
6ae9ed
+    if (!conn)
6ae9ed
+        return 0;
6ae9ed
+
6ae9ed
+    if (qemuDomainSecretDiskCapable(src)) {
6ae9ed
         virSecretUsageType secretUsageType = VIR_SECRET_USAGE_TYPE_ISCSI;
6ae9ed
-        qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
6ae9ed
 
6ae9ed
         if (VIR_ALLOC(secinfo) < 0)
6ae9ed
             return -1;
6ae9ed
@@ -1026,6 +1030,21 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
6ae9ed
         diskPriv->secinfo = secinfo;
6ae9ed
     }
6ae9ed
 
6ae9ed
+    if (!virStorageSourceIsEmpty(src) && src->encryption &&
6ae9ed
+        src->format == VIR_STORAGE_FILE_LUKS) {
6ae9ed
+
6ae9ed
+        if (VIR_ALLOC(secinfo) < 0)
6ae9ed
+            return -1;
6ae9ed
+
6ae9ed
+        if (qemuDomainSecretSetup(conn, priv, secinfo, disk->info.alias,
6ae9ed
+                                  VIR_SECRET_USAGE_TYPE_VOLUME, NULL,
6ae9ed
+                                  &src->encryption->secrets[0]->seclookupdef,
6ae9ed
+                                  true) < 0)
6ae9ed
+            goto error;
6ae9ed
+
6ae9ed
+        diskPriv->encinfo = secinfo;
6ae9ed
+    }
6ae9ed
+
6ae9ed
     return 0;
6ae9ed
 
6ae9ed
  error:
6ae9ed
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
6ae9ed
index 9cb1d44..6509867 100644
6ae9ed
--- a/src/qemu/qemu_hotplug.c
6ae9ed
+++ b/src/qemu/qemu_hotplug.c
6ae9ed
@@ -312,11 +312,14 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
6ae9ed
     bool releaseaddr = false;
6ae9ed
     bool driveAdded = false;
6ae9ed
     bool secobjAdded = false;
6ae9ed
+    bool encobjAdded = false;
6ae9ed
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
6ae9ed
     const char *src = virDomainDiskGetSource(disk);
6ae9ed
     virJSONValuePtr secobjProps = NULL;
6ae9ed
+    virJSONValuePtr encobjProps = NULL;
6ae9ed
     qemuDomainDiskPrivatePtr diskPriv;
6ae9ed
     qemuDomainSecretInfoPtr secinfo;
6ae9ed
+    qemuDomainSecretInfoPtr encinfo;
6ae9ed
 
6ae9ed
     if (!disk->info.type) {
6ae9ed
         if (qemuDomainMachineIsS390CCW(vm->def) &&
6ae9ed
@@ -356,6 +359,10 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
6ae9ed
             goto error;
6ae9ed
     }
6ae9ed
 
6ae9ed
+    encinfo = diskPriv->encinfo;
6ae9ed
+    if (encinfo && qemuBuildSecretInfoProps(encinfo, &encobjProps) < 0)
6ae9ed
+        goto error;
6ae9ed
+
6ae9ed
     if (!(drivestr = qemuBuildDriveStr(disk, false, priv->qemuCaps)))
6ae9ed
         goto error;
6ae9ed
 
6ae9ed
@@ -379,6 +386,15 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
6ae9ed
     }
6ae9ed
     secobjAdded = true;
6ae9ed
 
6ae9ed
+    if (encobjProps) {
6ae9ed
+        rv = qemuMonitorAddObject(priv->mon, "secret", encinfo->s.aes.alias,
6ae9ed
+                                  encobjProps);
6ae9ed
+        encobjProps = NULL; /* qemuMonitorAddObject consumes */
6ae9ed
+        if (rv < 0)
6ae9ed
+            goto exit_monitor;
6ae9ed
+    }
6ae9ed
+    encobjAdded = true;
6ae9ed
+
6ae9ed
     if (qemuMonitorAddDrive(priv->mon, drivestr) < 0)
6ae9ed
         goto exit_monitor;
6ae9ed
     driveAdded = true;
6ae9ed
@@ -398,6 +414,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
6ae9ed
 
6ae9ed
  cleanup:
6ae9ed
     virJSONValueFree(secobjProps);
6ae9ed
+    virJSONValueFree(encobjProps);
6ae9ed
     qemuDomainSecretDiskDestroy(disk);
6ae9ed
     VIR_FREE(devstr);
6ae9ed
     VIR_FREE(drivestr);
6ae9ed
@@ -413,6 +430,8 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
6ae9ed
     }
6ae9ed
     if (secobjAdded)
6ae9ed
         ignore_value(qemuMonitorDelObject(priv->mon, secinfo->s.aes.alias));
6ae9ed
+    if (encobjAdded)
6ae9ed
+        ignore_value(qemuMonitorDelObject(priv->mon, encinfo->s.aes.alias));
6ae9ed
     if (orig_err) {
6ae9ed
         virSetError(orig_err);
6ae9ed
         virFreeError(orig_err);
6ae9ed
@@ -570,11 +589,17 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
6ae9ed
 {
6ae9ed
     size_t i;
6ae9ed
     qemuDomainObjPrivatePtr priv = vm->privateData;
6ae9ed
+    virErrorPtr orig_err;
6ae9ed
     char *drivestr = NULL;
6ae9ed
     char *devstr = NULL;
6ae9ed
     bool driveAdded = false;
6ae9ed
+    bool encobjAdded = false;
6ae9ed
     int ret = -1;
6ae9ed
+    int rv;
6ae9ed
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
6ae9ed
+    virJSONValuePtr encobjProps = NULL;
6ae9ed
+    qemuDomainDiskPrivatePtr diskPriv;
6ae9ed
+    qemuDomainSecretInfoPtr encinfo;
6ae9ed
 
6ae9ed
     if (qemuDomainPrepareDisk(driver, vm, disk, NULL, false) < 0)
6ae9ed
         goto cleanup;
6ae9ed
@@ -605,6 +630,11 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
6ae9ed
     if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0)
6ae9ed
         goto error;
6ae9ed
 
6ae9ed
+    diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
6ae9ed
+    encinfo = diskPriv->encinfo;
6ae9ed
+    if (encinfo && qemuBuildSecretInfoProps(encinfo, &encobjProps) < 0)
6ae9ed
+        goto error;
6ae9ed
+
6ae9ed
     if (!(devstr = qemuBuildDriveDevStr(vm->def, disk, 0, priv->qemuCaps)))
6ae9ed
         goto error;
6ae9ed
 
6ae9ed
@@ -616,6 +646,15 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
6ae9ed
 
6ae9ed
     qemuDomainObjEnterMonitor(driver, vm);
6ae9ed
 
6ae9ed
+    if (encobjProps) {
6ae9ed
+        rv = qemuMonitorAddObject(priv->mon, "secret", encinfo->s.aes.alias,
6ae9ed
+                                  encobjProps);
6ae9ed
+        encobjProps = NULL; /* qemuMonitorAddObject consumes */
6ae9ed
+        if (rv < 0)
6ae9ed
+            goto exit_monitor;
6ae9ed
+    }
6ae9ed
+    encobjAdded = true;
6ae9ed
+
6ae9ed
     if (qemuMonitorAddDrive(priv->mon, drivestr) < 0)
6ae9ed
         goto exit_monitor;
6ae9ed
     driveAdded = true;
6ae9ed
@@ -632,6 +671,7 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
6ae9ed
     ret = 0;
6ae9ed
 
6ae9ed
  cleanup:
6ae9ed
+    virJSONValueFree(encobjProps);
6ae9ed
     qemuDomainSecretDiskDestroy(disk);
6ae9ed
     VIR_FREE(devstr);
6ae9ed
     VIR_FREE(drivestr);
6ae9ed
@@ -643,6 +683,14 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
6ae9ed
     if (driveAdded)
6ae9ed
         VIR_WARN("qemuMonitorAddDevice failed on %s (%s)", drivestr, devstr);
6ae9ed
 
6ae9ed
+    orig_err = virSaveLastError();
6ae9ed
+    if (encobjAdded)
6ae9ed
+        ignore_value(qemuMonitorDelObject(priv->mon, encinfo->s.aes.alias));
6ae9ed
+    if (orig_err) {
6ae9ed
+        virSetError(orig_err);
6ae9ed
+        virFreeError(orig_err);
6ae9ed
+    }
6ae9ed
+
6ae9ed
     ignore_value(qemuDomainObjExitMonitor(driver, vm));
6ae9ed
 
6ae9ed
     virDomainAuditDisk(vm, NULL, disk->src, "attach", false);
6ae9ed
@@ -2856,6 +2904,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
6ae9ed
     qemuDomainObjPrivatePtr priv = vm->privateData;
6ae9ed
     char *drivestr;
6ae9ed
     char *objAlias = NULL;
6ae9ed
+    char *encAlias = NULL;
6ae9ed
 
6ae9ed
     VIR_DEBUG("Removing disk %s from domain %p %s",
6ae9ed
               disk->info.alias, vm, vm->def->name);
6ae9ed
@@ -2881,6 +2930,20 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
6ae9ed
         }
6ae9ed
     }
6ae9ed
 
6ae9ed
+    /* Similarly, if this is possible a device using LUKS encryption, we
6ae9ed
+     * can remove the luks object password too
6ae9ed
+     */
6ae9ed
+    if (!virStorageSourceIsEmpty(disk->src) && disk->src->encryption &&
6ae9ed
+        disk->src->format == VIR_STORAGE_FILE_LUKS) {
6ae9ed
+
6ae9ed
+        if (!(encAlias =
6ae9ed
+              qemuDomainGetSecretAESAlias(disk->info.alias, true))) {
6ae9ed
+            VIR_FREE(objAlias);
6ae9ed
+            VIR_FREE(drivestr);
6ae9ed
+            return -1;
6ae9ed
+        }
6ae9ed
+    }
6ae9ed
+
6ae9ed
     qemuDomainObjEnterMonitor(driver, vm);
6ae9ed
 
6ae9ed
     /* If it fails, then so be it - it was a best shot */
6ae9ed
@@ -2888,6 +2951,11 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
6ae9ed
         ignore_value(qemuMonitorDelObject(priv->mon, objAlias));
6ae9ed
     VIR_FREE(objAlias);
6ae9ed
 
6ae9ed
+    /* If it fails, then so be it - it was a best shot */
6ae9ed
+    if (encAlias)
6ae9ed
+        ignore_value(qemuMonitorDelObject(priv->mon, encAlias));
6ae9ed
+    VIR_FREE(encAlias);
6ae9ed
+
6ae9ed
     qemuMonitorDriveDel(priv->mon, drivestr);
6ae9ed
     VIR_FREE(drivestr);
6ae9ed
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-luks-disks.args b/tests/qemuxml2argvdata/qemuxml2argv-luks-disks.args
6ae9ed
new file mode 100644
6ae9ed
index 0000000..efb5cb0
6ae9ed
--- /dev/null
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-luks-disks.args
6ae9ed
@@ -0,0 +1,36 @@
6ae9ed
+LC_ALL=C \
6ae9ed
+PATH=/bin \
6ae9ed
+HOME=/home/test \
6ae9ed
+USER=test \
6ae9ed
+LOGNAME=test \
6ae9ed
+QEMU_AUDIO_DRV=none \
6ae9ed
+/usr/bin/qemu \
6ae9ed
+-name encryptdisk \
6ae9ed
+-S \
6ae9ed
+-object secret,id=masterKey0,format=raw,\
6ae9ed
+file=/tmp/lib/domain--1-encryptdisk/master-key.aes \
6ae9ed
+-M pc-i440fx-2.1 \
6ae9ed
+-m 1024 \
6ae9ed
+-smp 1 \
6ae9ed
+-uuid 496898a6-e6ff-f7c8-5dc2-3cf410945ee9 \
6ae9ed
+-nographic \
6ae9ed
+-nodefaults \
6ae9ed
+-monitor unix:/tmp/lib/domain--1-encryptdisk/monitor.sock,server,nowait \
6ae9ed
+-no-acpi \
6ae9ed
+-boot c \
6ae9ed
+-usb \
6ae9ed
+-object secret,id=virtio-disk0-luks-secret0,\
6ae9ed
+data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\
6ae9ed
+keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
6ae9ed
+-drive file=/storage/guest_disks/encryptdisk,\
6ae9ed
+key-secret=virtio-disk0-luks-secret0,format=luks,if=none,id=drive-virtio-disk0 \
6ae9ed
+-device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\
6ae9ed
+id=virtio-disk0 \
6ae9ed
+-object secret,id=virtio-disk1-luks-secret0,\
6ae9ed
+data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\
6ae9ed
+keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
6ae9ed
+-drive file=/storage/guest_disks/encryptdisk2,\
6ae9ed
+key-secret=virtio-disk1-luks-secret0,format=luks,if=none,id=drive-virtio-disk1 \
6ae9ed
+-device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk1,\
6ae9ed
+id=virtio-disk1 \
6ae9ed
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
6ae9ed
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
6ae9ed
index d37d125..eddacf8 100644
6ae9ed
--- a/tests/qemuxml2argvtest.c
6ae9ed
+++ b/tests/qemuxml2argvtest.c
6ae9ed
@@ -49,12 +49,22 @@ fakeSecretGetValue(virSecretPtr obj ATTRIBUTE_UNUSED,
6ae9ed
 
6ae9ed
 static virSecretPtr
6ae9ed
 fakeSecretLookupByUsage(virConnectPtr conn,
6ae9ed
-                        int usageType ATTRIBUTE_UNUSED,
6ae9ed
+                        int usageType,
6ae9ed
                         const char *usageID)
6ae9ed
 {
6ae9ed
     unsigned char uuid[VIR_UUID_BUFLEN];
6ae9ed
-    if (STRNEQ(usageID, "mycluster_myname"))
6ae9ed
+    if (usageType == VIR_SECRET_USAGE_TYPE_VOLUME) {
6ae9ed
+        if (!STRPREFIX(usageID, "/storage/guest_disks/")) {
6ae9ed
+            virReportError(VIR_ERR_INTERNAL_ERROR,
6ae9ed
+                           "test provided invalid volume storage prefix '%s'",
6ae9ed
+                           usageID);
6ae9ed
+            return NULL;
6ae9ed
+        }
6ae9ed
+    } else if (STRNEQ(usageID, "mycluster_myname")) {
6ae9ed
+        virReportError(VIR_ERR_INTERNAL_ERROR,
6ae9ed
+                       "test provided incorrect usage '%s'", usageID);
6ae9ed
         return NULL;
6ae9ed
+    }
6ae9ed
 
6ae9ed
     if (virUUIDGenerate(uuid) < 0)
6ae9ed
         return NULL;
6ae9ed
@@ -62,10 +72,17 @@ fakeSecretLookupByUsage(virConnectPtr conn,
6ae9ed
     return virGetSecret(conn, uuid, usageType, usageID);
6ae9ed
 }
6ae9ed
 
6ae9ed
+static virSecretPtr
6ae9ed
+fakeSecretLookupByUUID(virConnectPtr conn,
6ae9ed
+                       const unsigned char *uuid)
6ae9ed
+{
6ae9ed
+    return virGetSecret(conn, uuid, 0, "");
6ae9ed
+}
6ae9ed
+
6ae9ed
 static virSecretDriver fakeSecretDriver = {
6ae9ed
     .connectNumOfSecrets = NULL,
6ae9ed
     .connectListSecrets = NULL,
6ae9ed
-    .secretLookupByUUID = NULL,
6ae9ed
+    .secretLookupByUUID = fakeSecretLookupByUUID,
6ae9ed
     .secretLookupByUsage = fakeSecretLookupByUsage,
6ae9ed
     .secretDefineXML = NULL,
6ae9ed
     .secretGetXMLDesc = NULL,
6ae9ed
@@ -1362,6 +1379,7 @@ mymain(void)
6ae9ed
 
6ae9ed
     DO_TEST("encrypted-disk", NONE);
6ae9ed
     DO_TEST("encrypted-disk-usage", NONE);
6ae9ed
+    DO_TEST("luks-disks", QEMU_CAPS_OBJECT_SECRET);
6ae9ed
 
6ae9ed
     DO_TEST("memtune", NONE);
6ae9ed
     DO_TEST("memtune-unlimited", NONE);
6ae9ed
-- 
6ae9ed
2.9.2
6ae9ed