]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Rename 'qemuMonitorAddDeviceArgs' to 'qemuMonitorAddDeviceProps'
authorPeter Krempa <pkrempa@redhat.com>
Wed, 24 Mar 2021 10:07:56 +0000 (11:07 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 12 Oct 2021 08:26:01 +0000 (10:26 +0200)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_hotplug.c
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h
src/qemu/qemu_process.c

index 5d4c8bf839d41bcc869f1cf0e99db8c97d7a9af9..1c310249e28e15a842972ee313f21916924d728d 100644 (file)
@@ -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);
     }
index 068b7ff9971e39ee180c2bfd91d180931c03b4b3..fe65d46ae9560beaec88f87344159951e928b584 100644 (file)
@@ -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);
 }
 
 
index 648fe293edb34f26e86f923e9609cd9a086c3b59..5edf6a161bee6588572accbb50ac8ef82c3a606b 100644 (file)
@@ -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);
 
index 1b98baa4c7eb87a568bb2a5b95d0dda037dfc80a..e5c71f58c2371dde84420e87ed249199bf2cb3ba 100644 (file)
@@ -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);
 }
 
 
index 0289f8c3bf5a65c35b9e9a50c2d9eacb7de27b03..8dc2350642409a532caa78e58ddbd732bca23bf8 100644 (file)
@@ -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);
 
index 9faaeeadbace217322e710cdea91f5a6393f6d45..09a2ff8ef2b15054e22c58a81abadae14092182c 100644 (file)
@@ -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;