[PATCH for 11.2] vhost: do not get config notifier when one doesn't exist

Eric Farman posted 1 patch 2 weeks, 6 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261102174916.2301985-1-farman@linux.ibm.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>
hw/virtio/vhost.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH for 11.2] vhost: do not get config notifier when one doesn't exist
Posted by Eric Farman 2 weeks, 6 days ago
Commit e3b12d0c55e4 ("util/event_notifier: more strict API") added an
assert for an uninitialized file descriptor in event_notifier_get_fd(),
but it presumes that such a thing always exists.

Since it's only vhost_ops->vhost_set_config_call that expects to use
this file descriptor, move the retrieval of that fd inside the non-null
check to avoid an assertion failure when it does not exist.

Fixes: e3b12d0c55e4 ("util/event_notifier: more strict API")
Signed-off-by: Eric Farman <farman@linux.ibm.com>
---
 hw/virtio/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index b25919c5c7d..998518c3b2e 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -2119,8 +2119,8 @@ static void vhost_start_config_intr(struct vhost_dev *dev)
         virtio_config_get_guest_notifier(dev->vdev);
 
     assert(dev->vhost_ops);
-    int fd = event_notifier_get_fd(config_notifier);
     if (dev->vhost_ops->vhost_set_config_call) {
+        int fd = event_notifier_get_fd(config_notifier);
         r = dev->vhost_ops->vhost_set_config_call(dev, fd);
         if (!r) {
             event_notifier_set(config_notifier);
-- 
2.53.0
Re: [PATCH for 11.2] vhost: do not get config notifier when one doesn't exist
Posted by Eric Farman 2 weeks, 5 days ago

On 11/2/26 12:49 PM, Eric Farman wrote:
> Commit e3b12d0c55e4 ("util/event_notifier: more strict API") added an
> assert for an uninitialized file descriptor in event_notifier_get_fd(),
> but it presumes that such a thing always exists.
> 
> Since it's only vhost_ops->vhost_set_config_call that expects to use
> this file descriptor, move the retrieval of that fd inside the non-null
> check to avoid an assertion failure when it does not exist.
> 
> Fixes: e3b12d0c55e4 ("util/event_notifier: more strict API")
> Signed-off-by: Eric Farman <farman@linux.ibm.com>

Ah, this is not going to work. VDPA has previously worked on s390x, but 
as it's the only place that sets vhost_ops->vhost_set_config_call we'll 
still end up failing the assertion in event_notifier_get_fd for that 
device type.

> ---
>   hw/virtio/vhost.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index b25919c5c7d..998518c3b2e 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -2119,8 +2119,8 @@ static void vhost_start_config_intr(struct vhost_dev *dev)
>           virtio_config_get_guest_notifier(dev->vdev);
>   
>       assert(dev->vhost_ops);
> -    int fd = event_notifier_get_fd(config_notifier);
>       if (dev->vhost_ops->vhost_set_config_call) {
> +        int fd = event_notifier_get_fd(config_notifier);
>           r = dev->vhost_ops->vhost_set_config_call(dev, fd);
>           if (!r) {
>               event_notifier_set(config_notifier);