diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index ce958848b61d0d871a08ce28dc9bc5009870d1a2..7322c8be638da7177e53b6e027e6a253c49e2b01 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -828,9 +828,11 @@ static void vfio_msix_disable(VFIOPCIDevice *vdev) } } - if (vdev->nr_vectors) { - vfio_disable_irqindex(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_INDEX); - } + /* + * Always clear MSI-X IRQ index. A PF device could have enabled + * MSI-X with no vectors. See vfio_msix_enable(). + */ + vfio_disable_irqindex(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_INDEX); vfio_msi_disable_common(vdev); vfio_intx_enable(vdev, &err);