Move the addition of the command wrapper to qemuMonitorJSONAttachCharDev
and rename the function to qemuMonitorJSONAttachCharDevGetProps.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
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 (!(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)
--
2.31.1