From d3af4392f7cbe72d3a87e778e562d8e8d13e6a6a Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 13 Oct 2021 17:18:50 +0200 Subject: [PATCH] qemuMonitorJSONAttachCharDevCommand: Format only the properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/qemu/qemu_monitor_json.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) 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 (!(cmd = qemuMonitorJSONAttachCharDevCommand(chrID, chr))) + if (!(props = qemuMonitorJSONAttachCharDevGetProps(chrID, chr))) + return -1; + + if (!(cmd = qemuMonitorJSONMakeCommandInternal("chardev-add", &props))) return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)