[PATCH 3/4] util/event_notifier: fix error handling for event_notifier_init callers

Trieu Huynh posted 4 patches 4 weeks ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Helge Deller <deller@gmx.de>, "Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>, Corey Minyard <minyard@acm.org>, Thomas Huth <th.huth+qemu@posteo.eu>, Laurent Vivier <laurent@vivier.eu>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>, Sriram Yagnaraman <sriram.yagnaraman@ericsson.com>, Jason Wang <jasowang@redhat.com>, Jiri Pirko <jiri@resnulli.us>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, BALATON Zoltan <balaton@eik.bme.hu>, Bernhard Beschow <shentey@gmail.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Nicholas Piggin <npiggin@gmail.com>, Aditya Gupta <adityag@linux.ibm.com>, Glenn Miles <milesg@linux.ibm.com>, "Hervé Poussineau" <hpoussin@reactos.org>, Harsh Prateek Bora <harshpb@linux.ibm.com>, Elena Ufimtseva <elena.ufimtseva@oracle.com>, Jagannathan Raman <jag.raman@oracle.com>, Hannes Reinecke <hare@suse.com>, Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <fam@euphon.net>, "Clément Chigot" <chigot@adacore.com>, Frederic Konrad <konrad.frederic@yahoo.fr>, Artyom Tarasenko <atar4qemu@gmail.com>, Tony Krowiak <akrowiak@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Jason Herne <jjherne@linux.ibm.com>, Alex Williamson <alex@shazbot.org>, "Cédric Le Goater" <clg@redhat.com>, Eric Farman <farman@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Stefano Garzarella <sgarzare@redhat.com>
[PATCH 3/4] util/event_notifier: fix error handling for event_notifier_init callers
Posted by Trieu Huynh 4 weeks ago
From: Trieu Huynh <vikingtc4@gmail.com>

Check return value of event_notifier_init() and return early on
failure instead of continuing with invalid state.
- Use ret < 0 to handle negative return value.
- No functional changes.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413
Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 hw/hyperv/hyperv.c     |  4 ++--
 hw/hyperv/vmbus.c      |  4 ++--
 hw/remote/proxy.c      | 15 +++++++++++++--
 hw/vfio/ap.c           |  2 +-
 hw/vfio/ccw.c          |  2 +-
 hw/vfio/pci-quirks.c   |  2 +-
 hw/vfio/pci.c          |  2 +-
 hw/virtio/vhost-vdpa.c |  4 ++--
 8 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
index 27e323a819..aa278b179e 100644
--- a/hw/hyperv/hyperv.c
+++ b/hw/hyperv/hyperv.c
@@ -439,7 +439,7 @@ HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
         sint_route->staged_msg->cb_data = cb_data;
 
         r = event_notifier_init(ack_notifier, false);
