Qemu reply to libvirt "DeviceNotFound" and libvirt didn't clean on the
side the live configuration.
qemuMonitorDelDevice() return -2 to qemuDomainDeleteDevice() and during
this action in qemuDomainDetachDeviceLive() the remove is never call.
Ref #359
Signed-off-by: Pierre LIBEAU <pierre.libeau(a)corp.ovh.com>
---
src/qemu/qemu_hotplug.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 9b508dc8f0..52a14a4476 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -93,6 +93,8 @@ qemuDomainResetDeviceRemoval(virDomainObj *vm);
*
* Returns: 0 on success,
* -1 otherwise.
+ * -2 device does not exist in qemu, but it still
+ * exists in libvirt
*/
static int
qemuDomainDeleteDevice(virDomainObj *vm,
@@ -124,7 +126,6 @@ qemuDomainDeleteDevice(virDomainObj *vm,
* domain XML is queried right after detach API the
* device would still be there. */
VIR_DEBUG("Detaching of device %s failed and no event arrived",
alias);
- rc = 0;
}
}
@@ -6055,7 +6056,11 @@ qemuDomainDetachDeviceLive(virDomainObj *vm,
if (!async)
qemuDomainMarkDeviceForRemoval(vm, info);
- if (qemuDomainDeleteDevice(vm, info->alias) < 0) {
+ int rc;
+ rc = qemuDomainDeleteDevice(vm, info->alias);
+ if (rc < 0) {
+ if (rc == -2)
+ ret = qemuDomainRemoveDevice(driver, vm, &detach);
if (virDomainObjIsActive(vm))
qemuDomainRemoveAuditDevice(vm, &detach, false);
goto cleanup;
--
2.37.3