mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
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.
This commit is contained in:
parent
f0276c3489
commit
25a272ada4
@ -46,7 +46,8 @@ virQEMUBuildCommandLineJSONRecurse(const char *key,
|
|||||||
|
|
||||||
switch ((virJSONType) value->type) {
|
switch ((virJSONType) value->type) {
|
||||||
case VIR_JSON_TYPE_STRING:
|
case VIR_JSON_TYPE_STRING:
|
||||||
virBufferAsprintf(buf, ",%s=%s", key, value->data.string);
|
virBufferAsprintf(buf, ",%s=", key);
|
||||||
|
virQEMUBuildBufferEscapeComma(buf, value->data.string);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_JSON_TYPE_NUMBER:
|
case VIR_JSON_TYPE_NUMBER:
|
||||||
|
@ -100,6 +100,7 @@ mymain(void)
|
|||||||
|
|
||||||
DO_TEST_COMMAND_OBJECT_FROM_JSON("{}", NULL);
|
DO_TEST_COMMAND_OBJECT_FROM_JSON("{}", NULL);
|
||||||
DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"string\":\"qwer\"}", "string=qwer");
|
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("{\"number\":1234}", "number=1234");
|
||||||
DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"boolean\":true}", "boolean=yes");
|
DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"boolean\":true}", "boolean=yes");
|
||||||
DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"boolean\":false}", "boolean=no");
|
DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"boolean\":false}", "boolean=no");
|
||||||
|
Loading…
Reference in New Issue
Block a user