[libvirt] [PATCH] virsh: Add daemon version reporting

From: Michal Privoznik <mprivozn@redhat.com> 'virsh version' might report against which version of libvirtd is running. --- tools/virsh.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index d98be1c..d3c3ce3 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -8620,6 +8620,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; @@ -8678,6 +8679,19 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) vshPrint(ctl, _("Running hypervisor: %s %d.%d.%d\n"), hvType, major, minor, rel); } + + ret = virConnectGetLibVersion(ctl->conn, &daemonVersion); + if (ret < 0) { + vshError(ctl, "%s", _("failed to get the daemon version")); + return false; + } + 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; } -- 1.7.5.rc3

On Mon, Jun 06, 2011 at 02:10:49PM +0200, Michal Prívozník wrote:
From: Michal Privoznik <mprivozn@redhat.com>
'virsh version' might report against which version of libvirtd is running. --- tools/virsh.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c index d98be1c..d3c3ce3 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -8620,6 +8620,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; @@ -8678,6 +8679,19 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) vshPrint(ctl, _("Running hypervisor: %s %d.%d.%d\n"), hvType, major, minor, rel); } + + ret = virConnectGetLibVersion(ctl->conn, &daemonVersion); + if (ret < 0) { + vshError(ctl, "%s", _("failed to get the daemon version")); + return false;
Raising an error here will prevent virsh talking to any libvirtd < 0.7.3 Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 06/06/2011 06:17 AM, Daniel P. Berrange wrote:
+ + ret = virConnectGetLibVersion(ctl->conn, &daemonVersion); + if (ret < 0) { + vshError(ctl, "%s", _("failed to get the daemon version")); + return false;
Raising an error here will prevent virsh talking to any libvirtd < 0.7.3
Also, this changes virsh output, which might break existing scripts. It would be safer to introduce a new bool flag, 'virsh version --daemon', to specifically request the new output line. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Michal Prívozník