@samitouri / QOSamiQemu / commits / 250d97681a

hw/misc/ivshmem-pci: Handle error from kvm_irqchip_add_irqfd_notifier_gsi()

The return value of kvm_irqchip_add_irqfd_notifier_gsi() was being ignored. Propagate the error to the caller via errp. Also change setup_interrupt() to return bool to follow QEMU error handling conventions, making error checks at call sites simpler. Resolves the TODO comment at the call site. Signed-off-by: David Hamilton <dahamilt0@gmail.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20260225121323.5395-2-dahamilt0@gmail.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

David Hamilton committed Feb 25, 2026 at 07:13 UTC 250d97681a00501edb9a7a24e20642f7a063b72d
1 file changed +9 -4
hw/misc/ivshmem-pci.c
+9 -4
@@ -442,13 +442,14 @@ static void ivshmem_add_kvm_msi_virq(IVShmemState *s, int vector,
442 s->msi_vectors[vector].pdev = pdev;
443 }
444
445 -static void setup_interrupt(IVShmemState *s, int vector, Error **errp)
445 +static bool setup_interrupt(IVShmemState *s, int vector, Error **errp)
446 {
447 EventNotifier *n = &s->peers[s->vm_id].eventfds[vector];
448 bool with_irqfd = kvm_msi_via_irqfd_enabled() &&
449 ivshmem_has_feature(s, IVSHMEM_MSI);
450 PCIDevice *pdev = PCI_DEVICE(s);
451 Error *err = NULL;
452 + int ret;
453
454 IVSHMEM_DPRINTF("setting up interrupt for vector: %d\n", vector);
455
@@ -460,18 +461,22 @@ static void setup_interrupt(IVShmemState *s, int vector, Error **errp)
461 ivshmem_add_kvm_msi_virq(s, vector, &err);
462 if (err) {
463 error_propagate(errp, err);
463 - return;
464 + return false;
465 }
466
467 if (!msix_is_masked(pdev, vector)) {
467 - kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, n, NULL,
468 + ret = kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, n, NULL,
469 s->msi_vectors[vector].virq);
469 - /* TODO handle error */
470 + if (ret < 0) {
471 + error_setg(errp, "Failed to configure irqfd notifier");
472 + return false;
473 + }
474 }
475 } else {
476 /* it will be delayed until msix is enabled, in write_config */
477 IVSHMEM_DPRINTF("with irqfd, delayed until msix enabled\n");
478 }
479 + return true;
480 }
481
482 static void process_msg_shmem(IVShmemState *s, int fd, Error **errp)