]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: hotplug: Properly handle errors in qemuDomainWaitForDeviceRemoval
authorPeter Krempa <pkrempa@redhat.com>
Mon, 4 Apr 2016 13:27:25 +0000 (15:27 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 13 Apr 2016 11:26:29 +0000 (13:26 +0200)
Callers ignore if this function returns -1 and continue as though the
DEVICE_DELETED event was not received. Since we can't be sure that the
event was not received we should behave as if the event was not
supported and remove the device definition right away. The error
fortunately won't really happen here.

src/qemu/qemu_hotplug.c

index f332b3417db439f9c2e50128e7fec9322cde1bda..950bc03b10609818df0a957bdf0c9806f3d06dd9 100644 (file)
@@ -3348,8 +3348,8 @@ qemuDomainResetDeviceRemoval(virDomainObjPtr vm)
 }
 
 /* Returns:
- *  -1 on error
- *   0 when DEVICE_DELETED event is unsupported
+ *   0 when DEVICE_DELETED event is unsupported, or we failed to reliably wait
+ *   for the event
  *   1 when DEVICE_DELETED arrived before the timeout and the caller is
  *     responsible for finishing the removal
  *   2 device removal did not finish in qemuDomainRemoveDeviceWaitTime
@@ -3364,7 +3364,7 @@ qemuDomainWaitForDeviceRemoval(virDomainObjPtr vm)
         return 0;
 
     if (virTimeMillisNow(&until) < 0)
-        return -1;
+        return 0;
     until += qemuDomainRemoveDeviceWaitTime;
 
     while (priv->unpluggingDevice) {
@@ -3373,9 +3373,9 @@ qemuDomainWaitForDeviceRemoval(virDomainObjPtr vm)
             if (errno == ETIMEDOUT) {
                 return 2;
             } else {
-                virReportSystemError(errno, "%s",
-                                     _("Unable to wait on unplug condition"));
-                return -1;
+                VIR_WARN("Failed to wait on unplug condition for domain '%s' "
+                         "device '%s'", vm->def->name, priv->unpluggingDevice);
+                return 0;
             }
         }
     }