mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
openvz: refactor openvzDomainSetBarrierLimit
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
0d47463356
commit
783e0b9c8e
@ -1551,28 +1551,22 @@ openvzDomainSetBarrierLimit(virDomainPtr domain,
|
|||||||
unsigned long long barrier,
|
unsigned long long barrier,
|
||||||
unsigned long long limit)
|
unsigned long long limit)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
g_autoptr(virCommand) cmd = virCommandNewArgList(VZCTL, "--quiet", "set", NULL);
|
||||||
virCommand *cmd = virCommandNewArgList(VZCTL, "--quiet", "set", NULL);
|
|
||||||
|
|
||||||
/* LONG_MAX indicates unlimited so reject larger values */
|
/* LONG_MAX indicates unlimited so reject larger values */
|
||||||
if (barrier > LONG_MAX || limit > LONG_MAX) {
|
if (barrier > LONG_MAX || limit > LONG_MAX) {
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
_("Failed to set %s for %s: value too large"), param,
|
_("Failed to set %s for %s: value too large"), param,
|
||||||
domain->name);
|
domain->name);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virCommandAddArg(cmd, domain->name);
|
virCommandAddArg(cmd, domain->name);
|
||||||
virCommandAddArgFormat(cmd, "--%s", param);
|
virCommandAddArgFormat(cmd, "--%s", param);
|
||||||
virCommandAddArgFormat(cmd, "%llu:%llu", barrier, limit);
|
virCommandAddArgFormat(cmd, "%llu:%llu", barrier, limit);
|
||||||
virCommandAddArg(cmd, "--save");
|
virCommandAddArg(cmd, "--save");
|
||||||
if (virCommandRun(cmd, NULL) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
ret = 0;
|
return virCommandRun(cmd, NULL);
|
||||||
cleanup:
|
|
||||||
virCommandFree(cmd);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user