Bug 2103524
| Summary: | Run virsh dumpxml cmd with extra options should return error | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 9 | Reporter: | yalzhang <yalzhang> |
| Component: | libvirt | Assignee: | Michal Privoznik <mprivozn> |
| libvirt sub component: | General | QA Contact: | yalzhang <yalzhang> |
| Status: | CLOSED ERRATA | Docs Contact: | |
| Severity: | unspecified | ||
| Priority: | unspecified | CC: | dzheng, jdenemar, lmen, mprivozn, pkrempa, virt-maint |
| Version: | 9.1 | Keywords: | Automation, Regression, Triaged, Upstream |
| Target Milestone: | rc | Flags: | pm-rhel:
mirror+
|
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | libvirt-8.5.0-3.el9 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2022-11-15 10:04:39 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: | |||
|
Description
yalzhang@redhat.com
2022-07-04 00:55:21 UTC
I don't think this is a regression, it's a feature. With 8.5.0 virsh gained new feature: dumpxml [--domain] $dom [--xpath] XPATH See https://gitlab.com/libvirt/libvirt/-/commit/8603b3d76ce54283812a9553da1b6f0e553a71f3 It's a convenient way to get only a subset of nodes instead of full domain XML. IMO the '--xpath' argument should have been declared with 'VSH_OFLAG_REQ_OPT' flag set making the '--xpath' prefix mandatory for the option which would also prevent eating any followign argument as the XPATH query. While we've already released a libvirt version with the above code included I think we don't have enough users of it so we could change it to make the option name mandatory. Fair enough, I've posted the fix here: https://listman.redhat.com/archives/libvir-list/2022-July/232733.html Merged upstream as:
commit e90d48ae6e22eaf1650f920abc0a6b87d2daa82b
Author: Michal Prívozník <mprivozn>
AuthorDate: Fri Jul 8 12:45:42 2022 +0200
Commit: Michal Prívozník <mprivozn>
CommitDate: Mon Jul 25 09:50:21 2022 +0200
virsh: Require --xpath for *dumpxml
Historically, the dumpxml command reject any unknown arguments,
for instance:
virsh dumpxml fedora xxx
However, after v8.5.0-rc1~31 the second argument ('xxx') is
treated as an XPath, but it's not that clearly visible.
Therefore, require the --xpath switch, like this:
virsh dumpxml fedora --xpath xxx
Yes, this breaks already released virsh, but I think we can argue
that the pool of users of this particular function is very small.
We also document the argument being mandatory:
dumpxml [--inactive] [--security-info] [--update-cpu] [--migratable]
[--xpath EXPRESSION] [--wrap] domain
The sooner we do this change, the better.
The same applies for other *dumpxml functions (net-dumpxml,
pool-dumpxml, vol-dumpxl to name a few).
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2103524
Signed-off-by: Michal Privoznik <mprivozn>
Reviewed-by: Peter Krempa <pkrempa>
v8.5.0-175-ge90d48ae6e
Test on libvirt-8.5.0-3.el9.x86_64, the result is as expected
# virsh net-dumpxml default xyz
error: unexpected data 'xyz'
# virsh net-dumpxml default --xpath xyz
#
# virsh net-dumpxml default --xpath //ip
<ip address="192.168.122.1" netmask="255.255.255.0">
<dhcp>
<range start="192.168.122.2" end="192.168.122.254"/>
</dhcp>
</ip>
Test on libvirt-8.5.0-4.el9.x86_64, the result is as expected: # virsh dumpxml rhel --xpath sdf # virsh dumpxml rhel --xpath //os <os firmware="efi"> <type arch="x86_64" machine="pc-q35-rhel9.0.0">hvm</type> <boot dev="hd"/> </os> # virsh dumpxml rhel xyz error: unexpected data 'xyz' 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 (Low: libvirt security, bug fix, and enhancement update), 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-2022:8003 |