mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
qemuMonitorJSONSetMigrationParams: Refactor command construction and cleanup
qemuMonitorJSONMakeCommandInternal does the full command construction if you pass in what would become the value of the 'arguments' key. Refactor the open-coded implementation to use the helper and use modern cleanup helpers at the same time. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
e9153cc604
commit
b5d8d4b025
@ -3440,30 +3440,19 @@ int
|
|||||||
qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon,
|
qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon,
|
||||||
virJSONValuePtr params)
|
virJSONValuePtr params)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
g_autoptr(virJSONValue) cmd = NULL;
|
||||||
virJSONValuePtr cmd = virJSONValueNewObject();
|
g_autoptr(virJSONValue) reply = NULL;
|
||||||
virJSONValuePtr reply = NULL;
|
|
||||||
|
|
||||||
if (virJSONValueObjectAppendString(cmd, "execute",
|
if (!(cmd = qemuMonitorJSONMakeCommandInternal("migrate-set-parameters", params)))
|
||||||
"migrate-set-parameters") < 0)
|
return -1;
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (virJSONValueObjectAppend(cmd, "arguments", params) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
params = NULL;
|
|
||||||
|
|
||||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
virJSONValueFree(cmd);
|
|
||||||
virJSONValueFree(params);
|
|
||||||
virJSONValueFree(reply);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user