On Thu, Sep 11, 2025 at 12:20:06PM +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]>
> ---
> 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 | 4 ++--
> util/main-loop.c | 5 ++++-
> 21 files changed, 64 insertions(+), 54 deletions(-)
>
> diff --git a/chardev/char-fd.c b/chardev/char-fd.c
> index 6f03adf872..739dc68c36 100644
> --- a/chardev/char-fd.c
> +++ b/chardev/char-fd.c
> @@ -212,8 +212,8 @@ void qemu_chr_open_fd(Chardev *chr,
> FDChardev *s = FD_CHARDEV(chr);
> g_autofree char *name = NULL;
>
> - if (fd_out >= 0 && !g_unix_set_fd_nonblocking(fd_out, true, NULL)) {
> - assert(!"Failed to set FD nonblocking");
> + if (fd_out >= 0) {
> + qemu_set_blocking(fd_out, false, &error_abort);
Every caller of this method has an 'errp' available that we
can plumb into qemu_chr_open_fd().
> }
>
> if (fd_out == fd_in && fd_in >= 0) {
> diff --git a/hw/misc/ivshmem-flat.c b/hw/misc/ivshmem-flat.c
> index fe4be6be17..89495f6a11 100644
> --- a/hw/misc/ivshmem-flat.c
> +++ b/hw/misc/ivshmem-flat.c
> @@ -154,7 +154,8 @@ static void ivshmem_flat_add_vector(IvshmemFTState *s,
> IvshmemPeer *peer,
> * peer.
> */
> peer->vector[peer->vector_counter].id = peer->vector_counter;
> - g_unix_set_fd_nonblocking(vector_fd, true, NULL);
> + /* WARNING: qemu_socket_set_nonblock() return code ignored */
> + qemu_set_blocking(vector_fd, false, NULL);
Perhaps &warn_report so we at least diagnose this awkward situation ?
>
> event_notifier_init_fd(&peer->vector[peer->vector_counter].event_notifier,
> vector_fd);
>
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 :|