提交 25a272ad 编写于 作者: P Peter Krempa

util: qemu: Add support for user-passed strings in JSON->commandline

Until now the JSON->commandline convertor was used only for objects
created by qemu. To allow reusing it with disk formatter we'll need to
escape ',' as usual in qemu commandlines.
上级 f0276c34
......@@ -46,7 +46,8 @@ virQEMUBuildCommandLineJSONRecurse(const char *key,
switch ((virJSONType) value->type) {
case VIR_JSON_TYPE_STRING:
virBufferAsprintf(buf, ",%s=%s", key, value->data.string);
virBufferAsprintf(buf, ",%s=", key);
virQEMUBuildBufferEscapeComma(buf, value->data.string);
break;
case VIR_JSON_TYPE_NUMBER:
......
......@@ -100,6 +100,7 @@ mymain(void)
DO_TEST_COMMAND_OBJECT_FROM_JSON("{}", NULL);
DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"string\":\"qwer\"}", "string=qwer");
DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"string\":\"qw,e,r\"}", "string=qw,,e,,r");
DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"number\":1234}", "number=1234");
DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"boolean\":true}", "boolean=yes");
DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"boolean\":false}", "boolean=no");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册