qemu-e2k/accel
Igor Mammedov e34f4d87e8 kvm: error out of kvm_irqchip_add_msi_route() in case of full route table
subj is calling kvm_add_routing_entry() which simply extends
  KVMState::irq_routes::entries[]
but doesn't check if number of routes goes beyond limit the kernel
is willing to accept. Which later leads toi the assert

  qemu-kvm: ../accel/kvm/kvm-all.c:1833: kvm_irqchip_commit_routes: Assertion `ret == 0' failed

typically it happens during guest boot for large enough guest

Reproduced with:
  ./qemu --enable-kvm -m 8G -smp 64 -machine pc \
     `for b in {1..2}; do echo -n "-device pci-bridge,id=pci$b,chassis_nr=$b ";
        for i in {0..31}; do touch /tmp/vblk$b$i;
           echo -n "-drive file=/tmp/vblk$b$i,if=none,id=drive$b$i,format=raw
                    -device virtio-blk-pci,drive=drive$b$i,bus=pci$b ";
      done; done`

While crash at boot time is bad, the same might happen at hotplug time
which is unacceptable.
So instead calling kvm_add_routing_entry() unconditionally, check first
that number of routes won't exceed KVM_CAP_IRQ_ROUTING. This way virtio
device insteads killin qemu, will gracefully fail to initialize device
as expected with following warnings on console:
    virtio-blk failed to set guest notifier (-28), ensure -accel kvm is set.
    virtio_bus_start_ioeventfd: failed. Fallback to userspace (slower).

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-ID: <20240408110956.451558-1-imammedo@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-04-08 21:22:00 +02:00
..
hvf accel: Do not set CPUState::can_do_io in non-TCG accels 2024-01-19 12:28:59 +01:00
kvm kvm: error out of kvm_irqchip_add_msi_route() in case of full route table 2024-04-08 21:22:00 +02:00
qtest meson: Replace CONFIG_SOFTMMU -> CONFIG_SYSTEM_ONLY 2023-06-20 10:01:30 +02:00
stubs migration: prevent migration when VM has poisoned memory 2024-02-05 14:41:58 +08:00
tcg accel/tcg/plugin: Remove CONFIG_SOFTMMU_GATE definition 2024-04-02 14:54:35 +02:00
xen hw/xen: Extract 'xen_igd.h' from 'xen_pt.h' 2024-03-09 18:51:45 +01:00
Kconfig i386: xen: fix compilation --without-default-devices 2024-02-16 13:56:09 +01:00
accel-blocker.c system/cpus: rename qemu_mutex_lock_iothread() to bql_lock() 2024-01-08 10:45:43 -05:00
accel-system.c accel: Rename accel_init_ops_interfaces() to include 'system' 2024-01-19 12:28:59 +01:00
accel-system.h accel: Rename accel_init_ops_interfaces() to include 'system' 2024-01-19 12:28:59 +01:00
accel-target.c accel: Rename accel_init_ops_interfaces() to include 'system' 2024-01-19 12:28:59 +01:00
accel-user.c accel: extend AccelState and AccelClass to user-mode 2021-02-05 10:24:15 -10:00
dummy-cpus.c accel: Do not set CPUState::can_do_io in non-TCG accels 2024-01-19 12:28:59 +01:00
meson.build accel: Rename accel_softmmu* -> accel_system* 2023-10-07 19:02:57 +02:00