-        if (r) {
+        if (r < 0) {
             goto cleanup_err_sint;
         }
         event_notifier_set_handler(ack_notifier, sint_ack_handler);
@@ -453,7 +453,7 @@ HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
 
     /* We need to setup a GSI for this SintRoute */
     r = event_notifier_init(&sint_route->sint_set_notifier, false);
-    if (r) {
+    if (r < 0) {
         goto cleanup_err_sint;
     }
 
diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
index c5bab5d245..2f0d2a03d8 100644
--- a/hw/hyperv/vmbus.c
+++ b/hw/hyperv/vmbus.c
@@ -1425,7 +1425,7 @@ static void open_channel(VMBusChannel *chan)
         goto put_gpadl;
     }
 
-    if (event_notifier_init(&chan->notifier, 0)) {
+    if (event_notifier_init(&chan->notifier, 0) < 0) {
         goto put_gpadl;
     }
 
@@ -2416,7 +2416,7 @@ static void vmbus_realize(BusState *bus, Error **errp)
     }
 
     ret = event_notifier_init(&vmbus->notifier, 0);
-    if (ret != 0) {
+    if (ret < 0) {
         error_setg(errp, "event notifier failed to init with %d", ret);
         goto remove_msg_handler;
     }
diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c
index 5081d67e7f..e91566509f 100644
--- a/hw/remote/proxy.c
+++ b/hw/remote/proxy.c
@@ -52,9 +52,20 @@ static void setup_irqfd(PCIProxyDev *dev)
     PCIDevice *pci_dev = PCI_DEVICE(dev);
     MPQemuMsg msg;
     Error *local_err = NULL;
+    int ret = 0;
 
-    event_notifier_init(&dev->intr, 0);
-    event_notifier_init(&dev->resample, 0);
+    ret = event_notifier_init(&dev->intr, 0);
+    if (ret < 0) {
+        error_report("Failed to init intr notifier: %s", strerror(-ret));
+        return;
+    }
+
+    ret = event_notifier_init(&dev->resample, 0);
+    if (ret < 0) {
+        error_report("Failed to init resample notifier: %s", strerror(-ret));
+        event_notifier_cleanup(&dev->intr);
+        return;
+    }
 
     memset(&msg, 0, sizeof(MPQemuMsg));
     msg.cmd = MPQEMU_CMD_SET_IRQFD;
diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
index e58a0169af..5c8f305653 100644
--- a/hw/vfio/ap.c
+++ b/hw/vfio/ap.c
@@ -180,7 +180,7 @@ static bool vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,
         return false;
     }
 
-    if (event_notifier_init(notifier, 0)) {
+    if (event_notifier_init(notifier, 0) < 0) {
         error_setg_errno(errp, errno,
                          "vfio: Unable to init event notifier for irq (%d)",
                          irq);
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index 2251facb35..ce9c014e6a 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -418,7 +418,7 @@ static bool vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
         return false;
     }
 
-    if (event_notifier_init(notifier, 0)) {
+    if (event_notifier_init(notifier, 0) < 0) {
         error_setg_errno(errp, errno,
                          "vfio: Unable to init event notifier for irq (%d)",
                          irq);
diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
index 7b907b9360..66e02b15a4 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -318,7 +318,7 @@ static VFIOIOEventFD *vfio_ioeventfd_init(VFIOPCIDevice *vdev,
 
     ioeventfd = g_malloc0(sizeof(*ioeventfd));
 
-    if (event_notifier_init(&ioeventfd->e, 0)) {
+    if (event_notifier_init(&ioeventfd->e, 0) < 0) {
         g_free(ioeventfd);
         return NULL;
     }
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index c89f3fbea3..29bf6511b3 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -70,7 +70,7 @@ static bool vfio_notifier_init(VFIOPCIDevice *vdev, EventNotifier *e,
     }
 
     ret = event_notifier_init(e, 0);
-    if (ret) {
+    if (ret < 0) {
         error_setg_errno(errp, -ret, "vfio_notifier_init %s failed", name);
         return false;
     }
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 2f8f11df86..9c7634e243 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -1075,13 +1075,13 @@ static int vhost_vdpa_svq_set_fds(struct vhost_dev *dev,
     int r;
 
     r = event_notifier_init(&svq->hdev_kick, 0);
-    if (r != 0) {
+    if (r < 0) {
         error_setg_errno(errp, -r, "Couldn't create kick event notifier");
         goto err_init_hdev_kick;
     }
 
     r = event_notifier_init(&svq->hdev_call, 0);
-    if (r != 0) {
+    if (r < 0) {
         error_setg_errno(errp, -r, "Couldn't create call event notifier");
         goto err_init_hdev_call;
     }
-- 
2.43.0
Re: [PATCH 3/4] util/event_notifier: fix error handling for event_notifier_init callers
Posted by Jag Raman 3 weeks, 6 days ago

> On Mar 10, 2026, at 2:27 PM, Trieu Huynh <vikingtc4@gmail.com> wrote:
> 
> From: Trieu Huynh <vikingtc4@gmail.com>
> 
> Check return value of event_notifier_init() and return early on
> failure instead of continuing with invalid state.
> - Use ret < 0 to handle negative return value.
> - No functional changes.
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413
> Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>

LGTM

Reviewed-by: Jagannathan Raman <jag.raman@oracle.com>

Please see note below.

> ---
> hw/hyperv/hyperv.c     |  4 ++--
> hw/hyperv/vmbus.c      |  4 ++--
> hw/remote/proxy.c      | 15 +++++++++++++--
> hw/vfio/ap.c           |  2 +-
> hw/vfio/ccw.c          |  2 +-
> hw/vfio/pci-quirks.c   |  2 +-
> hw/vfio/pci.c          |  2 +-
> hw/virtio/vhost-vdpa.c |  4 ++--
> 8 files changed, 23 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
> index 27e323a819..aa278b179e 100644
> --- a/hw/hyperv/hyperv.c
> +++ b/hw/hyperv/hyperv.c
> @@ -439,7 +439,7 @@ HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
>         sint_route->staged_msg->cb_data = cb_data;
> 
>         r = event_notifier_init(ack_notifier, false);
> -        if (r) {
> +        if (r < 0) {
>             goto cleanup_err_sint;
>         }
>         event_notifier_set_handler(ack_notifier, sint_ack_handler);
> @@ -453,7 +453,7 @@ HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
> 
>     /* We need to setup a GSI for this SintRoute */
>     r = event_notifier_init(&sint_route->sint_set_notifier, false);
> -    if (r) {
> +    if (r < 0) {
>         goto cleanup_err_sint;
>     }
> 
> diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
> index c5bab5d245..2f0d2a03d8 100644
> --- a/hw/hyperv/vmbus.c
> +++ b/hw/hyperv/vmbus.c
> @@ -1425,7 +1425,7 @@ static void open_channel(VMBusChannel *chan)
>         goto put_gpadl;
>     }
> 
> -    if (event_notifier_init(&chan->notifier, 0)) {
> +    if (event_notifier_init(&chan->notifier, 0) < 0) {
>         goto put_gpadl;
>     }
> 
> @@ -2416,7 +2416,7 @@ static void vmbus_realize(BusState *bus, Error **errp)
>     }
> 
>     ret = event_notifier_init(&vmbus->notifier, 0);
> -    if (ret != 0) {
> +    if (ret < 0) {
>         error_setg(errp, "event notifier failed to init with %d", ret);
>         goto remove_msg_handler;
>     }
> diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c
> index 5081d67e7f..e91566509f 100644
> --- a/hw/remote/proxy.c
> +++ b/hw/remote/proxy.c
> @@ -52,9 +52,20 @@ static void setup_irqfd(PCIProxyDev *dev)
>     PCIDevice *pci_dev = PCI_DEVICE(dev);
>     MPQemuMsg msg;
>     Error *local_err = NULL;
> +    int ret = 0;
> 
> -    event_notifier_init(&dev->intr, 0);
> -    event_notifier_init(&dev->resample, 0);
> +    ret = event_notifier_init(&dev->intr, 0);
> +    if (ret < 0) {
> +        error_report("Failed to init intr notifier: %s", strerror(-ret));

setup_irqfd() should ideally propagate the error up the stack.
But hw/remote/proxy.c is planned for removal as it is superseded
by vfio-user, so we don’t need to do it.

Thanks,
Jag

> +        return;
> +    }
> +
> +    ret = event_notifier_init(&dev->resample, 0);
> +    if (ret < 0) {
> +        error_report("Failed to init resample notifier: %s", strerror(-ret));
> +        event_notifier_cleanup(&dev->intr);
> +        return;
> +    }
> 
>     memset(&msg, 0, sizeof(MPQemuMsg));
>     msg.cmd = MPQEMU_CMD_SET_IRQFD;
> diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
> index e58a0169af..5c8f305653 100644
> --- a/hw/vfio/ap.c
> +++ b/hw/vfio/ap.c
> @@ -180,7 +180,7 @@ static bool vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,
>         return false;
>     }
> 
> -    if (event_notifier_init(notifier, 0)) {
> +    if (event_notifier_init(notifier, 0) < 0) {
>         error_setg_errno(errp, errno,
>                          "vfio: Unable to init event notifier for irq (%d)",
>                          irq);
> diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
> index 2251facb35..ce9c014e6a 100644
> --- a/hw/vfio/ccw.c
> +++ b/hw/vfio/ccw.c
> @@ -418,7 +418,7 @@ static bool vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
>         return false;
>     }
> 
> -    if (event_notifier_init(notifier, 0)) {
> +    if (event_notifier_init(notifier, 0) < 0) {
>         error_setg_errno(errp, errno,
>                          "vfio: Unable to init event notifier for irq (%d)",
>                          irq);
> diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
> index 7b907b9360..66e02b15a4 100644
> --- a/hw/vfio/pci-quirks.c
> +++ b/hw/vfio/pci-quirks.c
> @@ -318,7 +318,7 @@ static VFIOIOEventFD *vfio_ioeventfd_init(VFIOPCIDevice *vdev,
> 
>     ioeventfd = g_malloc0(sizeof(*ioeventfd));
> 
> -    if (event_notifier_init(&ioeventfd->e, 0)) {
> +    if (event_notifier_init(&ioeventfd->e, 0) < 0) {
>         g_free(ioeventfd);
>         return NULL;
>     }
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index c89f3fbea3..29bf6511b3 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -70,7 +70,7 @@ static bool vfio_notifier_init(VFIOPCIDevice *vdev, EventNotifier *e,
>     }
> 
>     ret = event_notifier_init(e, 0);
> -    if (ret) {
> +    if (ret < 0) {
>         error_setg_errno(errp, -ret, "vfio_notifier_init %s failed", name);
>         return false;
>     }
> diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> index 2f8f11df86..9c7634e243 100644
> --- a/hw/virtio/vhost-vdpa.c
> +++ b/hw/virtio/vhost-vdpa.c
> @@ -1075,13 +1075,13 @@ static int vhost_vdpa_svq_set_fds(struct vhost_dev *dev,
>     int r;
> 
>     r = event_notifier_init(&svq->hdev_kick, 0);
> -    if (r != 0) {
> +    if (r < 0) {
>         error_setg_errno(errp, -r, "Couldn't create kick event notifier");
>         goto err_init_hdev_kick;
>     }
> 
>     r = event_notifier_init(&svq->hdev_call, 0);
> -    if (r != 0) {
> +    if (r < 0) {
>         error_setg_errno(errp, -r, "Couldn't create call event notifier");
>         goto err_init_hdev_call;
>     }
> -- 
> 2.43.0
> 

Deprecate Multi-process QEMU (Re: [PATCH 3/4] util/event_notifier: fix error handling for event_notifier_init callers)
Posted by Cédric Le Goater 3 weeks, 6 days ago
Hello Jag,

+ John

>> diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c
>> index 5081d67e7f..e91566509f 100644
>> --- a/hw/remote/proxy.c
>> +++ b/hw/remote/proxy.c
>> @@ -52,9 +52,20 @@ static void setup_irqfd(PCIProxyDev *dev)
>>      PCIDevice *pci_dev = PCI_DEVICE(dev);
>>      MPQemuMsg msg;
>>      Error *local_err = NULL;
>> +    int ret = 0;
>>
>> -    event_notifier_init(&dev->intr, 0);
>> -    event_notifier_init(&dev->resample, 0);
>> +    ret = event_notifier_init(&dev->intr, 0);
>> +    if (ret < 0) {
>> +        error_report("Failed to init intr notifier: %s", strerror(-ret));
> 
> setup_irqfd() should ideally propagate the error up the stack.
> But hw/remote/proxy.c is planned for removal as it is superseded
> by vfio-user, so we don’t need to do it.

In that case, could you please send an update of docs/about/deprecated.rst
to deprecate Multi-process QEMU ?

Thanks,

C.


Re: Deprecate Multi-process QEMU (Re: [PATCH 3/4] util/event_notifier: fix error handling for event_notifier_init callers)
Posted by Jag Raman 3 weeks, 6 days ago

> On Mar 11, 2026, at 12:09 PM, Cédric Le Goater <clg@redhat.com> wrote:
> 
> Hello Jag,
> 
> + John
> 
>>> diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c
>>> index 5081d67e7f..e91566509f 100644
>>> --- a/hw/remote/proxy.c
>>> +++ b/hw/remote/proxy.c
>>> @@ -52,9 +52,20 @@ static void setup_irqfd(PCIProxyDev *dev)
>>>     PCIDevice *pci_dev = PCI_DEVICE(dev);
>>>     MPQemuMsg msg;
>>>     Error *local_err = NULL;
>>> +    int ret = 0;
>>> 
>>> -    event_notifier_init(&dev->intr, 0);
>>> -    event_notifier_init(&dev->resample, 0);
>>> +    ret = event_notifier_init(&dev->intr, 0);
>>> +    if (ret < 0) {
>>> +        error_report("Failed to init intr notifier: %s", strerror(-ret));
>> setup_irqfd() should ideally propagate the error up the stack.
>> But hw/remote/proxy.c is planned for removal as it is superseded
>> by vfio-user, so we don’t need to do it.
> 
> In that case, could you please send an update of docs/about/deprecated.rst
> to deprecate Multi-process QEMU ?

Sounds good, Cedric. Will do.

> 
> Thanks,
> 
> C.
> 

Re: [PATCH 3/4] util/event_notifier: fix error handling for event_notifier_init callers
Posted by Anthony Krowiak 3 weeks, 6 days ago

On 3/10/26 2:27 PM, Trieu Huynh wrote:
> From: Trieu Huynh <vikingtc4@gmail.com>
>
> Check return value of event_notifier_init() and return early on
> failure instead of continuing with invalid state.
> - Use ret < 0 to handle negative return value.
> - No functional changes.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413
> Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
> ---
>   hw/hyperv/hyperv.c     |  4 ++--
>   hw/hyperv/vmbus.c      |  4 ++--
>   hw/remote/proxy.c      | 15 +++++++++++++--
>   hw/vfio/ap.c           |  2 +-
>   hw/vfio/ccw.c          |  2 +-
>   hw/vfio/pci-quirks.c   |  2 +-
>   hw/vfio/pci.c          |  2 +-
>   hw/virtio/vhost-vdpa.c |  4 ++--
>   8 files changed, 23 insertions(+), 12 deletions(-)
>
> diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
> index 27e323a819..aa278b179e 100644
> --- a/hw/hyperv/hyperv.c
> +++ b/hw/hyperv/hyperv.c
> @@ -439,7 +439,7 @@ HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
>           sint_route->staged_msg->cb_data = cb_data;
>   
>           r = event_notifier_init(ack_notifier, false);
> -        if (r) {
> +        if (r < 0) {
>               goto cleanup_err_sint;
>           }
>           event_notifier_set_handler(ack_notifier, sint_ack_handler);
> @@ -453,7 +453,7 @@ HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
>   
>       /* We need to setup a GSI for this SintRoute */
>       r = event_notifier_init(&sint_route->sint_set_notifier, false);
> -    if (r) {
> +    if (r < 0) {
>           goto cleanup_err_sint;
>       }
>   
> diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
> index c5bab5d245..2f0d2a03d8 100644
> --- a/hw/hyperv/vmbus.c
> +++ b/hw/hyperv/vmbus.c
> @@ -1425,7 +1425,7 @@ static void open_channel(VMBusChannel *chan)
>           goto put_gpadl;
>       }
>   
> -    if (event_notifier_init(&chan->notifier, 0)) {
> +    if (event_notifier_init(&chan->notifier, 0) < 0) {
>           goto put_gpadl;
>       }
>   
> @@ -2416,7 +2416,7 @@ static void vmbus_realize(BusState *bus, Error **errp)
>       }
>   
>       ret = event_notifier_init(&vmbus->notifier, 0);
> -    if (ret != 0) {
> +    if (ret < 0) {
>           error_setg(errp, "event notifier failed to init with %d", ret);
>           goto remove_msg_handler;
>       }
> diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c
> index 5081d67e7f..e91566509f 100644
> --- a/hw/remote/proxy.c
> +++ b/hw/remote/proxy.c
> @@ -52,9 +52,20 @@ static void setup_irqfd(PCIProxyDev *dev)
>       PCIDevice *pci_dev = PCI_DEVICE(dev);
>       MPQemuMsg msg;
>       Error *local_err = NULL;
> +    int ret = 0;
>   
> -    event_notifier_init(&dev->intr, 0);
> -    event_notifier_init(&dev->resample, 0);
> +    ret = event_notifier_init(&dev->intr, 0);
> +    if (ret < 0) {
> +        error_report("Failed to init intr notifier: %s", strerror(-ret));
> +        return;
> +    }
> +
> +    ret = event_notifier_init(&dev->resample, 0);
> +    if (ret < 0) {
> +        error_report("Failed to init resample notifier: %s", strerror(-ret));
> +        event_notifier_cleanup(&dev->intr);
> +        return;
> +    }
>   
>       memset(&msg, 0, sizeof(MPQemuMsg));
>       msg.cmd = MPQEMU_CMD_SET_IRQFD;
> diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
> index e58a0169af..5c8f305653 100644
> --- a/hw/vfio/ap.c
> +++ b/hw/vfio/ap.c
> @@ -180,7 +180,7 @@ static bool vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,
>           return false;
>       }
>   
> -    if (event_notifier_init(notifier, 0)) {
> +    if (event_notifier_init(notifier, 0) < 0) {

Acked-by:  Anthony Krowiak <akrowiak@linux.ibm.com>

>           error_setg_errno(errp, errno,
>                            "vfio: Unable to init event notifier for irq (%d)",
>                            irq);
> diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
> index 2251facb35..ce9c014e6a 100644
> --- a/hw/vfio/ccw.c
> +++ b/hw/vfio/ccw.c
> @@ -418,7 +418,7 @@ static bool vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
>           return false;
>       }
>   
> -    if (event_notifier_init(notifier, 0)) {
> +    if (event_notifier_init(notifier, 0) < 0) {
>           error_setg_errno(errp, errno,
>                            "vfio: Unable to init event notifier for irq (%d)",
>                            irq);
> diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
> index 7b907b9360..66e02b15a4 100644
> --- a/hw/vfio/pci-quirks.c
> +++ b/hw/vfio/pci-quirks.c
> @@ -318,7 +318,7 @@ static VFIOIOEventFD *vfio_ioeventfd_init(VFIOPCIDevice *vdev,
>   
>       ioeventfd = g_malloc0(sizeof(*ioeventfd));
>   
> -    if (event_notifier_init(&ioeventfd->e, 0)) {
> +    if (event_notifier_init(&ioeventfd->e, 0) < 0) {
>           g_free(ioeventfd);
>           return NULL;
>       }
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index c89f3fbea3..29bf6511b3 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -70,7 +70,7 @@ static bool vfio_notifier_init(VFIOPCIDevice *vdev, EventNotifier *e,
>       }
>   
>       ret = event_notifier_init(e, 0);
> -    if (ret) {
> +    if (ret < 0) {
>           error_setg_errno(errp, -ret, "vfio_notifier_init %s failed", name);
>           return false;
>       }
> diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> index 2f8f11df86..9c7634e243 100644
> --- a/hw/virtio/vhost-vdpa.c
> +++ b/hw/virtio/vhost-vdpa.c
> @@ -1075,13 +1075,13 @@ static int vhost_vdpa_svq_set_fds(struct vhost_dev *dev,
>       int r;
>   
>       r = event_notifier_init(&svq->hdev_kick, 0);
> -    if (r != 0) {
> +    if (r < 0) {
>           error_setg_errno(errp, -r, "Couldn't create kick event notifier");
>           goto err_init_hdev_kick;
>       }
>   
>       r = event_notifier_init(&svq->hdev_call, 0);
> -    if (r != 0) {
> +    if (r < 0) {
>           error_setg_errno(errp, -r, "Couldn't create call event notifier");
>           goto err_init_hdev_call;
>       }