mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
openvz: refactor openvzExtractVersionInfo
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
359e9f5cf4
commit
73a716eecd
@ -66,11 +66,10 @@ strtoI(const char *str)
|
|||||||
static int
|
static int
|
||||||
openvzExtractVersionInfo(const char *cmdstr, int *retversion)
|
openvzExtractVersionInfo(const char *cmdstr, int *retversion)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
unsigned long version;
|
unsigned long version;
|
||||||
char *help = NULL;
|
g_autofree char *help = NULL;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
virCommand *cmd = virCommandNewArgList(cmdstr, "--help", NULL);
|
g_autoptr(virCommand) cmd = virCommandNewArgList(cmdstr, "--help", NULL);
|
||||||
|
|
||||||
if (retversion)
|
if (retversion)
|
||||||
*retversion = 0;
|
*retversion = 0;
|
||||||
@ -79,27 +78,21 @@ openvzExtractVersionInfo(const char *cmdstr, int *retversion)
|
|||||||
virCommandSetOutputBuffer(cmd, &help);
|
virCommandSetOutputBuffer(cmd, &help);
|
||||||
|
|
||||||
if (virCommandRun(cmd, NULL) < 0)
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
tmp = help;
|
tmp = help;
|
||||||
|
|
||||||
/* expected format: vzctl version <major>.<minor>.<micro> */
|
/* expected format: vzctl version <major>.<minor>.<micro> */
|
||||||
if ((tmp = STRSKIP(tmp, "vzctl version ")) == NULL)
|
if ((tmp = STRSKIP(tmp, "vzctl version ")) == NULL)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virParseVersionString(tmp, &version, true) < 0)
|
if (virParseVersionString(tmp, &version, true) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (retversion)
|
if (retversion)
|
||||||
*retversion = version;
|
*retversion = version;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virCommandFree(cmd);
|
|
||||||
VIR_FREE(help);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int openvzExtractVersion(struct openvz_driver *driver)
|
int openvzExtractVersion(struct openvz_driver *driver)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user