[PATCH] vfio: propagate IRQ notifier registration failure

zhaoguohan@kylinos.cn posted 1 patch 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260424023904.261258-1-zhaoguohan@kylinos.cn
Maintainers: Alex Williamson <alex@shazbot.org>, "Cédric Le Goater" <clg@redhat.com>, Tony Krowiak <akrowiak@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Jason Herne <jjherne@linux.ibm.com>, Cornelia Huck <cohuck@redhat.com>, Eric Farman <farman@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>
There is a newer version of this series
hw/vfio/ap.c  | 1 +
hw/vfio/ccw.c | 1 +
2 files changed, 2 insertions(+)
[PATCH] vfio: propagate IRQ notifier registration failure
Posted by zhaoguohan@kylinos.cn 1 month ago
From: GuoHan Zhao <zhaoguohan@kylinos.cn>

vfio_ap_register_irq_notifier() and vfio_ccw_register_irq_notifier() clean
up the fd handler and EventNotifier when vfio_device_irq_set_signaling()
fails, but still return true to their callers.

Return false after cleanup so callers can handle the failed registration
path instead of treating it as a successful notifier setup.

Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn>
---
 hw/vfio/ap.c  | 1 +
 hw/vfio/ccw.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
index 276ae8c207bf..6e2a1223ea8d 100644
--- a/hw/vfio/ap.c
+++ b/hw/vfio/ap.c
@@ -193,6 +193,7 @@ static bool vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,
                                        errp)) {
         qemu_set_fd_handler(fd, NULL, NULL, vapdev);
         event_notifier_cleanup(notifier);
+        return false;
     }
 
     return true;
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index ff6ab9a7408f..c3dc7c196235 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -431,6 +431,7 @@ static bool vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
                                        VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) {
         qemu_set_fd_handler(fd, NULL, NULL, vcdev);
         event_notifier_cleanup(notifier);
+        return false;
     }
 
     return true;
-- 
2.43.0
Re: [PATCH] vfio: propagate IRQ notifier registration failure
Posted by Cédric Le Goater 3 weeks, 5 days ago
Hello,

On 4/24/26 04:39, zhaoguohan@kylinos.cn wrote:
> From: GuoHan Zhao <zhaoguohan@kylinos.cn>
> 
> vfio_ap_register_irq_notifier() and vfio_ccw_register_irq_notifier() clean
> up the fd handler and EventNotifier when vfio_device_irq_set_signaling()
> fails, but still return true to their callers.
> 
> Return false after cleanup so callers can handle the failed registration
> path instead of treating it as a successful notifier setup.
> 
> Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn>
> ---
>   hw/vfio/ap.c  | 1 +
>   hw/vfio/ccw.c | 1 +
>   2 files changed, 2 insertions(+)
> 
> diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
> index 276ae8c207bf..6e2a1223ea8d 100644
> --- a/hw/vfio/ap.c
> +++ b/hw/vfio/ap.c
> @@ -193,6 +193,7 @@ static bool vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,
>                                          errp)) {
>           qemu_set_fd_handler(fd, NULL, NULL, vapdev);
>           event_notifier_cleanup(notifier);
> +        return false;
>       }
>   
>       return true;
> diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
> index ff6ab9a7408f..c3dc7c196235 100644
> --- a/hw/vfio/ccw.c
> +++ b/hw/vfio/ccw.c
> @@ -431,6 +431,7 @@ static bool vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
>                                          VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) {
>           qemu_set_fd_handler(fd, NULL, NULL, vcdev);
>           event_notifier_cleanup(notifier);
> +        return false;
>       }
>   
>       return true;


The issue was introduced by :

   Fixes: cbd470f0aac5 ("vfio/ap: Make vfio_ap_register_irq_notifier() return a bool")
   Fixes: 8aaeff97acee ("vfio/ccw: Make vfio_ccw_register_irq_notifier() return a bool")

Could you please resend two patches ?

thanks,

C.