]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorJSONSetMigrationParams: Take double pointer for @params
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 caller as well as will enable a later
refactor of qemuMonitorJSONMakeCommandInternal.

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

index df5560d39f016efbea4f5577c9f6770b1492238e..d1d59aeb017539bbd0d8f562bf778c71ec0a13d1 100644 (file)
@@ -843,12 +843,9 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver,
     if (!(params = qemuMigrationParamsToJSON(migParams)))
         goto cleanup;
 
-    if (virJSONValueObjectKeysNumber(params) > 0) {
-        rc = qemuMonitorSetMigrationParams(priv->mon, params);
-        params = NULL;
-        if (rc < 0)
-            goto cleanup;
-    }
+    if (virJSONValueObjectKeysNumber(params) > 0 &&
+        qemuMonitorSetMigrationParams(priv->mon, &params) < 0)
+        goto cleanup;
 
     ret = 0;
 
index abdd9d5240408cd8ab16aa1c7a7567a611691312..f0a69f59cf5124d0d7892decedec5476f5f52fff 100644 (file)
@@ -2464,22 +2464,17 @@ qemuMonitorGetMigrationParams(qemuMonitorPtr mon,
  * @mon: Pointer to the monitor object.
  * @params: Migration parameters.
  *
- * The @params object is consumed and should not be referenced by the caller
- * after this function returns.
+ * The @params object is consumed and cleared on success and some errors.
  *
  * Returns 0 on success, -1 on error.
  */
 int
 qemuMonitorSetMigrationParams(qemuMonitorPtr mon,
-                              virJSONValuePtr params)
+                              virJSONValuePtr *params)
 {
-    QEMU_CHECK_MONITOR_GOTO(mon, error);
+    QEMU_CHECK_MONITOR(mon);
 
     return qemuMonitorJSONSetMigrationParams(mon, params);
-
- error:
-    virJSONValueFree(params);
-    return -1;
 }
 
 
index 3a09b995ce81c4008722a7e2b607380f25d1ff4a..c543515cdc974680acd76c51fdf125000d4e05c8 100644 (file)
@@ -793,7 +793,7 @@ int qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
 int qemuMonitorGetMigrationParams(qemuMonitorPtr mon,
                                   virJSONValuePtr *params);
 int qemuMonitorSetMigrationParams(qemuMonitorPtr mon,
-                                  virJSONValuePtr params);
+                                  virJSONValuePtr *params);
 
 typedef enum {
     QEMU_MONITOR_MIGRATION_STATUS_INACTIVE,
index 936254f0ec4d9e66f2f0c49a09681d0a510782c3..ad517a99b803252f537521ec0759efe8b9f223a4 100644 (file)
@@ -3461,12 +3461,13 @@ qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon,
 
 int
 qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon,
-                                  virJSONValuePtr params)
+                                  virJSONValuePtr *params)
 {
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
+    virJSONValuePtr par = g_steal_pointer(params);
 
-    if (!(cmd = qemuMonitorJSONMakeCommandInternal("migrate-set-parameters", params)))
+    if (!(cmd = qemuMonitorJSONMakeCommandInternal("migrate-set-parameters", par)))
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
index 4eb0f667a2381407804e6b9ee6338c4c05c0bd5d..f3d7d204d68c34627a2ff97c1aff3ab679031114 100644 (file)
@@ -140,7 +140,7 @@ int qemuMonitorJSONSetMigrationCacheSize(qemuMonitorPtr mon,
 int qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon,
                                       virJSONValuePtr *params);
 int qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon,
-                                      virJSONValuePtr params);
+                                      virJSONValuePtr *params);
 
 int qemuMonitorJSONGetMigrationStats(qemuMonitorPtr mon,
                                      qemuMonitorMigrationStatsPtr stats,