Bug 817244 - Issues about virsh -h usage
Summary: Issues about virsh -h usage
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.3
Hardware: x86_64
OS: Linux
Target Milestone: rc
: ---
Assignee: Eric Blake
QA Contact: Virtualization Bugs
Depends On:
TreeView+ depends on / blocked
Reported: 2012-04-28 09:15 UTC by Min Zhan
Modified: 2013-02-21 07:12 UTC (History)
8 users (show)

Fixed In Version: libvirt-0.9.13-3.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2013-02-21 07:12:35 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2013:0276 0 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2013-02-20 21:18:26 UTC

Description Min Zhan 2012-04-28 09:15:03 UTC
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 09:21:21 UTC
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 16:56:11 UTC
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 20:32:19 UTC
Upstream patch proposed

Comment 4 Eric Blake 2012-05-23 17:49:38 UTC
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 10:45:31 UTC
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 07:12:35 UTC
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.