diff mbox

qemu-kvm: fix crash on reboot with vhost-net

Message ID 20100426133743.GA16573@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael S. Tsirkin April 26, 2010, 1:37 p.m. UTC
None
diff mbox

Patch

diff --git a/hw/msix.c b/hw/msix.c
index 3ec8805..43361b5 100644
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -613,9 +613,18 @@  int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque)
     if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector])
         return 0;
 
-    if (dev->msix_mask_notifier)
-        r = dev->msix_mask_notifier(dev, vector, opaque,
-                                    msix_is_masked(dev, vector));
+    if (dev->msix_mask_notifier && !msix_is_masked(dev, vector)) {
+        /* Switching notifiers while vector is unmasked:
+         * mask the old one, unmask the new one. */
+        if (dev->msix_mask_notifier_opaque[vector]) {
+            r = dev->msix_mask_notifier(dev, vector,
+                                        dev->msix_mask_notifier_opaque[vector],
+                                        1);
+        }
+        if (r >= 0 && opaque) {
+            r = dev->msix_mask_notifier(dev, vector, opaque, 0);
+        }
+    }
     if (r >= 0)
         dev->msix_mask_notifier_opaque[vector] = opaque;
     return r;