]> git.ipfire.org Git - thirdparty/qemu.git/blobdiff - hw/virtio/virtio-pci.c
hw/virtio: handle un-configured shutdown in virtio-pci
[thirdparty/qemu.git] / hw / virtio / virtio-pci.c
index 45327f0b319eca323128b56983d228e086b95fac..5ce61f9b4502388677cda17fe51c7ec2a8f579aa 100644 (file)
@@ -996,9 +996,14 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign)
 
     nvqs = MIN(nvqs, VIRTIO_QUEUE_MAX);
 
-    /* When deassigning, pass a consistent nvqs value
-     * to avoid leaking notifiers.
+    /*
+     * When deassigning, pass a consistent nvqs value to avoid leaking
+     * notifiers. But first check we've actually been configured, exit
+     * early if we haven't.
      */
+    if (!assign && !proxy->nvqs_with_notifiers) {
+        return 0;
+    }
     assert(assign || nvqs == proxy->nvqs_with_notifiers);
 
     proxy->nvqs_with_notifiers = nvqs;