summaryrefslogtreecommitdiffstats
path: root/hw/misc/vfio.c
diff options
context:
space:
mode:
authorAlex Williamson2013-12-06 19:16:40 +0100
committerAlex Williamson2013-12-06 19:16:40 +0100
commit3e40ba0faf0822fa78336fe6cd9d677ea9b14f1b (patch)
tree94f7b6e38cdc19275a986337d42814e996a34f89 /hw/misc/vfio.c
parentvfio-pci: Add debug config options to disable MSI/X KVM support (diff)
downloadqemu-3e40ba0faf0822fa78336fe6cd9d677ea9b14f1b.tar.gz
qemu-3e40ba0faf0822fa78336fe6cd9d677ea9b14f1b.tar.xz
qemu-3e40ba0faf0822fa78336fe6cd9d677ea9b14f1b.zip
vfio-pci: Release all MSI-X vectors when disabled
We were relying on msix_unset_vector_notifiers() to release all the vectors when we disable MSI-X, but this only happens when MSI-X is still enabled on the device. Perform further cleanup by releasing any remaining vectors listed as in-use after this call. This caused a leak of IRQ routes on hotplug depending on how the guest OS prepared the device for removal. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Cc: qemu-stable@nongnu.org
Diffstat (limited to 'hw/misc/vfio.c')
-rw-r--r--hw/misc/vfio.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
index f367537737..9aecaa82bc 100644
--- a/hw/misc/vfio.c
+++ b/hw/misc/vfio.c
@@ -905,8 +905,20 @@ static void vfio_disable_msi_common(VFIODevice *vdev)
static void vfio_disable_msix(VFIODevice *vdev)
{
+ int i;
+
msix_unset_vector_notifiers(&vdev->pdev);
+ /*
+ * MSI-X will only release vectors if MSI-X is still enabled on the
+ * device, check through the rest and release it ourselves if necessary.
+ */
+ for (i = 0; i < vdev->nr_vectors; i++) {
+ if (vdev->msi_vectors[i].use) {
+ vfio_msix_vector_release(&vdev->pdev, i);
+ }
+ }
+
if (vdev->nr_vectors) {
vfio_disable_irqindex(vdev, VFIO_PCI_MSIX_IRQ_INDEX);
}