[libvirt] [PATCH] show compiled in options in virsh --version

Daniel Veillard veillard at redhat.com
Thu Oct 28 13:00:45 UTC 2010


  To ease debugging this trivial patch allows to find what was compiled
in in the local version of libvirt, this doesn't work for remote access
but that's probably sufficient. With the patch I get on my machine:

paphio:~/libvirt/tools -> ./virsh --version
Virsh command line tool of libvirt 0.8.4
See web site at http://libvirt.org/

Compiled with support for:
 Hypervisors: Xen QEmu/KVM UML OpenVZ LXC ESX PHYP Test 
 Networking: Remote Daemon Network Bridging Netcf Nwfilter 
 Storage: Dir Disk Filesystem SCSI Multipath iSCSI LVM 
 Miscellaneous: SELinux Secrets Debug Readline 
paphio:~/libvirt/tools -> 

 instead of just "0.8.4"

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/
-------------- next part --------------
diff --git a/tools/virsh.c b/tools/virsh.c
index a182d4c..25edd97 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -11477,6 +11477,129 @@ vshUsage(void)
 }
 
 /*
+ * Show version and options compiled in
+ */
+static void
+vshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
+{
+    /* FIXME - list a copyright blurb, as in GNU programs?  */
+    vshPrint(ctl, _("Virsh command line tool of libvirt %s\n"), VERSION);
+    vshPrint(ctl, _("See web site at %s\n\n"), "http://libvirt.org/");
+
+    vshPrint(ctl, _("Compiled with support for:\n"));
+    vshPrint(ctl, _(" Hypervisors: "));
+#ifdef WITH_XEN
+    vshPrint(ctl, "Xen ");
+#endif
+#ifdef WITH_QEMU
+    vshPrint(ctl, "QEmu/KVM ");
+#endif
+#ifdef WITH_UML
+    vshPrint(ctl, "UML ");
+#endif
+#ifdef WITH_OPENVZ
+    vshPrint(ctl, "OpenVZ ");
+#endif
+#ifdef WITH_VBOX
+    vshPrint(ctl, "VirtualBox ");
+#endif
+#ifdef WITH_XENAPI
+    vshPrint(ctl, "XenAPI ");
+#endif
+#ifdef WITH_LXC
+    vshPrint(ctl, "LXC ");
+#endif
+#ifdef WITH_ESX
+    vshPrint(ctl, "ESX ");
+#endif
+#ifdef WITH_PHYP
+    vshPrint(ctl, "PHYP ");
+#endif
+#ifdef WITH_ONE
+    vshPrint(ctl, "ONE ");
+#endif
+#ifdef WITH_TEST
+    vshPrint(ctl, "Test ");
+#endif
+    vshPrint(ctl, "\n");
+
+    vshPrint(ctl, _(" Networking: "));
+#ifdef WITH_REMOTE
+    vshPrint(ctl, "Remote ");
+#endif
+#ifdef WITH_PROXY
+    vshPrint(ctl, "Proxy ");
+#endif
+#ifdef WITH_LIBVIRTD
+    vshPrint(ctl, "Daemon ");
+#endif
+#ifdef WITH_NETWORK
+    vshPrint(ctl, "Network ");
+#endif
+#ifdef WITH_BRIDGE
+    vshPrint(ctl, "Bridging ");
+#endif
+#ifdef WITH_NETCF
+    vshPrint(ctl, "Netcf ");
+#endif
+#ifdef WITH_NWFILTER
+    vshPrint(ctl, "Nwfilter ");
+#endif
+#ifdef WITH_VIRTUALPORT
+    vshPrint(ctl, "VirtualPort ");
+#endif
+    vshPrint(ctl, "\n");
+
+    vshPrint(ctl, _(" Storage: "));
+#ifdef WITH_STORAGE_DIR
+    vshPrint(ctl, "Dir ");
+#endif
+#ifdef WITH_STORAGE_DISK
+    vshPrint(ctl, "Disk ");
+#endif
+#ifdef WITH_STORAGE_FS
+    vshPrint(ctl, "Filesystem ");
+#endif
+#ifdef WITH_STORAGE_SCSI
+    vshPrint(ctl, "SCSI ");
+#endif
+#ifdef WITH_STORAGE_MPATH
+    vshPrint(ctl, "Multipath ");
+#endif
+#ifdef WITH_STORAGE_ISCSI
+    vshPrint(ctl, "iSCSI ");
+#endif
+#ifdef WITH_STORAGE_LVM
+    vshPrint(ctl, "LVM ");
+#endif
+    vshPrint(ctl, "\n");
+
+    vshPrint(ctl, _(" Miscellaneous: "));
+#ifdef ENABLE_SECDRIVER_APPARMOR
+    vshPrint(ctl, "AppArmor ");
+#endif
+#ifdef WITH_SECDRIVER_SELINUX
+    vshPrint(ctl, "SELinux ");
+#endif
+#ifdef WITH_SECRETS
+    vshPrint(ctl, "Secrets ");
+#endif
+#ifdef ENABLE_DEBUG
+    vshPrint(ctl, "Debug ");
+#endif
+#ifdef WITH_DTRACE
+    vshPrint(ctl, "DTrace ");
+#endif
+#ifdef USE_READLINE
+    vshPrint(ctl, "Readline ");
+#endif
+#ifdef WITH_DRIVER_MODULES
+    vshPrint(ctl, "Modular ");
+#endif
+    vshPrint(ctl, "\n");
+}
+
+/*
  * argv[]:  virsh [options] [command]
  *
  */
@@ -11521,8 +11644,7 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
             ctl->name = vshStrdup(ctl, optarg);
             break;
         case 'v':
-            /* FIXME - list a copyright blurb, as in GNU programs?  */
-            puts(VERSION);
+            vshShowVersion(ctl);
             exit(EXIT_SUCCESS);
         case 'r':
             ctl->readonly = TRUE;
diff --git a/tools/virsh.pod b/tools/virsh.pod
index d904800..3c49ea5 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -56,8 +56,8 @@ given instead.
 
 =item B<-v>, B<--version>
 
-Ignore all other arguments, and behave as if the B<version> command were
-given instead.
+Ignore all other arguments, and prints the version of the libvirt library
+virsh is coming from and which options and driver are compiled in.
 
 =item B<-c>, B<--connect> I<URI>
 


More information about the libvir-list mailing list