From: Michal Privoznik <mprivozn(a)redhat.com>
'virsh version' might report against which version of libvirtd is
running.
---
diff to v1:
- added 'daemon' switch
- don't fail when no deamon version is available
tools/virsh.c | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 123781f..56405c0 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -8658,6 +8658,10 @@ static const vshCmdInfo info_version[] = {
{NULL, NULL}
};
+static const vshCmdOptDef opts_version[] = {
+ {"daemon", VSH_OT_BOOL, VSH_OFLAG_NONE, N_("report daemon version
too")},
+ {NULL, 0, 0, NULL}
+};
static bool
cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
@@ -8667,6 +8671,7 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
unsigned long libVersion;
unsigned long includeVersion;
unsigned long apiVersion;
+ unsigned long daemonVersion;
int ret;
unsigned int major;
unsigned int minor;
@@ -8725,6 +8730,21 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshPrint(ctl, _("Running hypervisor: %s %d.%d.%d\n"),
hvType, major, minor, rel);
}
+
+ if (vshCommandOptBool(cmd, "daemon")) {
+ ret = virConnectGetLibVersion(ctl->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;
}
@@ -11148,7 +11168,7 @@ static const vshCmdDef domManagementCmds[] = {
{"vcpucount", cmdVcpucount, opts_vcpucount, info_vcpucount, 0},
{"vcpuinfo", cmdVcpuinfo, opts_vcpuinfo, info_vcpuinfo, 0},
{"vcpupin", cmdVcpupin, opts_vcpupin, info_vcpupin, 0},
- {"version", cmdVersion, NULL, info_version, 0},
+ {"version", cmdVersion, opts_version, info_version, 0},
{"vncdisplay", cmdVNCDisplay, opts_vncdisplay, info_vncdisplay, 0},
{NULL, NULL, NULL, NULL, 0}
};
--
1.7.5.rc3