diff mbox

[v2,2/4] qemu: command: escape commas in secret master path

Message ID 58f5269f061bd3c9494019eebd0d4b032fbe5b01.1462314536.git.crobinso@redhat.com
State Superseded
Headers show

Commit Message

Cole Robinson May 4, 2016, 2:56 p.m. UTC
Need to convert the local function to virBuffer usage, so we
can use virBufferEscape
---
 src/qemu/qemu_command.c                              | 7 +++++--
 tests/qemuxml2argvdata/qemuxml2argv-name-escape.args | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

-- 
2.7.4

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

Patch

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b13df49..d54d0d1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -180,6 +180,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
@@ -202,12 +203,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);
+    virBufferEscape(&buf, ',', ",", "%s", path);
+    virCommandAddArgBuffer(cmd, &buf);
 
     ret = 0;
 
  cleanup:
+    virBufferFreeAndReset(&buf);
     VIR_FREE(alias);
     VIR_FREE(path);
     return ret;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-name-escape.args b/tests/qemuxml2argvdata/qemuxml2argv-name-escape.args
index 94a3133..a5e35b8 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-name-escape.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-name-escape.args
@@ -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 \