]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorJSONAttachCharDevCommand: Format only the properties
authorPeter Krempa <pkrempa@redhat.com>
Wed, 13 Oct 2021 15:18:50 +0000 (17:18 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 19 Nov 2021 11:38:34 +0000 (12:38 +0100)
Move the addition of the command wrapper to qemuMonitorJSONAttachCharDev
and rename the function to qemuMonitorJSONAttachCharDevGetProps.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_monitor_json.c

index 2cfae2276dbb164f714038880090d15adc761321..b036cc41120d547b2a1c4e29a39caebfc9a66c47 100644 (file)
@@ -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)