Bug 817244 - Issues about virsh -h usage
Issues about virsh -h usage
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt (Show other bugs)
x86_64 Linux
medium Severity medium
: rc
: ---
Assigned To: Eric Blake
Virtualization Bugs
Depends On:
  Show dependency treegraph
Reported: 2012-04-28 05:15 EDT by min zhan
Modified: 2013-02-21 02:12 EST (History)
8 users (show)

See Also:
Fixed In Version: libvirt-0.9.13-3.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-02-21 02:12:35 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description min zhan 2012-04-28 05:15:03 EDT
Description of problem:
Some issues about virsh -h usage

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:

Man page:
-h, --help
Ignore all other arguments, and behave as if the help command were
           given instead.

Test with the following, found -h does not ignore all other arguments. If it is not, I think the doc should be improved. 

# virsh -h -v -V

# virsh -h -V -v
Virsh command line tool of libvirt 0.9.10
See web site at http://libvirt.org/

Compiled with support for:
 Hypervisors: QEmu/KVM LXC ESX Test
 Networking: Remote Daemon Network Bridging Netcf Nwfilter VirtualPort
 Storage: Dir Disk Filesystem SCSI Multipath iSCSI LVM
 Miscellaneous: SELinux Secrets Debug DTrace Readline
Actual results:
As above

Expected results:
doc should be improved.

Additional info:
Comment 1 min zhan 2012-04-28 05:21:21 EDT
Also the following result would be confused:

# virsh -l -h 
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # 

Actually here it think -h is a log file name and output this result; not the -h (help) argument to ignore other options and show the help page, which may be the users' original thought.
Comment 2 Eric Blake 2012-04-28 12:56:11 EDT
For comment 0: this should be easy to fix, since the parser currently treats -h as setting a flag that only gets checked after all other options are parsed, while -v and -V exit immediately without parsing the rest of the options.  I'll propose a patch upstream.

For comment 1, the behavior is intentional and will not be changed (since it is provided by the getopt_long() function of glibc); -l always takes an argument, even if that argument looks like another option.  This is no different from any other program where options take an argument.
Comment 3 Eric Blake 2012-04-30 16:32:19 EDT
Upstream patch proposed
Comment 4 Eric Blake 2012-05-23 13:49:38 EDT
Will be fixed for 6.4 when the rebase picks this up:

commit 46e5d36b8998c53fbea9c589f618ae906103fec7
Author: Eric Blake <eblake@redhat.com>
Date:   Mon Apr 30 14:19:11 2012 -0600

    virsh: make -h always give help
    https://bugzilla.redhat.com/show_bug.cgi?id=817244 mentions that
    unlike most other tools, where --help or --version prevent all
    further parsing of all later options, virsh was strange in that
    --version stopped parsing but --help tried to plow on to the end.
    There was no rationale for this original implementation (since
    2005!), so I think we can safely conform to common usage patterns.
    * tools/virsh.c (main): Drop useless 'help' variable.
Comment 6 yanbing du 2012-07-24 06:45:31 EDT
Test with libvirt-0.9.13-3.el6.x86_64, bug verified.
When give -h option, all the other arguments will be ignored.
Comment 7 errata-xmlrpc 2013-02-21 02:12:35 EST
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.