From: Peter Krempa Date: Wed, 13 Oct 2021 15:18:50 +0000 (+0200) Subject: qemuMonitorJSONAttachCharDevCommand: Format only the properties X-Git-Tag: v7.10.0-rc1~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3af4392f7cbe72d3a87e778e562d8e8d13e6a6a;p=thirdparty%2Flibvirt.git qemuMonitorJSONAttachCharDevCommand: Format only the properties Move the addition of the command wrapper to qemuMonitorJSONAttachCharDev and rename the function to qemuMonitorJSONAttachCharDevGetProps. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 2cfae2276d..b036cc4112 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6609,9 +6609,10 @@ qemuMonitorJSONBuildChrChardevReconnect(virJSONValue *object, } static virJSONValue * -qemuMonitorJSONAttachCharDevCommand(const char *chrID, - const virDomainChrSourceDef *chr) +qemuMonitorJSONAttachCharDevGetProps(const char *chrID, + const virDomainChrSourceDef *chr) { + g_autoptr(virJSONValue) props = NULL; g_autoptr(virJSONValue) backend = virJSONValueNewObject(); g_autoptr(virJSONValue) data = virJSONValueNewObject(); g_autoptr(virJSONValue) addr = NULL; @@ -6760,10 +6761,13 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID, virJSONValueObjectAppend(backend, "data", &data) < 0) return NULL; - return qemuMonitorJSONMakeCommand("chardev-add", - "s:id", chrID, - "a:backend", &backend, - NULL); + if (virJSONValueObjectAdd(&props, + "s:id", chrID, + "a:backend", &backend, + NULL) < 0) + return NULL; + + return g_steal_pointer(&props); } @@ -6774,8 +6778,12 @@ qemuMonitorJSONAttachCharDev(qemuMonitor *mon, { g_autoptr(virJSONValue) cmd = NULL; g_autoptr(virJSONValue) reply = NULL; + g_autoptr(virJSONValue) props = NULL; + + if (!(props = qemuMonitorJSONAttachCharDevGetProps(chrID, chr))) + return -1; - if (!(cmd = qemuMonitorJSONAttachCharDevCommand(chrID, chr))) + if (!(cmd = qemuMonitorJSONMakeCommandInternal("chardev-add", &props))) return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)