1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

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))) if (!(params = qemuMigrationParamsToJSON(migParams)))
goto cleanup; goto cleanup;
if (virJSONValueObjectKeysNumber(params) > 0) { if (virJSONValueObjectKeysNumber(params) > 0 &&
rc = qemuMonitorSetMigrationParams(priv->mon, params); qemuMonitorSetMigrationParams(priv->mon, &params) < 0)
params = NULL;
if (rc < 0)
goto cleanup; goto cleanup;
}
ret = 0; ret = 0;

View File

@ -2464,22 +2464,17 @@ qemuMonitorGetMigrationParams(qemuMonitorPtr mon,
* @mon: Pointer to the monitor object. * @mon: Pointer to the monitor object.
* @params: Migration parameters. * @params: Migration parameters.
* *
* The @params object is consumed and should not be referenced by the caller * The @params object is consumed and cleared on success and some errors.
* after this function returns.
* *
* Returns 0 on success, -1 on error. * Returns 0 on success, -1 on error.
*/ */
int int
qemuMonitorSetMigrationParams(qemuMonitorPtr mon, qemuMonitorSetMigrationParams(qemuMonitorPtr mon,
virJSONValuePtr params) virJSONValuePtr *params)
{ {
QEMU_CHECK_MONITOR_GOTO(mon, error); QEMU_CHECK_MONITOR(mon);
return qemuMonitorJSONSetMigrationParams(mon, params); return qemuMonitorJSONSetMigrationParams(mon, params);
error:
virJSONValueFree(params);
return -1;
} }

View File

@ -793,7 +793,7 @@ int qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
int qemuMonitorGetMigrationParams(qemuMonitorPtr mon, int qemuMonitorGetMigrationParams(qemuMonitorPtr mon,
virJSONValuePtr *params); virJSONValuePtr *params);
int qemuMonitorSetMigrationParams(qemuMonitorPtr mon, int qemuMonitorSetMigrationParams(qemuMonitorPtr mon,
virJSONValuePtr params); virJSONValuePtr *params);
typedef enum { typedef enum {
QEMU_MONITOR_MIGRATION_STATUS_INACTIVE, QEMU_MONITOR_MIGRATION_STATUS_INACTIVE,

View File

@ -3461,12 +3461,13 @@ qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon,
int int
qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon, qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon,
virJSONValuePtr params) virJSONValuePtr *params)
{ {
g_autoptr(virJSONValue) cmd = NULL; g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = 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; return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)

View File

@ -140,7 +140,7 @@ int qemuMonitorJSONSetMigrationCacheSize(qemuMonitorPtr mon,
int qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon, int qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon,
virJSONValuePtr *params); virJSONValuePtr *params);
int qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon, int qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon,
virJSONValuePtr params); virJSONValuePtr *params);
int qemuMonitorJSONGetMigrationStats(qemuMonitorPtr mon, int qemuMonitorJSONGetMigrationStats(qemuMonitorPtr mon,
qemuMonitorMigrationStatsPtr stats, qemuMonitorMigrationStatsPtr stats,