Bug 1857504
| Summary: | [virt-install] The code logic is wrong when editing a shutoff vm's XML via virt-xml tool | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 8 | Reporter: | zhoujunqin <juzhou> |
| Component: | virt-manager | Assignee: | Pavel Hrdina <phrdina> |
| Status: | CLOSED ERRATA | QA Contact: | Virtualization Bugs <virt-bugs> |
| Severity: | low | Docs Contact: | |
| Priority: | low | ||
| Version: | 8.3 | CC: | jsuchane, kanderso, tyan, tzheng, virt-maint, xiaodwan |
| Target Milestone: | rc | Flags: | pm-rhel:
mirror+
|
| Target Release: | 8.0 | ||
| Hardware: | x86_64 | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | virt-manager-2.2.1-4.el8 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2021-05-18 15:47:03 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: | |||
Fixed upstream by:
commit 29f9f5f2d7f47fe6cc3333f2a9e6c6209db5a8f3
Author: Pavel Hrdina <phrdina>
AuthorDate: Tue Dec 3 13:02:21 2019 +0100
Commit: Pavel Hrdina <phrdina>
CommitDate: Tue Dec 3 13:04:37 2019 +0100
virt-xml: fix defined_xml_is_unchanged
Commit <53f075ab76e1c372474ae0d88f202e487d9f213f> added a warning if the
VM XML is not changed after removing default devices but the code was
incorrect. We have to compare strings instead of string vs Guest object
and also the condition was inverted.
Signed-off-by: Pavel Hrdina <phrdina>
v2.2.1-127-g29f9f5f2
I can reproduce this issue with package: virt-install-2.2.1-3.el8.noarch virt-manager-common-2.2.1-3.el8.noarch Steps as Comment 0. Then try to verify this bug with new build: virt-manager-common-2.2.1-4.el8.noarch virt-install-2.2.1-4.el8.noarch libvirt-6.0.0-30.module+el8.4.0+8705+34397d87.x86_64 qemu-kvm-4.2.0-37.module+el8.4.0+8837+c89bcfe6.x86_64 kernel-4.18.0-249.el8.x86_64 Steps: Test scenario 1: Test with a shutoff vm 1.1 Prepare a shutoff vm. # virsh domstate rhel8.3 shut off # virsh dumpxml rhel8.3 |grep -A5 disk ... <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/home/8.3-re'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/> </disk> ... 1.2 Remove disk 'vda' from xml # virt-xml rhel8.3 --remove-device --disk target.dev=vda Domain 'rhel8.3' defined successfully. 1.3 Check vm's XML again. # virsh dumpxml rhel8.3 |grep -A5 disk Result: No disk(vda) shows, so the vm's XML file changes as expected when the vm is in shutoff status. Test scenario 2: Test with a running vm 2.1 Prepare a running vm. # virsh domstate rhel8.3 running # virsh dumpxml rhel8.3 |grep -A5 disk ... <disk type='file' device='disk'> <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/home/8.3-re' index='1'/> <backingStore/> <target dev='vda' bus='virtio'/> <alias name='virtio-disk0'/> <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/> </disk> ... 2.2 Remove disk 'vda' from xml # virt-xml rhel8.3 --remove-device --disk target.dev=vda Domain 'rhel8.3' defined successfully. Changes will take effect after the domain is fully powered off. 2.3 Check vm's XML again. # virsh dumpxml rhel8.3 |grep -A5 disk ... <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/home/8.3-re' index='1'/> <backingStore/> <target dev='vda' bus='virtio'/> <alias name='virtio-disk0'/> <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/> </disk> ... Result: Disk(vda) shows. 2.4 Power off vm and check vm's XML again. # virsh destroy rhel8.3 Domain rhel8.3 destroyed # virsh dumpxml rhel8.3 |grep -A5 disk Result: No disk(vda) shows, so the vm's XML file changed as expected. I move this bug from ON_QA to VERIFIED status based on above testing, thanks. 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 (virt-manager 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/RHBA-2021:1843 |
Description of problem: The code logic is wrong when editing a shutoff vm's XML via virt-xml tool # vim virt-xml +109 def defined_xml_is_unchanged(conn, domain, original_xml): rawxml = get_xmldesc(domain, inactive=True) new_xml = virtinst.Guest(conn, parsexml=rawxml) return new_xml != original_xml <--- It should be '=='. Version-Release number of selected component (if applicable): virt-install-2.2.1-3.el8.noarch libvirt-6.0.0-25.module+el8.3.0+7176+57f10f42.x86_64 How reproducible: 100% Steps to Reproduce: 1. Prepare a shutoff vm. # virsh domstate rhel7.9-virt-viewer shut off # virsh dumpxml rhel7.9-virt-viewer |grep -A5 disk <suspend-to-disk enabled='no'/> </pm> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/home/rhel7.img'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/> </disk> ... 2. Remove disk 'vda' from xml # virt-xml rhel7.9-virt-viewer --remove-device --disk target=vda Domain 'rhel7.9-virt-viewer' defined successfully. WARNING XML did not change after domain define. You may have changed a value that libvirt is setting by default. 3. Check vm's XML again. # virsh dumpxml rhel7.9-virt-viewer |grep -A5 disk <suspend-to-disk enabled='no'/> </pm> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <controller type='usb' index='0' model='qemu-xhci' ports='15'> <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/> Result: No disk(vda) shows, so the vm's XML file has changed. Actual results: As described. Expected results: Fix it the logic issue, then get the expected result like follows: # virt-xml vm1 --remove-device --disk target=vda Domain 'vm1' defined successfully. Additional info: