qemuMonitorJSONSetMigrationParams: Take double pointer for @params

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>
This commit is contained in:
Peter Krempa 2020-11-30 15:17:34 +01:00
parent 49cb59778a
commit 7e8a9118d5
5 changed files with 11 additions and 18 deletions

View 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;

View 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;
}

View 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,

View 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)

View 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,