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 1018369 - virsh documentation error: option --domain already seen
Summary: virsh documentation error: option --domain already seen
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.0
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: rc
: ---
Assignee: Eric Blake
QA Contact: lijuan men
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-10-11 19:12 UTC by Chris Evich
Modified: 2016-12-21 20:41 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-12-21 20:41:30 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Chris Evich 2013-10-11 19:12:11 UTC
Description of problem:
virsh parameter parsing enforces positional ordering even when argument options passed

Version-Release number of selected component (if applicable):
libvirt-1.1.1-5.el7.x86_64

How reproducible:
Very

Steps to Reproduce:
1. Shutdown vm
2. virsh attach-device /path/to.xml --domain virt-tests-vm1 --config

Actual results:
exit 1 stdout: '' stderr: 'error: option --domain already seen'

Expected results:
exit 0 stdout: 'Device attached successfully' stderr: ''

Additional info:
It works fine if --domain opt comes before /path/to.xml, so this possibly could be fixed with fairly simple man and --help doc. update - In case code-change is non-trivial.

Comment 1 Eric Blake 2013-10-11 19:25:12 UTC
Not (necessarily) a bug.  The parser is currently coded to non-lookahead parsing, so:

attach-device /path/to.xml ...

is parsed as:

attach-device --domain /path/to.xml ...

regardless of the contents of '...'.

It _might_ be possible to change that to do a full-scan parse, where all explicit options are removed from the set of options that must then be mapped to remaining positional arguments.  But doing that might break existing clients that are used to the current parse rules.  And it is also more complex:

attach-device --file --domain --config foo

should parse the same as:

attach-device --domain=foo --file=--domain --config

but that means you can't just look for arguments with leading '--', you also have to know the context of whether the previous argument was an option that requires data vs. a boolean option.

Finally, you can ALWAYS be more explicit and provide:

attach-device --file=/path/to.xml --domain=virt-tests-vm1 --config

if you want to avoid positional parsing, so it's not like the current parsing rules are actively preventing you from constructing a valid command line.  As such, I'm inclined to close this as not a bug, unless I hear further good arguments why we should make a change.

Comment 2 Eric Blake 2013-10-11 19:28:56 UTC
(In reply to Chris Evich from comment #0)
> Additional info:
> It works fine if --domain opt comes before /path/to.xml, so this possibly
> could be fixed with fairly simple man and --help doc. update

If we go the improved doc route, what wording would you suggest?  (I'm a bit biased since I wrote the bulk of the current parse code, and am worried that code changes could risk unintended back-compat breakage in spite of our existing testsuite on option parsing).

Comment 4 Chris Evich 2013-10-11 20:44:10 UTC
Yeah, not surprised that messing with the parser would be difficult.  I also suspect there are many other commands with a similarly challenged help:

  SYNOPSIS
    attach-device <domain> <file> [--persistent] [--config] [--live] [--current]

No info is provided about --domain/--file.  However, I think maybe just a simple tweak could fix this,  How about:

  SYNOPSIS
    attach-device [--domain] <domain> [--file] <file> [--persistent] [--config] 
                  [--live] [--current]

Same thing for the man page:

attach-device [--domain] domain [--file] FILE [[[--live] [--config] | 
              [--current]] | [--persistent]]

Another idea is to just add a blanket statement to the man page Description.  It already covers a lot of the usage anyway.  How about something like:

"Any [OPTION] with equivalent [ARG] will be interpreted in the same order as [ARG].  For example, <domain> <file> could be --domain <domain> --file <file>, but not in any other order".

Comment 9 Eric Blake 2015-07-28 15:24:56 UTC
As a doc fix, this should be fairly simple to get something in place to help the situation.

Comment 11 Ademar Reis 2016-12-21 20:41:30 UTC
Discussed this with Eric and decided it's not worth fixing. The behavior and documentation have been like this forever and (other) users are not complaining.


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