This allows simplification of the callers.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
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;
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,
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;
* @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;
}
int qemuMonitorGetMigrationCapabilities(qemuMonitorPtr mon,
char ***capabilities);
int qemuMonitorSetMigrationCapabilities(qemuMonitorPtr mon,
- virJSONValuePtr caps);
+ virJSONValuePtr *caps);
int qemuMonitorGetGICCapabilities(qemuMonitorPtr mon,
virGICCapability **capabilities);
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;
ret = 0;
cleanup:
- virJSONValueFree(caps);
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
int qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon,
char ***capabilities);
int qemuMonitorJSONSetMigrationCapabilities(qemuMonitorPtr mon,
- virJSONValuePtr caps);
+ virJSONValuePtr *caps);
int qemuMonitorJSONGetGICCapabilities(qemuMonitorPtr mon,
virGICCapability **capabilities);
goto cleanup;
ret = qemuMonitorJSONSetMigrationCapabilities(qemuMonitorTestGetMonitor(test),
- json);
- json = NULL;
+ &json);
cleanup:
virJSONValueFree(json);