This allows simplification of the callers.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_migration_params.c | 13 ++++---------
src/qemu/qemu_monitor.c | 11 +++--------
src/qemu/qemu_monitor.h | 2 +-
src/qemu/qemu_monitor_json.c | 5 ++---
src/qemu/qemu_monitor_json.h | 2 +-
tests/qemumonitorjsontest.c | 3 +--
6 files changed, 12 insertions(+), 24 deletions(-)
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index d1d59aeb01..8c019bf2ce 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -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;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index f8287d375f..b29779f8e4 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3942,22 +3942,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.
*
* 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;
}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index c8b9111633..a7fba393bf 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -870,7 +870,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);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index bb454bf49d..fe5c26f37f 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -7131,14 +7131,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;
@@ -7151,7 +7151,6 @@ qemuMonitorJSONSetMigrationCapabilities(qemuMonitorPtr mon,
ret = 0;
cleanup:
- virJSONValueFree(caps);
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index b3f3e79041..9cb4ec264b 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -151,7 +151,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);
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 25ebf06eb0..954a074f15 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -2259,8 +2259,7 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities(const
void *opaque)
goto cleanup;
ret = qemuMonitorJSONSetMigrationCapabilities(qemuMonitorTestGetMonitor(test),
- json);
- json = NULL;
+ &json);
cleanup:
virJSONValueFree(json);
--
2.28.0