We commonly use 'props' for the JSON object describing something. Rename
the monitor device addition code.
Additionally the common approach is to clear the pointer if it was
consumed so the arguments are adjusted to do so.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_hotplug.c | 3 +--
src/qemu/qemu_monitor.c | 13 +++++++------
src/qemu/qemu_monitor.h | 4 ++--
src/qemu/qemu_monitor_json.c | 13 ++++++-------
src/qemu/qemu_monitor_json.h | 4 ++--
src/qemu/qemu_process.c | 3 +--
6 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 5d4c8bf839..1c310249e2 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -6301,8 +6301,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriver *driver,
qemuDomainObjEnterMonitor(driver, vm);
if (newhotplug) {
- rc = qemuMonitorAddDeviceArgs(qemuDomainGetMonitor(vm), vcpuprops);
- vcpuprops = NULL;
+ rc = qemuMonitorAddDeviceProps(qemuDomainGetMonitor(vm), &vcpuprops);
} else {
rc = qemuMonitorSetCPU(qemuDomainGetMonitor(vm), vcpu, true);
}
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 068b7ff997..fe65d46ae9 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2893,20 +2893,21 @@ qemuMonitorAddDevice(qemuMonitor *mon,
/**
- * qemuMonitorAddDeviceArgs:
+ * qemuMonitorAddDeviceProps:
* @mon: monitor object
- * @args: arguments for device add, consumed on success or failure
+ * @props: JSON object describing the device to add, the object is consumed
+ * and cleared.
*
- * Adds a device described by @args. Requires JSON monitor.
+ * Adds a device described by @props.
* Returns 0 on success -1 on error.
*/
int
-qemuMonitorAddDeviceArgs(qemuMonitor *mon,
- virJSONValue *args)
+qemuMonitorAddDeviceProps(qemuMonitor *mon,
+ virJSONValue **props)
{
QEMU_CHECK_MONITOR(mon);
- return qemuMonitorJSONAddDeviceArgs(mon, args);
+ return qemuMonitorJSONAddDeviceProps(mon, props);
}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 648fe293ed..5edf6a161b 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1028,8 +1028,8 @@ int qemuMonitorAttachPCIDiskController(qemuMonitor *mon,
const char *bus,
virPCIDeviceAddress *guestAddr);
-int qemuMonitorAddDeviceArgs(qemuMonitor *mon,
- virJSONValue *args);
+int qemuMonitorAddDeviceProps(qemuMonitor *mon,
+ virJSONValue **props);
int qemuMonitorAddDevice(qemuMonitor *mon,
const char *devicestr);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 1b98baa4c7..e5c71f58c2 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4554,8 +4554,8 @@ int qemuMonitorJSONDelDevice(qemuMonitor *mon,
int
-qemuMonitorJSONAddDeviceArgs(qemuMonitor *mon,
- virJSONValue *args)
+qemuMonitorJSONAddDeviceProps(qemuMonitor *mon,
+ virJSONValue **props)
{
int ret = -1;
virJSONValue *cmd = NULL;
@@ -4564,7 +4564,7 @@ qemuMonitorJSONAddDeviceArgs(qemuMonitor *mon,
if (!(cmd = qemuMonitorJSONMakeCommand("device_add", NULL)))
goto cleanup;
- if (virJSONValueObjectAppend(cmd, "arguments", &args) < 0)
+ if (virJSONValueObjectAppend(cmd, "arguments", props) < 0)
goto cleanup;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
@@ -4575,7 +4575,6 @@ qemuMonitorJSONAddDeviceArgs(qemuMonitor *mon,
ret = 0;
cleanup:
- virJSONValueFree(args);
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
@@ -4586,12 +4585,12 @@ int
qemuMonitorJSONAddDevice(qemuMonitor *mon,
const char *devicestr)
{
- virJSONValue *args;
+ g_autoptr(virJSONValue) props = NULL;
- if (!(args = qemuMonitorJSONKeywordStringToJSON(devicestr, "driver")))
+ if (!(props = qemuMonitorJSONKeywordStringToJSON(devicestr, "driver")))
return -1;
- return qemuMonitorJSONAddDeviceArgs(mon, args);
+ return qemuMonitorJSONAddDeviceProps(mon, &props);
}
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 0289f8c3bf..8dc2350642 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -235,8 +235,8 @@ int qemuMonitorJSONAttachPCIDiskController(qemuMonitor *mon,
const char *bus,
virPCIDeviceAddress *guestAddr);
-int qemuMonitorJSONAddDeviceArgs(qemuMonitor *mon,
- virJSONValue *args);
+int qemuMonitorJSONAddDeviceProps(qemuMonitor *mon,
+ virJSONValue **props);
int qemuMonitorJSONAddDevice(qemuMonitor *mon,
const char *devicestr);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 9faaeeadba..09a2ff8ef2 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6085,8 +6085,7 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriver *driver,
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
goto cleanup;
- rc = qemuMonitorAddDeviceArgs(qemuDomainGetMonitor(vm), vcpuprops);
- vcpuprops = NULL;
+ rc = qemuMonitorAddDeviceProps(qemuDomainGetMonitor(vm), &vcpuprops);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto cleanup;
--
2.31.1