@samitouri / QOSamiQemu / commits / 338d81b22b

vfio/pci: Guard accel_irqchip_begin_route_changes() calls

Since commit 49b2dcbd2422 ("accel/accel-irq: add generic begin_route_changes"), accel_irqchip_begin_route_changes() aborts when no accelerator irqchip is available. This causes a fatal error when running VFIO passthrough devices under TCG emulation: qemu-system-aarch64: can't initiate route change, no accel irqchip available The previous kvm_irqchip_begin_route_changes() was a simple inline that did not have a fatal path. The VFIO code already handles the absence of KVM MSI routing gracefully by falling back to userspace handling, but the new generic function aborts before that fallback can take effect. Guard the call sites in hw/vfio/pci.c with accel_msi_via_irqfd_enabled() so that route changes are only initiated when an accelerator irqchip is actually present. Fixes: 49b2dcbd2422 ("accel/accel-irq: add generic begin_route_changes") Cc: Magnus Kulke <magnuskulke@linux.microsoft.com> Link: https://lore.kernel.org/qemu-devel/20260721105026.3932297-1-clg@redhat.com Signed-off-by: Cédric Le Goater <clg@redhat.com>

Cédric Le Goater committed Jul 21, 2026 at 12:50 UTC 338d81b22b4dc6c45299da1114925a4b086d6e00
1 file changed +4 -2
hw/vfio/pci.c
+4 -2
@@ -699,7 +699,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr,
699 if (msg) {
700 if (vdev->defer_kvm_irq_routing) {
701 vfio_pci_add_kvm_msi_virq(vdev, vector, nr, true);
702 - } else {
702 + } else if (accel_msi_via_irqfd_enabled()) {
703 vfio_route_change = accel_irqchip_begin_route_changes();
704 vfio_pci_add_kvm_msi_virq(vdev, vector, nr, true);
705 accel_irqchip_commit_route_changes(&vfio_route_change);
@@ -801,7 +801,9 @@ void vfio_pci_prepare_kvm_msi_virq_batch(VFIOPCIDevice *vdev)
801 {
802 assert(!vdev->defer_kvm_irq_routing);
803 vdev->defer_kvm_irq_routing = true;
804 - vfio_route_change = accel_irqchip_begin_route_changes();
804 + if (accel_msi_via_irqfd_enabled()) {
805 + vfio_route_change = accel_irqchip_begin_route_changes();
806 + }
807 }
808
809 void vfio_pci_commit_kvm_msi_virq_batch(VFIOPCIDevice *vdev)