1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-10-22 19:34:08 +03:00

admin: Introduce virAdmConnectGetLibVersion

Introduce a new API to get libvirt version. It is worth noting, that
libvirt-admin and libvirt share the same version number. Unfortunately,
our existing API isn't generic enough to be used with virAdmConnectPtr
as well. Also this patch wires up this API to the virt-admin client
as a generic cmdVersion command.
This commit is contained in:
Erik Skultety
2015-10-05 17:17:51 +02:00
parent 6dd7e42d89
commit a474371fc6
10 changed files with 135 additions and 4 deletions

View File

@@ -197,6 +197,67 @@ cmdURI(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
return true;
}
/*
* "version" command
*/
static const vshCmdInfo info_version[] = {
{.name = "help",
.data = N_("show version")
},
{.name = "desc",
.data = N_("Display the system and also the daemon version information.")
},
{.name = NULL}
};
static bool
cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
unsigned long libVersion;
unsigned long long includeVersion;
unsigned long long daemonVersion;
int ret;
unsigned int major;
unsigned int minor;
unsigned int rel;
vshAdmControlPtr priv = ctl->privData;
includeVersion = LIBVIR_VERSION_NUMBER;
major = includeVersion / 1000000;
includeVersion %= 1000000;
minor = includeVersion / 1000;
rel = includeVersion % 1000;
vshPrint(ctl, _("Compiled against library: libvirt %d.%d.%d\n"),
major, minor, rel);
ret = virGetVersion(&libVersion, NULL, NULL);
if (ret < 0) {
vshError(ctl, "%s", _("failed to get the library version"));
return false;
}
major = libVersion / 1000000;
libVersion %= 1000000;
minor = libVersion / 1000;
rel = libVersion % 1000;
vshPrint(ctl, _("Using library: libvirt %d.%d.%d\n"),
major, minor, rel);
ret = virAdmConnectGetLibVersion(priv->conn, &daemonVersion);
if (ret < 0) {
vshError(ctl, "%s", _("failed to get the daemon version"));
} else {
major = daemonVersion / 1000000;
daemonVersion %= 1000000;
minor = daemonVersion / 1000;
rel = daemonVersion % 1000;
vshPrint(ctl, _("Running against daemon: %d.%d.%d\n"),
major, minor, rel);
}
return true;
}
/* ---------------
* Command Connect
@@ -516,6 +577,12 @@ static const vshCmdDef vshAdmCmds[] = {
.info = info_uri,
.flags = 0
},
{.name = "version",
.handler = cmdVersion,
.opts = NULL,
.info = info_version,
.flags = 0
},
{.name = "connect",
.handler = cmdConnect,
.opts = opts_connect,