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

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 -> v2: map the command to -V and leave -v/--version unchanged change the way spacing is done Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On 11/05/2010 11:20 AM, Daniel Veillard wrote:
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 ->
+++ b/tools/virsh.c @@ -11525,6 +11525,7 @@ vshUsage(void) " -t | --timing print timing information\n" " -l | --log <file> output logging to file\n" " -v | --version program version\n\n" + " -V version and full options\n\n"
In general, it's nice to have a long-option to go with every short option, but I don't think it's worth holding up this patch for just that. ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Mon, Nov 08, 2010 at 08:26:18AM -0700, Eric Blake wrote:
On 11/05/2010 11:20 AM, Daniel Veillard wrote:
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 ->
+++ b/tools/virsh.c @@ -11525,6 +11525,7 @@ vshUsage(void) " -t | --timing print timing information\n" " -l | --log <file> output logging to file\n" " -v | --version program version\n\n" + " -V version and full options\n\n"
In general, it's nice to have a long-option to go with every short option, but I don't think it's worth holding up this patch for just that.
ACK.
Thanks, pushed. I really think that -V was the right pick since it's the usual flag for this kind of informations, but since -v/--version was already used I had no idea how to name the long option, especially starting with letter v... Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On 09/11/2010, at 10:16 PM, Daniel Veillard wrote:
I really think that -V was the right pick since it's the usual flag for this kind of informations, but since -v/--version was already used I had no idea how to name the long option, especially starting with letter v...
The "creative" approach: --aVailable-stuff :)

On 11/09/2010 04:16 AM, Daniel Veillard wrote:
+++ b/tools/virsh.c @@ -11525,6 +11525,7 @@ vshUsage(void) " -t | --timing print timing information\n" " -l | --log <file> output logging to file\n" " -v | --version program version\n\n" + " -V version and full options\n\n"
In general, it's nice to have a long-option to go with every short option, but I don't think it's worth holding up this patch for just that.
ACK.
Thanks, pushed.
I really think that -V was the right pick since it's the usual flag for this kind of informations, but since -v/--version was already used I had no idea how to name the long option, especially starting with letter v...
My earlier proposal was to make --version take an optional argument (only the long option form; the short options -v and -V have no argument): -v | --version[=short] program version -V | --version=long version and full options I can code that up, if you like the idea. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Tue, Nov 09, 2010 at 08:11:21AM -0700, Eric Blake wrote:
On 11/09/2010 04:16 AM, Daniel Veillard wrote:
+++ b/tools/virsh.c @@ -11525,6 +11525,7 @@ vshUsage(void) " -t | --timing print timing information\n" " -l | --log <file> output logging to file\n" " -v | --version program version\n\n" + " -V version and full options\n\n"
In general, it's nice to have a long-option to go with every short option, but I don't think it's worth holding up this patch for just that.
ACK.
Thanks, pushed.
I really think that -V was the right pick since it's the usual flag for this kind of informations, but since -v/--version was already used I had no idea how to name the long option, especially starting with letter v...
My earlier proposal was to make --version take an optional argument (only the long option form; the short options -v and -V have no argument):
-v | --version[=short] program version -V | --version=long version and full options
I can code that up, if you like the idea.
sure sounds fine to me, sorry I didn't remembered your suggestion ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

* tools/virsh.c (vshParseArgv): Use NULL instead of 0 for pointer, and symbolic names for has_arg. Give --version an optional arg. (vshUsage): Document this. * tools/virsh.pod: Likewise. --- Technically, this treats '--version=anything' as -v, so that only '--version=long' is -V; if you want, I can spin a V2 that requires that optarg be exactly NULL, "short", or "long", rather than letting anything go, but I didn't think it was worth it. tools/virsh.c | 31 +++++++++++++++++-------------- tools/virsh.pod | 4 ++-- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 26d7f5a..5caa46e 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -11524,8 +11524,8 @@ vshUsage(void) " -q | --quiet quiet mode\n" " -t | --timing print timing information\n" " -l | --log <file> output logging to file\n" - " -v | --version program version\n\n" - " -V version and full options\n\n" + " -v | --version[=short] program version\n\n" + " -V | --version=long version and full options\n\n" " commands (non interactive mode):\n"), progname, progname); for (cmd = commands; cmd->name; cmd++) @@ -11670,15 +11670,15 @@ vshParseArgv(vshControl *ctl, int argc, char **argv) bool help = false; int arg; struct option opt[] = { - {"debug", 1, 0, 'd'}, - {"help", 0, 0, 'h'}, - {"quiet", 0, 0, 'q'}, - {"timing", 0, 0, 't'}, - {"version", 0, 0, 'v'}, - {"connect", 1, 0, 'c'}, - {"readonly", 0, 0, 'r'}, - {"log", 1, 0, 'l'}, - {0, 0, 0, 0} + {"debug", required_argument, NULL, 'd'}, + {"help", no_argument, NULL, 'h'}, + {"quiet", no_argument, NULL, 'q'}, + {"timing", no_argument, NULL, 't'}, + {"version", optional_argument, NULL, 'v'}, + {"connect", required_argument, NULL, 'c'}, + {"readonly", no_argument, NULL, 'r'}, + {"log", required_argument, NULL, 'l'}, + {NULL, 0, NULL, 0} }; /* Standard (non-command) options. The leading + ensures that no @@ -11704,12 +11704,15 @@ vshParseArgv(vshControl *ctl, int argc, char **argv) case 'c': ctl->name = vshStrdup(ctl, optarg); break; + case 'v': + if (STRNEQ_NULLABLE(optarg, "long")) { + puts(VERSION); + exit(EXIT_SUCCESS); + } + /* fall through */ case 'V': vshShowVersion(ctl); exit(EXIT_SUCCESS); - case 'v': - puts(VERSION); - exit(EXIT_SUCCESS); case 'r': ctl->readonly = TRUE; break; diff --git i/tools/virsh.pod w/tools/virsh.pod index 4f3f220..6bfae09 100644 --- i/tools/virsh.pod +++ w/tools/virsh.pod @@ -54,12 +54,12 @@ The B<virsh> program understands the following I<OPTIONS>. Ignore all other arguments, and behave as if the B<help> command were given instead. -=item B<-v>, B<--version> +=item B<-v>, B<--version>[=short] Ignore all other arguments, and prints the version of the libvirt library virsh is coming from -=item B<-V> +=item B<-V>, B<--version=long> Ignore all other arguments, and prints the version of the libvirt library virsh is coming from and which options and driver are compiled in. -- 1.7.3.2

2010/11/9 Eric Blake <eblake@redhat.com>:
* tools/virsh.c (vshParseArgv): Use NULL instead of 0 for pointer, and symbolic names for has_arg. Give --version an optional arg. (vshUsage): Document this. * tools/virsh.pod: Likewise. ---
ACK. Matthias

On 11/10/2010 03:43 PM, Matthias Bolte wrote:
2010/11/9 Eric Blake <eblake@redhat.com>:
* tools/virsh.c (vshParseArgv): Use NULL instead of 0 for pointer, and symbolic names for has_arg. Give --version an optional arg. (vshUsage): Document this. * tools/virsh.pod: Likewise. ---
ACK.
Thanks; pushed. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (4)
-
Daniel Veillard
-
Eric Blake
-
Justin Clift
-
Matthias Bolte