Blame SOURCES/libvirt-util-qemu-Add-support-for-user-passed-strings-in-JSON-commandline.patch

6ae9ed
From dc6ab905ea7c40ab3bdb76ecb8b3eb7b088c4a05 Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <dc6ab905ea7c40ab3bdb76ecb8b3eb7b088c4a05@dist-git>
6ae9ed
From: Peter Krempa <pkrempa@redhat.com>
6ae9ed
Date: Tue, 2 Aug 2016 13:41:43 +0200
6ae9ed
Subject: [PATCH] util: qemu: Add support for user-passed strings in
6ae9ed
 JSON->commandline
6ae9ed
6ae9ed
Until now the JSON->commandline convertor was used only for objects
6ae9ed
created by qemu. To allow reusing it with disk formatter we'll need to
6ae9ed
escape ',' as usual in qemu commandlines.
6ae9ed
6ae9ed
(cherry picked from commit 25a272ada48302ea0d7333b4f2e3556a713230a5)
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1134878 [JSON backing]
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1247521 [gluster multi-host]
6ae9ed
---
6ae9ed
 src/util/virqemu.c          | 3 ++-
6ae9ed
 tests/qemucommandutiltest.c | 1 +
6ae9ed
 2 files changed, 3 insertions(+), 1 deletion(-)
6ae9ed
6ae9ed
diff --git a/src/util/virqemu.c b/src/util/virqemu.c
6ae9ed
index a5d5385..99c14c2 100644
6ae9ed
--- a/src/util/virqemu.c
6ae9ed
+++ b/src/util/virqemu.c
6ae9ed
@@ -46,7 +46,8 @@ virQEMUBuildCommandLineJSONRecurse(const char *key,
6ae9ed
 
6ae9ed
     switch ((virJSONType) value->type) {
6ae9ed
     case VIR_JSON_TYPE_STRING:
6ae9ed
-        virBufferAsprintf(buf, ",%s=%s", key, value->data.string);
6ae9ed
+        virBufferAsprintf(buf, ",%s=", key);
6ae9ed
+        virQEMUBuildBufferEscapeComma(buf, value->data.string);
6ae9ed
         break;
6ae9ed
 
6ae9ed
     case VIR_JSON_TYPE_NUMBER:
6ae9ed
diff --git a/tests/qemucommandutiltest.c b/tests/qemucommandutiltest.c
6ae9ed
index 21fef1c..8299462 100644
6ae9ed
--- a/tests/qemucommandutiltest.c
6ae9ed
+++ b/tests/qemucommandutiltest.c
6ae9ed
@@ -100,6 +100,7 @@ mymain(void)
6ae9ed
 
6ae9ed
     DO_TEST_COMMAND_OBJECT_FROM_JSON("{}", NULL);
6ae9ed
     DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"string\":\"qwer\"}", "string=qwer");
6ae9ed
+    DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"string\":\"qw,e,r\"}", "string=qw,,e,,r");
6ae9ed
     DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"number\":1234}", "number=1234");
6ae9ed
     DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"boolean\":true}", "boolean=yes");
6ae9ed
     DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"boolean\":false}", "boolean=no");
6ae9ed
-- 
6ae9ed
2.9.2
6ae9ed