mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-05 22:05:47 +00:00
openvz: refactor openvzGetVEStatus
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
783e0b9c8e
commit
c5ae8135df
@ -1697,21 +1697,20 @@ openvzDomainSetMemoryParameters(virDomainPtr domain,
|
|||||||
static int
|
static int
|
||||||
openvzGetVEStatus(virDomainObj *vm, int *status, int *reason)
|
openvzGetVEStatus(virDomainObj *vm, int *status, int *reason)
|
||||||
{
|
{
|
||||||
virCommand *cmd;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
char *outbuf;
|
g_autofree char *outbuf = NULL;
|
||||||
char *line;
|
char *line;
|
||||||
int state;
|
int state;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
cmd = virCommandNewArgList(VZLIST, vm->def->name, "-ostatus", "-H", NULL);
|
cmd = virCommandNewArgList(VZLIST, vm->def->name, "-ostatus", "-H", NULL);
|
||||||
virCommandSetOutputBuffer(cmd, &outbuf);
|
virCommandSetOutputBuffer(cmd, &outbuf);
|
||||||
if (virCommandRun(cmd, NULL) < 0)
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if ((line = strchr(outbuf, '\n')) == NULL) {
|
if ((line = strchr(outbuf, '\n')) == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to parse vzlist output"));
|
_("Failed to parse vzlist output"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
*line++ = '\0';
|
*line++ = '\0';
|
||||||
|
|
||||||
@ -1728,12 +1727,7 @@ openvzGetVEStatus(virDomainObj *vm, int *status, int *reason)
|
|||||||
*status = VIR_DOMAIN_SHUTOFF;
|
*status = VIR_DOMAIN_SHUTOFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virCommandFree(cmd);
|
|
||||||
VIR_FREE(outbuf);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user