Bug 1618622 - Detaching ('virsh detach-device-alias') shmem returns failure while actually succeeds in dumpxml of VM
Summary: Detaching ('virsh detach-device-alias') shmem returns failure while actually ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.6
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Luyao Huang
URL:
Whiteboard:
Depends On:
Blocks: 1618680
TreeView+ depends on / blocked
 
Reported: 2018-08-17 05:57 UTC by jiyan
Modified: 2018-10-30 09:59 UTC (History)
11 users (show)

Fixed In Version: libvirt-4.5.0-7.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1618680 (view as bug list)
Environment:
Last Closed: 2018-10-30 09:58:28 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2018:3113 None None None 2018-10-30 09:59:31 UTC

Description jiyan 2018-08-17 05:57:23 UTC
Description of problem:
Detaching ('virsh detach-device-alias') shmem returns failure while actually succeeds in dumpxml of  VM

Version-Release number of selected component (if applicable):
qemu-kvm-rhev-2.12.0-10.el7.x86_64
kernel-3.10.0-933.el7.x86_64
libvirt-4.5.0-6.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Prepare a shutdown VM without shmem conf and shmem.xml file
# virsh domstate test7.6
shut off

# virsh dumpxml test7.6 --inactive |grep shmem
No output

# cat shmem.xml 
    <shmem name='my_shmem0'>
      <model type='ivshmem-plain'/>
      <size unit='M'>4</size>
      <alias name='ua-8a97238f-0eb4-4e94-87bf-3e878b138749'/>
    </shmem>

2. Start VM and hot-plug shmem.xml to VM
# virsh start test7.6
Domain test7.6 started

# virsh attach-device test7.6 shmem.xml 
Device attached successfully

# virsh dumpxml test7.6 |grep shmem -A6
    <shmem name='my_shmem0'>
      <model type='ivshmem-plain'/>
      <size unit='M'>4</size>
      <alias name='ua-8a97238f-0eb4-4e94-87bf-3e878b138749'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </shmem>

3. Detach shmem from VM
# virsh detach-device-alias test7.6 ua-8a97238f-0eb4-4e94-87bf-3e878b138749
error: Failed to detach device with alias ua-8a97238f-0eb4-4e94-87bf-3e878b138749
error: internal error: unable to execute QEMU command 'object-del': object 'shmmem-ua-8a97238f-0eb4-4e94-87bf-3e878b138749' is in use, can not be deleted

# virsh dumpxml test7.6 |grep shmem -A6
No output

Actual result:
As step-3 shows

Expected result:
Once the virsh cmd returns failure, shmem xml conf should not disappear in dumpxml of VM

Additional info:
>>>>>>>> In Step-3, the qmp info is as following:
 96.073 > 0x7f721c018720 {"execute":"device_del","arguments":{"id":"ua-8a97238f-0eb4-4e94-87bf-3e878b138749"},"id":"libvirt-24"}
 96.076 < 0x7f721c018720 {"return": {}, "id": "libvirt-24"}
 96.076 > 0x7f721c018720 {"execute":"object-del","arguments":{"id":"shmmem-ua-8a97238f-0eb4-4e94-87bf-3e878b138749"},"id":"libvirt-25"}
 96.079 < 0x7f721c018720 {"id": "libvirt-25", "error": {"class": "GenericError", "desc": "object 'shmmem-ua-8a97238f-0eb4-4e94-87bf-3e878b138749' is in use, can not be deleted"}} (libvirt receives the event from qemu.)
 96.092 ! 0x7f721c018720 {"timestamp": {"seconds": 1534483936, "microseconds": 767944}, "event": "DEVICE_DELETED", "data": {"device": "ua-8a97238f-0eb4-4e94-87bf-3e878b138749", "path": "/machine/peripheral/ua-8a97238f-0eb4-4e94-87bf-3e878b138749"}}
 96.093 > 0x7f721c018720 {"execute":"object-del","arguments":{"id":"shmmem-ua-8a97238f-0eb4-4e94-87bf-3e878b138749"},"id":"libvirt-26"}
 96.096 < 0x7f721c018720 {"return": {}, "id": "libvirt-26"}

>>>>>>>> In Step-3, detaching the shmem device by 'virsh detach-device' can succeed
# virsh detach-device test7.6 shmem.xml 
Device detached successfully

# virsh dumpxml test7.6 |grep "<shmem" -A6
No output

Comment 3 Peter Krempa 2018-08-17 10:02:50 UTC
Fixed upstream:

commit 69c20e1090059d8b359fdd435e8ba50db7269be1
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Fri Aug 17 09:11:34 2018 +0200

    qemu: hotplug: Fix asynchronous unplug of 'shmem'
    
    commit 5c81c342a7 forgot to skip the detaching of the shmem backend
    when async unplug is requested which meant that we've tried to unplug
    the backend prior to delivery of the DEVICE_DELETED event.

Comment 6 Luyao Huang 2018-08-29 09:23:03 UTC
Verify this bug with libvirt-4.5.0-7.el7.x86_64:

1. prepare a running vm:

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 31    vm1                            running

2. attach shmem device:

# virsh attach-device vm1 shmem.xml
Device attached successfully

3. detach it use detach-device-alias:

# virsh detach-device-alias vm1 ua-123
Device detach request sent successfully

4. recheck xml and cannot find device

# virsh dumpxml vm1 |grep ua-123

Comment 8 errata-xmlrpc 2018-10-30 09:58:28 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-2018:3113


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