Show compiled in options in virsh -V

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 -V
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 ->

* tools/virsh.c: add -V option
* tools/virsh.pod: document the extension
This commit is contained in:
Daniel Veillard 2010-11-08 15:03:32 +01:00
parent c60c450bc3
commit 5879c15dfd
2 changed files with 135 additions and 4 deletions

View File

@ -11525,6 +11525,7 @@ vshUsage(void)
" -t | --timing print timing information\n" " -t | --timing print timing information\n"
" -l | --log <file> output logging to file\n" " -l | --log <file> output logging to file\n"
" -v | --version program version\n\n" " -v | --version program version\n\n"
" -V version and full options\n\n"
" commands (non interactive mode):\n"), progname, progname); " commands (non interactive mode):\n"), progname, progname);
for (cmd = commands; cmd->name; cmd++) for (cmd = commands; cmd->name; cmd++)
@ -11536,6 +11537,129 @@ vshUsage(void)
return; return;
} }
/*
* 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] * argv[]: virsh [options] [command]
* *
@ -11560,7 +11684,7 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
/* Standard (non-command) options. The leading + ensures that no /* Standard (non-command) options. The leading + ensures that no
* argument reordering takes place, so that command options are * argument reordering takes place, so that command options are
* not confused with top-level virsh options. */ * not confused with top-level virsh options. */
while ((arg = getopt_long(argc, argv, "+d:hqtc:vrl:", opt, NULL)) != -1) { while ((arg = getopt_long(argc, argv, "+d:hqtc:vVrl:", opt, NULL)) != -1) {
switch (arg) { switch (arg) {
case 'd': case 'd':
if (virStrToLong_i(optarg, NULL, 10, &ctl->debug) < 0) { if (virStrToLong_i(optarg, NULL, 10, &ctl->debug) < 0) {
@ -11580,8 +11704,10 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
case 'c': case 'c':
ctl->name = vshStrdup(ctl, optarg); ctl->name = vshStrdup(ctl, optarg);
break; break;
case 'V':
vshShowVersion(ctl);
exit(EXIT_SUCCESS);
case 'v': case 'v':
/* FIXME - list a copyright blurb, as in GNU programs? */
puts(VERSION); puts(VERSION);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
case 'r': case 'r':

View File

@ -56,8 +56,13 @@ given instead.
=item B<-v>, B<--version> =item B<-v>, B<--version>
Ignore all other arguments, and behave as if the B<version> command were Ignore all other arguments, and prints the version of the libvirt library
given instead. virsh is coming from
=item B<-V>
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> =item B<-c>, B<--connect> I<URI>