On Tue, Sep 16, 2025 at 04:13:59PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> Instead of open-coded g_unix_set_fd_nonblocking() calls, use
> QEMU wrapper qemu_set_blocking().
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
> Reviewed-by: Daniel P. Berrangé <[email protected]>
> ---
>  chardev/char-fd.c                  |  4 ++--
>  chardev/char-pty.c                 |  3 +--
>  chardev/char-serial.c              |  3 +--
>  chardev/char-stdio.c               |  3 +--
>  hw/input/virtio-input-host.c       |  3 +--
>  hw/misc/ivshmem-flat.c             |  3 ++-
>  hw/misc/ivshmem-pci.c              |  7 ++++++-
>  hw/virtio/vhost-vsock.c            |  8 ++------
>  io/channel-command.c               |  9 ++++++---
>  io/channel-file.c                  |  3 +--
>  net/tap-bsd.c                      | 12 ++++++++++--
>  net/tap-linux.c                    |  7 ++++++-
>  net/tap-solaris.c                  |  7 ++++++-
>  net/tap.c                          | 21 ++++++---------------
>  qga/commands-posix.c               |  3 +--
>  tests/qtest/fuzz/virtio_net_fuzz.c |  2 +-
>  tests/qtest/vhost-user-test.c      |  3 +--
>  tests/unit/test-iov.c              |  5 +++--
>  ui/input-linux.c                   |  3 +--
>  util/event_notifier-posix.c        |  7 +++++--
>  util/main-loop.c                   |  5 ++++-
>  21 files changed, 67 insertions(+), 54 deletions(-)
> 

> diff --git a/net/tap-bsd.c b/net/tap-bsd.c
> index b4c84441ba..2e444e59b5 100644
> --- a/net/tap-bsd.c
> +++ b/net/tap-bsd.c
> @@ -98,7 +98,12 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
>              return -1;
>          }
>      }
> -    g_unix_set_fd_nonblocking(fd, true, NULL);
> +
> +    if (!qemu_set_blocking(fd, false, errp) {

Missing trailing ')' here

> +        close(fd);
> +        return -1;
> +    }
> +
>      return fd;
>  }
>  
> @@ -189,7 +194,10 @@ int tap_open(char *ifname, int ifname_size, int 
> *vnet_hdr,
>          goto error;
>      }
>  
> -    g_unix_set_fd_nonblocking(fd, true, NULL);
> +    if (!qemu_set_blocking(fd, false, errp) {

and here

> +        goto error;
> +    }
> +
>      return fd;
>  
>  error:

> diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c
> index 56472ca709..e39d6e7787 100644
> --- a/tests/qtest/vhost-user-test.c
> +++ b/tests/qtest/vhost-user-test.c
> @@ -471,8 +471,7 @@ static void chr_read(void *opaque, const uint8_t *buf, 
> int size)
>           * The receive function forces it to be blocking,
>           * so revert it back to non-blocking.
>           */
> -        g_unix_set_fd_nonblocking(fd, true, &err);
> -        g_assert_no_error(err);
> +        qemu_set_blocking(fd, false, &error_abort);
>          break;

This removed the only use 'err' causing a warning in tsan builds.

>  
>      case VHOST_USER_SET_LOG_BASE:

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Reply via email to