[PATCH] qemu: hotplug: fail when net device detach times out

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



qemuDomainDetachNetDevice should not treat a timeout in a call to
qemuDomainWaitForDeviceRemoval as success. Instead, it should treat it
as failure -- this is the intention behind having a timeout.

If qemuDomainWaitForDeviceRemoval times out, it returns 0. In this
instance, if qemuDomainDetachNetDevice returns 0, virsh detach-interface
reports:

  Interface detached successfully

with a zero exit status.

But with a negative return value from qemuDomainDetachNetDevice, virsh
detach-interface reports:

  error: Failed to detach interface
  error: An error occurred, but the cause is unknown

with a non-zero exit status, which is more appropriate.

Signed-off-by: Jonathan Davies <jonathan.davies@xxxxxxxxxxx>
---
 src/qemu/qemu_hotplug.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 4be0f546c..d9a2f2d4d 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -5082,8 +5082,13 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         goto cleanup;
 
-    if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
+    ret = qemuDomainWaitForDeviceRemoval(vm);
+    if (ret == 1) {
         ret = qemuDomainRemoveNetDevice(driver, vm, detach);
+    } else if (ret == 0) {
+        VIR_WARN("Detach of device %s timed out; treating as a failure", detach->ifname);
+        ret = -1;
+    }
 
  cleanup:
     qemuDomainResetDeviceRemoval(vm);
-- 
2.14.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux