]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorSetMigrationCapabilities: Take double pointer for @caps
authorPeter Krempa <pkrempa@redhat.com>
Mon, 30 Nov 2020 14:17:34 +0000 (15:17 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 8 Jan 2021 08:17:25 +0000 (09:17 +0100)
This allows simplification of the callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_migration_params.c
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h
tests/qemumonitorjsontest.c

index d1d59aeb017539bbd0d8f562bf778c71ec0a13d1..8c019bf2ced9fb5efedfceeef6f7936c3e739aae 100644 (file)
@@ -803,7 +803,6 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver,
     g_autoptr(virJSONValue) caps = NULL;
     qemuMigrationParam xbzrle = QEMU_MIGRATION_PARAM_XBZRLE_CACHE_SIZE;
     int ret = -1;
-    int rc;
 
     if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
         return -1;
@@ -819,12 +818,9 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver,
         if (!(caps = qemuMigrationCapsToJSON(priv->migrationCaps, migParams->caps)))
             goto cleanup;
 
-        if (virJSONValueArraySize(caps) > 0) {
-            rc = qemuMonitorSetMigrationCapabilities(priv->mon, caps);
-            caps = NULL;
-            if (rc < 0)
-                goto cleanup;
-        }
+        if (virJSONValueArraySize(caps) > 0 &&
+            qemuMonitorSetMigrationCapabilities(priv->mon, &caps) < 0)
+            goto cleanup;
     }
 
     /* If QEMU is too old to support xbzrle-cache-size migration parameter,
@@ -1389,8 +1385,7 @@ qemuMigrationCapsCheck(virQEMUDriverPtr driver,
         if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
             return -1;
 
-        rc = qemuMonitorSetMigrationCapabilities(priv->mon, json);
-        json = NULL;
+        rc = qemuMonitorSetMigrationCapabilities(priv->mon, &json);
 
         if (qemuDomainObjExitMonitor(driver, vm) < 0)
             return -1;
index f0a69f59cf5124d0d7892decedec5476f5f52fff..73d25ec628a18633365bceb87e42badb20c7b73a 100644 (file)
@@ -3879,22 +3879,17 @@ qemuMonitorGetMigrationCapabilities(qemuMonitorPtr mon,
  * @mon: Pointer to the monitor object.
  * @caps: Migration capabilities.
  *
- * The @caps object is consumed and should not be referenced by the caller
- * after this function returns.
+ * The @caps object is consumed cleared on success and some errors.
  *
  * Returns 0 on success, -1 on error.
  */
 int
 qemuMonitorSetMigrationCapabilities(qemuMonitorPtr mon,
-                                    virJSONValuePtr caps)
+                                    virJSONValuePtr *caps)
 {
-    QEMU_CHECK_MONITOR_GOTO(mon, error);
+    QEMU_CHECK_MONITOR(mon);
 
     return qemuMonitorJSONSetMigrationCapabilities(mon, caps);
-
- error:
-    virJSONValueFree(caps);
-    return -1;
 }
 
 
index c543515cdc974680acd76c51fdf125000d4e05c8..a07617ec285277a727a48d949debd641424e0cc8 100644 (file)
@@ -864,7 +864,7 @@ int qemuMonitorGetMigrationStats(qemuMonitorPtr mon,
 int qemuMonitorGetMigrationCapabilities(qemuMonitorPtr mon,
                                         char ***capabilities);
 int qemuMonitorSetMigrationCapabilities(qemuMonitorPtr mon,
-                                        virJSONValuePtr caps);
+                                        virJSONValuePtr *caps);
 
 int qemuMonitorGetGICCapabilities(qemuMonitorPtr mon,
                                   virGICCapability **capabilities);
index ad517a99b803252f537521ec0759efe8b9f223a4..0660c37e1ea6a5950bbf92b6c319dbdc09db6cc8 100644 (file)
@@ -6972,14 +6972,14 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon,
 
 int
 qemuMonitorJSONSetMigrationCapabilities(qemuMonitorPtr mon,
-                                        virJSONValuePtr caps)
+                                        virJSONValuePtr *caps)
 {
     int ret = -1;
     virJSONValuePtr cmd = NULL;
     virJSONValuePtr reply = NULL;
 
     cmd = qemuMonitorJSONMakeCommand("migrate-set-capabilities",
-                                     "a:capabilities", &caps,
+                                     "a:capabilities", caps,
                                      NULL);
     if (!cmd)
         goto cleanup;
@@ -6992,7 +6992,6 @@ qemuMonitorJSONSetMigrationCapabilities(qemuMonitorPtr mon,
 
     ret = 0;
  cleanup:
-    virJSONValueFree(caps);
     virJSONValueFree(cmd);
     virJSONValueFree(reply);
     return ret;
index f3d7d204d68c34627a2ff97c1aff3ab679031114..4a5292a69c566b20ee54aadccad21ae8cc009389 100644 (file)
@@ -149,7 +149,7 @@ int qemuMonitorJSONGetMigrationStats(qemuMonitorPtr mon,
 int qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon,
                                             char ***capabilities);
 int qemuMonitorJSONSetMigrationCapabilities(qemuMonitorPtr mon,
-                                            virJSONValuePtr caps);
+                                            virJSONValuePtr *caps);
 
 int qemuMonitorJSONGetGICCapabilities(qemuMonitorPtr mon,
                                       virGICCapability **capabilities);
index d0c37967d5e63726585ef2f5773e1d3f88a53618..13794c28860579e135e091bef05f33c78f47b4d5 100644 (file)
@@ -2092,8 +2092,7 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities(const void *opaque)
         goto cleanup;
 
     ret = qemuMonitorJSONSetMigrationCapabilities(qemuMonitorTestGetMonitor(test),
-                                                  json);
-    json = NULL;
+                                                  &json);
 
  cleanup:
     virJSONValueFree(json);