mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemuMonitorJSONSetBlockIoThrottle: Refactor cleanup
Switch to automatic memory freeing and remove the cleanup section. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
9c3fdcdfec
commit
2d57075cb6
@ -5428,10 +5428,9 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *mon,
|
|||||||
bool supportGroupNameOption,
|
bool supportGroupNameOption,
|
||||||
bool supportMaxLengthOptions)
|
bool supportMaxLengthOptions)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
g_autoptr(virJSONValue) cmd = NULL;
|
||||||
virJSONValue *cmd = NULL;
|
g_autoptr(virJSONValue) result = NULL;
|
||||||
virJSONValue *result = NULL;
|
g_autoptr(virJSONValue) args = NULL;
|
||||||
virJSONValue *args = NULL;
|
|
||||||
const char *errdev = drivealias;
|
const char *errdev = drivealias;
|
||||||
|
|
||||||
if (!errdev)
|
if (!errdev)
|
||||||
@ -5450,7 +5449,7 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *mon,
|
|||||||
"U:iops_rd", info->read_iops_sec,
|
"U:iops_rd", info->read_iops_sec,
|
||||||
"U:iops_wr", info->write_iops_sec,
|
"U:iops_wr", info->write_iops_sec,
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (supportMaxOptions &&
|
if (supportMaxOptions &&
|
||||||
virJSONValueObjectAdd(args,
|
virJSONValueObjectAdd(args,
|
||||||
@ -5462,13 +5461,13 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *mon,
|
|||||||
"U:iops_wr_max", info->write_iops_sec_max,
|
"U:iops_wr_max", info->write_iops_sec_max,
|
||||||
"U:iops_size", info->size_iops_sec,
|
"U:iops_size", info->size_iops_sec,
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (supportGroupNameOption &&
|
if (supportGroupNameOption &&
|
||||||
virJSONValueObjectAdd(args,
|
virJSONValueObjectAdd(args,
|
||||||
"S:group", info->group_name,
|
"S:group", info->group_name,
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (supportMaxLengthOptions &&
|
if (supportMaxLengthOptions &&
|
||||||
virJSONValueObjectAdd(args,
|
virJSONValueObjectAdd(args,
|
||||||
@ -5485,13 +5484,13 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *mon,
|
|||||||
"P:iops_wr_max_length",
|
"P:iops_wr_max_length",
|
||||||
info->write_iops_sec_max_length,
|
info->write_iops_sec_max_length,
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virJSONValueObjectAppend(cmd, "arguments", &args) < 0)
|
if (virJSONValueObjectAppend(cmd, "arguments", &args) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorJSONCommand(mon, cmd, &result) < 0)
|
if (qemuMonitorJSONCommand(mon, cmd, &result) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virJSONValueObjectHasKey(result, "error")) {
|
if (virJSONValueObjectHasKey(result, "error")) {
|
||||||
if (qemuMonitorJSONHasError(result, "DeviceNotActive")) {
|
if (qemuMonitorJSONHasError(result, "DeviceNotActive")) {
|
||||||
@ -5507,15 +5506,10 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *mon,
|
|||||||
qemuMonitorJSONCommandName(cmd),
|
qemuMonitorJSONCommandName(cmd),
|
||||||
qemuMonitorJSONStringifyError(error));
|
qemuMonitorJSONStringifyError(error));
|
||||||
}
|
}
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
virJSONValueFree(cmd);
|
|
||||||
virJSONValueFree(result);
|
|
||||||
virJSONValueFree(args);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemuMonitorJSONGetBlockIoThrottle(qemuMonitor *mon,
|
int qemuMonitorJSONGetBlockIoThrottle(qemuMonitor *mon,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user