mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
openvz: refactor openvzDomainGetBarrierLimit
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
5c7c1db2f5
commit
0d47463356
@ -1515,37 +1515,33 @@ openvzDomainGetBarrierLimit(virDomainPtr domain,
|
|||||||
unsigned long long *barrier,
|
unsigned long long *barrier,
|
||||||
unsigned long long *limit)
|
unsigned long long *limit)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
char *endp;
|
||||||
char *endp, *output = NULL;
|
g_autofree char *output = NULL;
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
virCommand *cmd = virCommandNewArgList(VZLIST, "--no-header", NULL);
|
g_autoptr(virCommand) cmd = virCommandNewArgList(VZLIST, "--no-header", NULL);
|
||||||
|
|
||||||
virCommandSetOutputBuffer(cmd, &output);
|
virCommandSetOutputBuffer(cmd, &output);
|
||||||
virCommandAddArgFormat(cmd, "-o%s.b,%s.l", param, param);
|
virCommandAddArgFormat(cmd, "-o%s.b,%s.l", param, param);
|
||||||
virCommandAddArg(cmd, domain->name);
|
virCommandAddArg(cmd, domain->name);
|
||||||
if (virCommandRun(cmd, NULL) < 0)
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
tmp = output;
|
tmp = output;
|
||||||
virSkipSpaces(&tmp);
|
virSkipSpaces(&tmp);
|
||||||
if (virStrToLong_ull(tmp, &endp, 10, barrier) < 0) {
|
if (virStrToLong_ull(tmp, &endp, 10, barrier) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Can't parse limit from vzlist output '%s'"), output);
|
_("Can't parse limit from vzlist output '%s'"), output);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
tmp = endp;
|
tmp = endp;
|
||||||
virSkipSpaces(&tmp);
|
virSkipSpaces(&tmp);
|
||||||
if (virStrToLong_ull(tmp, &endp, 10, limit) < 0) {
|
if (virStrToLong_ull(tmp, &endp, 10, limit) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Can't parse barrier from vzlist output '%s'"), output);
|
_("Can't parse barrier from vzlist output '%s'"), output);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
VIR_FREE(output);
|
|
||||||
virCommandFree(cmd);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user