[PATCH v3 3/5] qemu: Use virJSONValueObjectCreate for master key

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rather than open coding, follow the secinfo code and use the common
secret object build/generate sequence.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 1455c0d..6920379 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -198,6 +198,9 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
     char *alias = NULL;
     char *path = NULL;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
+    virJSONValuePtr props = NULL;
+    char *tmp = NULL;
+
 
     /* If the -object secret does not exist, then just return. This just
      * means the domain won't be able to use a secret master key and is
@@ -219,10 +222,22 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
     if (!(path = qemuDomainGetMasterKeyFilePath(domainLibDir)))
         goto cleanup;
 
-    virCommandAddArg(cmd, "-object");
-    virBufferAsprintf(&buf, "secret,id=%s,format=raw,file=", alias);
     qemuBufferEscapeComma(&buf, path);
-    virCommandAddArgBuffer(cmd, &buf);
+    if (virBufferCheckError(&buf) < 0)
+        goto cleanup;
+    VIR_FREE(path);
+    path = virBufferContentAndReset(&buf);
+
+    if (virJSONValueObjectCreate(&props,
+                                 "s:format", "raw",
+                                 "s:file", path,
+                                 NULL) < 0)
+        goto cleanup;
+
+    if (!(tmp = virQEMUBuildObjectCommandlineFromJSON("secret", alias, props)))
+        goto cleanup;
+
+    virCommandAddArgList(cmd, "-object", tmp, NULL);
 
     ret = 0;
 
-- 
2.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]