]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: command: Inject password-secret only when not using JSON props
authorPeter Krempa <pkrempa@redhat.com>
Thu, 23 Nov 2017 14:37:37 +0000 (15:37 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 23 Nov 2017 17:50:04 +0000 (18:50 +0100)
The 'file.password-secret' injection should be used only if we are using
the old formatter. When formatting the source string from the JSON
properties, the property should be added there.

Also drop the comment which refers to stuff that will not be used in
libvirt since -blockdev is the way to go.

src/qemu/qemu_command.c

index e72a9442bffcb1be4daa4439f80b7662e8905da2..5ef98d38cca63d6e7dbbc7f11a9bc7b9b8ed7c07 100644 (file)
@@ -1578,6 +1578,9 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
         }
 
         virQEMUBuildBufferEscapeComma(buf, source);
+
+        if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES)
+            virBufferAsprintf(buf, ",file.password-secret=%s", secinfo->s.aes.alias);
     } else {
         if (!(source = virQEMUBuildDriveCommandlineFromJSON(srcprops)))
             goto cleanup;
@@ -1592,16 +1595,6 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
             virBufferAsprintf(buf, "file.debug=%d,", cfg->glusterDebugLevel);
     }
 
-    if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
-        /* NB: If libvirt starts using the more modern option based
-         *     syntax to build the command line (e.g., "-drive driver=rbd,
-         *     filename=%s,...") instead of the legacy model (e.g."-drive
-         *     file=%s,..."), then the "file." prefix can be removed
-         */
-        virBufferAsprintf(buf, "file.password-secret=%s,",
-                          secinfo->s.aes.alias);
-    }
-
     if (encinfo)
         virQEMUBuildLuksOpts(buf, &disk->src->encryption->encinfo,
                              encinfo->s.aes.alias);