]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: command: escape commas in secret master path
authorCole Robinson <crobinso@redhat.com>
Fri, 22 Apr 2016 22:22:05 +0000 (18:22 -0400)
committerCole Robinson <crobinso@redhat.com>
Mon, 16 May 2016 14:30:38 +0000 (10:30 -0400)
Need to convert the local function to virBuffer usage, so we
can use qemuBufferEscapeComma

src/qemu/qemu_command.c
tests/qemuxml2argvdata/qemuxml2argv-name-escape.args

index 02bd543eeb08421276f6de33ae56401c5f2a0956..751690e285ea08588acd5d40d3d62dffb37250e4 100644 (file)
@@ -196,6 +196,7 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
     int ret = -1;
     char *alias = NULL;
     char *path = NULL;
+    virBuffer buf = VIR_BUFFER_INITIALIZER;
 
     /* 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
@@ -218,12 +219,14 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
         goto cleanup;
 
     virCommandAddArg(cmd, "-object");
-    virCommandAddArgFormat(cmd, "secret,id=%s,format=raw,file=%s",
-                           alias, path);
+    virBufferAsprintf(&buf, "secret,id=%s,format=raw,file=", alias);
+    qemuBufferEscapeComma(&buf, path);
+    virCommandAddArgBuffer(cmd, &buf);
 
     ret = 0;
 
  cleanup:
+    virBufferFreeAndReset(&buf);
     VIR_FREE(alias);
     VIR_FREE(path);
     return ret;
index 94a3133a8a089ea1aa121aa2273a07d1a5cba2dc..a5e35b877c6f8dee6157869fe72c1fa486abeb0f 100644 (file)
@@ -7,7 +7,7 @@ QEMU_AUDIO_DRV=none \
 /usr/bin/qemu \
 -name foo,,bar,debug-threads=on \
 -S \
--object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-foo,\
+-object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-foo,,\
 bar/master-key.aes \
 -M pc \
 -m 214 \