https://bugzilla.redhat.com/show_bug.cgi?id=1623389
Steps to reproduce:
1) cat shmem.xml
<shmem name='my_shmem0'>
<model type='ivshmem-plain'/>
<size unit='M'>4</size>
<alias name='ua-123'/>
</shmem>
2) virsh attach-device vm1 shmem.xml
3) virsh detach-device-alias vm1 ua-123; virsh detach-device vm1 shmem.xml
4) observe that the device is still in the domain:
virsh dumpxml vm1
<shmem name='my_shmem0'>
<model type='ivshmem-plain'/>
<size unit='M'>4</size>
<alias name='ua-123'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x0a' function='0x0'/>
</shmem>
5) But qemu has the device no more:
virsh detach-device-alias vm1 ua-123
error: Failed to detach device with alias ua-123
error: internal error: unable to execute QEMU command 'device_del': Device
'ua-123' not found
This reproducer is to make sure that DELETE_DEVICE event arrives
while monitor is unlocked. It is very hard to time qemu and
libvirt so that the event comes exactly at the time when
detach-device from 3) is doing the monitor call. Simulate this by
unlocking monitor, waiting a few seconds and locking the monitor
again.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_hotplug.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index baa4713cf4..59a5d21a5b 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -96,6 +96,11 @@ qemuDomainDeleteDevice(virDomainObjPtr vm,
qemuDomainObjEnterMonitor(driver, vm);
rc = qemuMonitorDelDevice(priv->mon, alias);
+ if (rc < 0) {
+ virObjectUnlock(priv->mon);
+ sleep(10);
+ virObjectLock(priv->mon);
+ }
if (enterMonitor &&
qemuDomainObjExitMonitor(driver, vm) < 0)
--
2.19.2