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 1414393 - Device present in the domain XML after VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED was received
Summary: Device present in the domain XML after VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED was...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Jing Qi
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-01-18 12:08 UTC by Milan Zamazal
Modified: 2017-08-02 00:01 UTC (History)
7 users (show)

Fixed In Version: libvirt-3.1.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-01 17:21:45 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Python test script (2.41 KB, text/x-python)
2017-01-18 12:08 UTC, Milan Zamazal
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2017:1846 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2017-08-01 18:02:50 UTC

Description Milan Zamazal 2017-01-18 12:08:44 UTC
Created attachment 1242125 [details]
Python test script

Description of problem:

When a VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED event is received, the given device may still be present in the domain XML returned from libvirt for a short while afterwards. It eventually disappears, but its temporary presence may cause trouble. For instance, when a memory device is hotunplugged and the corresponding event is received, the domain XML may contain not only the supposedly already removed device but also obsolete information about the VM memory size.

Version-Release number of selected component (if applicable):

libvirt-2.0.0-10.el7_3.4.x86_64
qemu-kvm-rhev-2.6.0-28.el7_3.3.x86_64

How reproducible:

Most of the time on my machine.

Steps to Reproduce:

1. Run a VM with a guest OS supporting memory hotplug and hotunplug (such as RHEL/CentOS 7.3 x86_64).
2. Register a callback on device removal in libvirt API.
3. Hotplug a DIMM device into the VM.
4. Hotunplug the DIMM device from the VM.
5. Fetch the domain XML in the device removal callback. It may still contain the removed DIMM.

The attached test script demonstrates the problem. You can use it (at your own risk!) for steps 2.-5. above:

  sudo python2 device-removal-bug.py DOMAIN-NAME 

where DOMAIN-NAME is the name of the already running VM.

Actual results:

Sometimes output like this from the test script, the DIMM is present in the domain XML retrieved in the callback:

  Device removal reported
  ERROR: DIMM still present in the domain XML
  DIMM no longer present in the domain XML

Expected results:

Always output like this from the test script, the DIMM is never present in the domain XML retrieved in the callback:

  Device removal reported
  DIMM no longer present in the domain XML

Additional info:

Comment 2 Peter Krempa 2017-01-20 13:31:45 UTC
The event was emitted prior to accessing the monitor to delete the memory backends and thus it was possible to get the XML at the time when the memory element was still present.

Posted https://www.redhat.com/archives/libvir-list/2017-January/msg00914.html to address the issue.

Comment 3 Peter Krempa 2017-01-20 14:33:02 UTC
Fixed upstream:

commit 1d4fd2dd0fe0ebde9a9c61ebc4326b4181092d58
Author: Peter Krempa <pkrempa>
Date:   Fri Jan 20 14:24:35 2017 +0100

    qemu: hotplug: Properly emit "DEVICE_DELETED" event when unplugging memory
    
    The event needs to be emitted after the last monitor call, so that it's
    not possible to find the device in the XML accidentally while the vm
    object is unlocked.

Comment 5 Jing Qi 2017-05-12 06:35:54 UTC
Verified with libvirt-3.2.0-3.el7.x86_64 and qemu-kvm-rhev-2.9.0-3.el7.x86_64
Domain xml:
<maxMemory slots='16' unit='KiB'>25600000</maxMemory>
  <memory unit='KiB'>4048896</memory>
  <currentMemory unit='KiB'>4048896</currentMemory>

Mem.xml
<memory model='dimm'>
<target>
<size unit='m'>500</size>
<node>0</node>
</target>
</memory>

# virsh attach-device rhel7.4 mem.xml 
Device attached successfully

# virsh detach-device rhel7.4 mem.xml 
Device detached successfully

# python2 device-removal-bug.py rhel7.4
Device removal reported
DIMM no longer present in the domain

Comment 6 errata-xmlrpc 2017-08-01 17:21:45 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/RHEA-2017:1846

Comment 7 errata-xmlrpc 2017-08-02 00:01:15 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/RHEA-2017:1846


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