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 1857504 - [virt-install] The code logic is wrong when editing a shutoff vm's XML via virt-xml tool
Summary: [virt-install] The code logic is wrong when editing a shutoff vm's XML via vi...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: virt-manager
Version: 8.3
Hardware: x86_64
OS: Unspecified
low
low
Target Milestone: rc
: 8.0
Assignee: Pavel Hrdina
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-07-16 03:12 UTC by zhoujunqin
Modified: 2021-05-18 15:47 UTC (History)
6 users (show)

Fixed In Version: virt-manager-2.2.1-4.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-05-18 15:47:03 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description zhoujunqin 2020-07-16 03:12:34 UTC
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:

Comment 1 Jaroslav Suchanek 2020-07-16 08:51:08 UTC
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

Comment 12 zhoujunqin 2020-11-24 10:42:40 UTC
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.

Comment 14 errata-xmlrpc 2021-05-18 15:47:03 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 (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


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