RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 949373 - Issues about virsh with incorrect argument
Summary: Issues about virsh with incorrect argument
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.0
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-04-08 02:38 UTC by tingting zheng
Modified: 2014-06-18 00:47 UTC (History)
6 users (show)

Fixed In Version: libvirt-1.0.5-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-06-13 12:35:19 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description tingting zheng 2013-04-08 02:38:03 UTC
Description
Issues about virsh with incorrect argument

Version:
libvirt-1.0.3-1.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Run virsh with incorrect argument.(Different output with rhel6.4,see Additional info)
# virsh --debu
error: option '-d' requires an argument

# virsh ---debug
error: unsupported option '-

# virsh --debugg
error: unsupported option '-

2.Run virsh with --,no handle for it.(Same with rhel6.4,not sure whether it is designed by this)
# virsh -- list --all
 Id    Name                           State
----------------------------------------------------

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

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

virsh #


Actual results:
As describes.

Expected results:
Improve the error info to be correct and clear.

Additional info:
On rhel6.4:
# virsh --debu
virsh: option '--debug' requires an argument
error: unsupported option '-?'. See --help.

# virsh ---debug
virsh: unrecognized option '---debug'
error: unsupported option '-?'. See --help.

# virsh --debugg
virsh: unrecognized option '--debugg'
error: unsupported option '-?'. See --help.

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

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

virsh #

Comment 2 Eric Blake 2013-04-08 17:25:30 UTC
(In reply to comment #0)
> Description
> Issues about virsh with incorrect argument
> 
> Version:
> libvirt-1.0.3-1.el7.x86_64
> 
> How reproducible:
> 100%
> 
> Steps to Reproduce:
> 1.Run virsh with incorrect argument.(Different output with rhel6.4,see
> Additional info)
> # virsh --debu
> error: option '-d' requires an argument

'--debu' is unambiguously short for '--debug', and since '--debug' and '-d' are synonyms, the output is technically correct.  But yes, it would be nice if the error message included the name of the option as the user typed it instead of canonicalizing it to the short option variant.

> 
> # virsh ---debug
> error: unsupported option '-

This is correct - there is no option that starts with three dashes.  But again, it would be nice if the error message included the entire option as the user typed it, instead of just the first character (the third dash) that caused the problem.  Furthermore, the output is unbalanced (missing a close '), so that should be fixed, even if we don't figure out how to replay what the user typed.

> 
> # virsh --debugg
> error: unsupported option '-

Again, there is no long option named --debugg, but again, displaying the full text of what the user typed would be better.

> 
> 2.Run virsh with --,no handle for it.(Same with rhel6.4,not sure whether it
> is designed by this)
> # virsh -- list --all

This is not a bug, but behavior required by POSIX.  The '--' marker must be silently ignored, and states that all remaining arguments are taken as arguments instead of options even if they start with '-'.  There is nothing to fix here.

> # virsh --
> Welcome to virsh, the virtualization interactive terminal.

Again, nothing to fix.

Comment 3 Ján Tomko 2013-04-30 08:39:55 UTC
The fix is now pushed upstream:
commit 53531e16bf7cfe4fe20a4fe132f8199dcd474245
Author:     Ján Tomko <jtomko>
AuthorDate: 2013-04-29 19:12:17 +0200
Commit:     Ján Tomko <jtomko>
CommitDate: 2013-04-30 10:23:44 +0200

    virsh: fix incorrect argument errors for long options
    
    For long options, print:
    * the option as specified by the user if it's unknown
    * the canonical long option if its argument is not
      a number (and should be)
    
    And for missing arguments, print both the short and
    the long option name.
    (Doing only one of those would require either parsing
    argv ourselves or let getopt print the errors, since
    we can't tell long and short options apart by optopt
    or longindex)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=949373
    
    Unsupported long option:
    
    $ virsh --pm
    Before:
    error: unsupported option '-
    After:
    error: unsupported option '--pm'. See --help.
    
    Missing parameter:
    
    $ virsh --deb
    Before:
    error: option '-d' requires an argument
    After:
    error: option '-d'/'--debug' requires an argument
    
    $ virsh -rd
    Before:
    error: option '-d' requires an argument
    After:
    error: option '-d'/'--debug' requires an argument
    
    Non-numeric parameter:
    
    $ virsh --deb duck
    Before:
    error: option -d takes a numeric argument
    After:
    error: option --debug takes a numeric argument

Comment 4 zzhong@redhat.com 2013-05-08 01:02:43 UTC
can reporduce with libvirt-1.0.3-1.el7.x86_64
verify with build:
libvirt-1.0.5-1.el7.x86_64

step:
1.Run virsh with incorrect argument.(Different output with rhel6.4,see Additional info)
#virsh --debu
error: option '-d'/'--debug' requires an argument

#virsh ---debug
error: unsupported option '---debug'. See --help.

#virsh --debugg
error: unsupported option '--debugg'. See --help.

2.Run virsh with --,no handle for it.
#virsh -- list --all
Id Name State
----------------------------------------------------
24 test running
29 bb running
- test1 shut off
- win-mig shut off
- win7 shut off

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

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

virsh#

#virsh --pm
error: unsupported option '--pm'. See --help.

#virsh --deb
error: option '-d'/'--debug' requires an argument

#virsh -rd
error: option '-d'/'--debug' requires an argument

#virsh --deb duck
error: option --debug takes a numeric argument

with wrong argument,it will have the error info to be correct and clear.verification passed

Comment 5 Ludek Smid 2014-06-13 12:35:19 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.


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