mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00: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)
|
||||
{
|
||||
virCommand *cmd;
|
||||
char *outbuf;
|
||||
g_autoptr(virCommand) cmd = NULL;
|
||||
g_autofree char *outbuf = NULL;
|
||||
char *temp;
|
||||
int veid;
|
||||
bool ok;
|
||||
|
||||
cmd = virCommandNewArgList(VZLIST, name, "-ovpsid", "-H", NULL);
|
||||
virCommandSetOutputBuffer(cmd, &outbuf);
|
||||
if (virCommandRun(cmd, NULL) < 0) {
|
||||
virCommandFree(cmd);
|
||||
VIR_FREE(outbuf);
|
||||
if (virCommandRun(cmd, NULL) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
virCommandFree(cmd);
|
||||
ok = virStrToLong_i(outbuf, &temp, 10, &veid) == 0 && *temp == '\n';
|
||||
VIR_FREE(outbuf);
|
||||
|
||||
if (ok && veid >= 0)
|
||||
return veid;
|
||||
|
Loading…
Reference in New Issue
Block a user