Bug 1633077

Summary: domxml-to-native should treat --xml as the default option
Product: Red Hat Enterprise Linux 7 Reporter: Lili Zhu <lizhu>
Component: libvirtAssignee: Jiri Denemark <jdenemar>
Status: CLOSED ERRATA QA Contact: Lili Zhu <lizhu>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.6CC: dyuan, fjin, jdenemar, jomurphy, lcheng, xuzhang, yanqzhan
Target Milestone: rcKeywords: Automation, Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-4.5.0-12.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1634769 (view as bug list) Environment:
Last Closed: 2019-08-06 13:14:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1634769, 1651787    

Description Lili Zhu 2018-09-26 07:08:48 UTC
Description of problem:
improve the doc about domxml-to-native

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

How reproducible:
100%

Steps to Reproduce:
1. check the manual of domxml-to-native
# man virsh
 domxml-to-native format { [--xml] xml | --domain domain-name-or-id-or-uuid }

2. check the help info 
# virsh domxml-to-native --help
  NAME
    domxml-to-native - Convert domain XML to native config

3. convert the file xml into domain XML format
# virsh domxml-to-native qemu-argv avocado-vt-vm1.xml
error: failed to get domain 'avocado-vt-vm1.xml'
error: Domain not found: no domain with matching name 'avocado-vt-vm1.xml'


Actual results:
Now without flag "--xml", virsh will parse the argument as domain-name-or-id-or-uuid by default.

Expected results:
If it is designed like this, please improve the doc. Since it is just opposite to the case in RHEL7.5, refer to the Additional info.


Additional info:
In rhel7.5, it can work well without flag "--xml"
# virsh domxml-to-native qemu-argv /root/avocado-vt-vm1.xml
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin QEMU_AUD....

# virsh domxml-to-native qemu-argv avocado-vt-vm1
error: Failed to open file 'avocado-vt-vm1': No such file or directory

Comment 3 Jiri Denemark 2018-09-26 07:44:58 UTC
Broken by the completer code:

commit d86531daf2747acba21556ab0aa6a3d6861b600e
Refs: v4.3.0-127-gd86531daf2
Author:     Lin Ma <lma>
AuthorDate: Tue May 8 22:20:33 2018 +0800
Commit:     Michal Privoznik <mprivozn>
CommitDate: Thu May 10 09:21:13 2018 +0200

	virsh: Apply macro for current VSH_OT_STRING "domain" options

    These VSH_OT_STRING "domain" options support domain name completion now.

    Signed-off-by: Lin Ma <lma>

Comment 5 Jiri Denemark 2018-09-26 08:03:51 UTC
Patch sent upstream for review: https://www.redhat.com/archives/libvir-list/2018-September/msg01334.html

Comment 6 Jiri Denemark 2018-09-26 16:14:49 UTC
Fixed upstream by

commit b7ccd0757de73344a4b973ede946dad40de846c7
Refs: v4.8.0-rc1-3-gb7ccd0757d
Author:     Jiri Denemark <jdenemar>
AuthorDate: Wed Sep 26 09:59:08 2018 +0200
Commit:     Jiri Denemark <jdenemar>
CommitDate: Wed Sep 26 17:22:38 2018 +0200

    virsh: Require explicit --domain for domxml-to-native

    The domxml-to-native virsh command accepts either --xml or --domain
    option followed by a file or domain name respectively. The --domain
    option is documented as required, which means an argument with no option
    is treated as --xml. Commit v4.3.0-127-gd86531daf2 broke this by making
    --domain optional and thus an argument with no option was treated as
    --domain.

    https://bugzilla.redhat.com/show_bug.cgi?id=1633077

    Signed-off-by: Jiri Denemark <jdenemar>

Comment 11 Lili Zhu 2019-04-09 03:42:44 UTC
Verify this bug with:
libvirt-4.5.0-12.el7.x86_64

verification steps:
1. convert the file xml into domain XML format
# virsh domxml-to-native qemu-argv avocado-vt-vm1.xml
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin QEMU_AUDIO_DRV=spice /usr/libexec/qemu-kvm -name guest=avocado-vt-vm1,debug-threads=on ....

2. convert the file xml into domain XML format with --xml flag
# virsh domxml-to-native qemu-argv --xml avocado-vt-vm1.xml
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin QEMU_AUDIO_DRV=spice /usr/libexec/qemu-kvm -name guest=avocado-vt-vm1,debug-threads=on...

3. covert the domain to native config without the --domian flag
# virsh domxml-to-native qemu-argv avocado-vt-vm1
error: Failed to open file 'avocado-vt-vm1': No such file or directory

4. covert the domain to native config with the --domain flag
# virsh domxml-to-native qemu-argv --domain avocado-vt-vm1 
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin QEMU_AUDIO_DRV=spice /usr/libexec/qemu-kvm -name guest=avocado-vt-vm1,...

As the results match with the expected results, mark the bug as verified.

Comment 13 errata-xmlrpc 2019-08-06 13:14:02 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.

https://access.redhat.com/errata/RHSA-2019:2294