mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
openvz: refactor openvzGetVEID
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
680d8c91e8
commit
0dfb73a511
@ -978,23 +978,18 @@ static int openvzAssignUUIDs(void)
|
|||||||
|
|
||||||
int openvzGetVEID(const char *name)
|
int openvzGetVEID(const char *name)
|
||||||
{
|
{
|
||||||
virCommand *cmd;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
char *outbuf;
|
g_autofree char *outbuf = NULL;
|
||||||
char *temp;
|
char *temp;
|
||||||
int veid;
|
int veid;
|
||||||
bool ok;
|
bool ok;
|
||||||
|
|
||||||
cmd = virCommandNewArgList(VZLIST, name, "-ovpsid", "-H", NULL);
|
cmd = virCommandNewArgList(VZLIST, name, "-ovpsid", "-H", NULL);
|
||||||
virCommandSetOutputBuffer(cmd, &outbuf);
|
virCommandSetOutputBuffer(cmd, &outbuf);
|
||||||
if (virCommandRun(cmd, NULL) < 0) {
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
virCommandFree(cmd);
|
|
||||||
VIR_FREE(outbuf);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
virCommandFree(cmd);
|
|
||||||
ok = virStrToLong_i(outbuf, &temp, 10, &veid) == 0 && *temp == '\n';
|
ok = virStrToLong_i(outbuf, &temp, 10, &veid) == 0 && *temp == '\n';
|
||||||
VIR_FREE(outbuf);
|
|
||||||
|
|
||||||
if (ok && veid >= 0)
|
if (ok && veid >= 0)
|
||||||
return veid;
|
return veid;
|
||||||
|
Loading…
Reference in New Issue
Block a user