[libvirt] [PATCH 1/6] qemu: command: Inject password-secret only when not using JSON props

Peter Krempa posted 6 patches 7 years, 5 months ago
[libvirt] [PATCH 1/6] qemu: command: Inject password-secret only when not using JSON props
Posted by Peter Krempa 7 years, 5 months ago
The 'file.password-secret' injection should be used only if we are using
the old formatter. When formatting the source string from the JSON
properities, the property should be added there.

Also drop the comment which refers to stuff that will not be used in
libvirt sine -blockdev is the way to go.
---
 src/qemu/qemu_command.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 26d395d67c..667ac746e1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -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);
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/6] qemu: command: Inject password-secret only when not using JSON props
Posted by Ján Tomko 7 years, 5 months ago
On Thu, Nov 23, 2017 at 05:24:38PM +0100, Peter Krempa wrote:
>The 'file.password-secret' injection should be used only if we are using
>the old formatter. When formatting the source string from the JSON
>properities, the property should be added there.

*properties

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

*since

Jan

>---
> src/qemu/qemu_command.c | 13 +++----------
> 1 file changed, 3 insertions(+), 10 deletions(-)
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list