[PATCH 00/10] io: deal with blocking/non-blocking fds

Vladimir Sementsov-Ogievskiy posted 10 patches 3 days, 2 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250903094411.1029449-1-vsementsov@yandex-team.ru
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, Gustavo Romero <gustavo.romero@linaro.org>, Elena Ufimtseva <elena.ufimtseva@oracle.com>, Jagannathan Raman <jag.raman@oracle.com>, John Levon <john.levon@nutanix.com>, Thanos Makatos <thanos.makatos@nutanix.com>, "Cédric Le Goater" <clg@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Jason Wang <jasowang@redhat.com>, Michael Roth <michael.roth@amd.com>, Kostiantyn Kostiuk <kkostiuk@redhat.com>, Fam Zheng <fam@euphon.net>, Alexander Bulekov <alxndr@bu.edu>, Bandan Das <bsd@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Darren Kenny <darren.kenny@oracle.com>, Qiuhao Li <Qiuhao.Li@outlook.com>, Laurent Vivier <lvivier@redhat.com>, Stefan Berger <stefanb@linux.vnet.ibm.com>, Stefan Weil <sw@weilnetz.de>, Coiby Xu <Coiby.Xu@gmail.com>
chardev/char-fd.c                       |  4 +--
chardev/char-pty.c                      |  3 +-
chardev/char-serial.c                   |  3 +-
chardev/char-socket.c                   | 45 ++++++++++++-------------
chardev/char-stdio.c                    |  3 +-
contrib/ivshmem-server/ivshmem-server.c |  5 ++-
hw/hyperv/syndbg.c                      |  4 ++-
hw/input/virtio-input-host.c            |  3 +-
hw/misc/ivshmem-flat.c                  |  4 ++-
hw/misc/ivshmem-pci.c                   |  8 ++++-
hw/remote/mpqemu-link.c                 |  3 ++
hw/vfio-user/proxy.c                    |  4 +++
hw/virtio/vhost-user.c                  | 10 +++++-
hw/virtio/vhost-vsock.c                 |  8 ++---
include/io/channel.h                    | 12 +++++++
include/qemu/osdep.h                    |  8 +++++
include/qemu/sockets.h                  |  3 --
io/channel-command.c                    |  9 +++--
io/channel-file.c                       |  3 +-
io/channel-socket.c                     | 26 +++++++-------
net/dgram.c                             | 28 ++++++++-------
net/l2tpv3.c                            |  5 +--
net/socket.c                            | 27 ++++++++++-----
net/stream.c                            |  9 ++---
net/stream_data.c                       | 10 +++---
net/tap-bsd.c                           | 12 +++++--
net/tap-linux.c                         |  8 ++++-
net/tap-solaris.c                       |  7 +++-
net/tap.c                               | 21 ++++--------
qga/channel-posix.c                     |  7 +++-
qga/commands-posix.c                    |  3 +-
scsi/qemu-pr-helper.c                   |  4 +++
tests/qtest/fuzz/virtio_net_fuzz.c      |  2 +-
tests/qtest/tpm-emu.c                   |  1 +
tests/qtest/vhost-user-test.c           |  3 +-
tests/unit/socket-helpers.c             |  5 ++-
tests/unit/test-crypto-tlssession.c     |  8 ++---
tests/unit/test-io-channel-socket.c     |  1 +
tests/unit/test-iov.c                   |  5 +--
ui/input-linux.c                        |  3 +-
util/event_notifier-posix.c             |  5 +--
util/main-loop.c                        |  6 +++-
util/oslib-posix.c                      | 27 +++++++++------
util/oslib-win32.c                      | 25 ++++++--------
util/vhost-user-server.c                |  9 +++--
45 files changed, 244 insertions(+), 165 deletions(-)
[PATCH 00/10] io: deal with blocking/non-blocking fds
Posted by Vladimir Sementsov-Ogievskiy 3 days, 2 hours ago
Hi all!

The series brings two things:

1. unify code which sets fds blocking/non-blocking through the whole
source

2. for fds, which comes from qio_channel_readv_full(), stop making
them blocking in generic code, and move this logic to the callers,
all except coming from migration qemu-file (see last patch)

Vladimir Sementsov-Ogievskiy (10):
  io/channel: document how qio_channel_readv_full() handles fds
  char-socket: rework tcp_chr_recv()
  util: add qemu_set_blocking() function
  util: drop qemu_socket_set_nonblock()
  util: drop qemu_socket_try_set_nonblock()
  util: drop qemu_socket_set_block()
  use qemu_set_blocking instead of g_unix_set_fd_nonblocking
  oslib-posix: add qemu_fds_set_blocking() helper
  qio_channel_readv_full(): move setting fd blocking to callers
  migration/qemu-file: don't make incoming fds blocking again

 chardev/char-fd.c                       |  4 +--
 chardev/char-pty.c                      |  3 +-
 chardev/char-serial.c                   |  3 +-
 chardev/char-socket.c                   | 45 ++++++++++++-------------
 chardev/char-stdio.c                    |  3 +-
 contrib/ivshmem-server/ivshmem-server.c |  5 ++-
 hw/hyperv/syndbg.c                      |  4 ++-
 hw/input/virtio-input-host.c            |  3 +-
 hw/misc/ivshmem-flat.c                  |  4 ++-
 hw/misc/ivshmem-pci.c                   |  8 ++++-
 hw/remote/mpqemu-link.c                 |  3 ++
 hw/vfio-user/proxy.c                    |  4 +++
 hw/virtio/vhost-user.c                  | 10 +++++-
 hw/virtio/vhost-vsock.c                 |  8 ++---
 include/io/channel.h                    | 12 +++++++
 include/qemu/osdep.h                    |  8 +++++
 include/qemu/sockets.h                  |  3 --
 io/channel-command.c                    |  9 +++--
 io/channel-file.c                       |  3 +-
 io/channel-socket.c                     | 26 +++++++-------
 net/dgram.c                             | 28 ++++++++-------
 net/l2tpv3.c                            |  5 +--
 net/socket.c                            | 27 ++++++++++-----
 net/stream.c                            |  9 ++---
 net/stream_data.c                       | 10 +++---
 net/tap-bsd.c                           | 12 +++++--
 net/tap-linux.c                         |  8 ++++-
 net/tap-solaris.c                       |  7 +++-
 net/tap.c                               | 21 ++++--------
 qga/channel-posix.c                     |  7 +++-
 qga/commands-posix.c                    |  3 +-
 scsi/qemu-pr-helper.c                   |  4 +++
 tests/qtest/fuzz/virtio_net_fuzz.c      |  2 +-
 tests/qtest/tpm-emu.c                   |  1 +
 tests/qtest/vhost-user-test.c           |  3 +-
 tests/unit/socket-helpers.c             |  5 ++-
 tests/unit/test-crypto-tlssession.c     |  8 ++---
 tests/unit/test-io-channel-socket.c     |  1 +
 tests/unit/test-iov.c                   |  5 +--
 ui/input-linux.c                        |  3 +-
 util/event_notifier-posix.c             |  5 +--
 util/main-loop.c                        |  6 +++-
 util/oslib-posix.c                      | 27 +++++++++------
 util/oslib-win32.c                      | 25 ++++++--------
 util/vhost-user-server.c                |  9 +++--
 45 files changed, 244 insertions(+), 165 deletions(-)

-- 
2.48.1
Re: [PATCH 00/10] io: deal with blocking/non-blocking fds
Posted by Lei Yang 1 day, 21 hours ago
Tested the current series of patches, mixed with patches from series
[1] and [2], and the virtio-net regression tests passed. I also tested
local VM migration under multiple NIC queues enabled and disabled, it
also passed.

[1] https://patchwork.ozlabs.org/project/qemu-devel/cover/20250903124934.1169899-1-vsementsov@yandex-team.ru/
[2] https://patchwork.ozlabs.org/project/qemu-devel/cover/20250903133706.1177633-1-vsementsov@yandex-team.ru/

Tested-by: Lei Yang <leiyang@redhat.com>

On Wed, Sep 3, 2025 at 5:46 PM Vladimir Sementsov-Ogievskiy
<vsementsov@yandex-team.ru> wrote:
>
> Hi all!
>
> The series brings two things:
>
> 1. unify code which sets fds blocking/non-blocking through the whole
> source
>
> 2. for fds, which comes from qio_channel_readv_full(), stop making
> them blocking in generic code, and move this logic to the callers,
> all except coming from migration qemu-file (see last patch)
>
> Vladimir Sementsov-Ogievskiy (10):
>   io/channel: document how qio_channel_readv_full() handles fds
>   char-socket: rework tcp_chr_recv()
>   util: add qemu_set_blocking() function
>   util: drop qemu_socket_set_nonblock()
>   util: drop qemu_socket_try_set_nonblock()
>   util: drop qemu_socket_set_block()
>   use qemu_set_blocking instead of g_unix_set_fd_nonblocking
>   oslib-posix: add qemu_fds_set_blocking() helper
>   qio_channel_readv_full(): move setting fd blocking to callers
>   migration/qemu-file: don't make incoming fds blocking again
>
>  chardev/char-fd.c                       |  4 +--
>  chardev/char-pty.c                      |  3 +-
>  chardev/char-serial.c                   |  3 +-
>  chardev/char-socket.c                   | 45 ++++++++++++-------------
>  chardev/char-stdio.c                    |  3 +-
>  contrib/ivshmem-server/ivshmem-server.c |  5 ++-
>  hw/hyperv/syndbg.c                      |  4 ++-
>  hw/input/virtio-input-host.c            |  3 +-
>  hw/misc/ivshmem-flat.c                  |  4 ++-
>  hw/misc/ivshmem-pci.c                   |  8 ++++-
>  hw/remote/mpqemu-link.c                 |  3 ++
>  hw/vfio-user/proxy.c                    |  4 +++
>  hw/virtio/vhost-user.c                  | 10 +++++-
>  hw/virtio/vhost-vsock.c                 |  8 ++---
>  include/io/channel.h                    | 12 +++++++
>  include/qemu/osdep.h                    |  8 +++++
>  include/qemu/sockets.h                  |  3 --
>  io/channel-command.c                    |  9 +++--
>  io/channel-file.c                       |  3 +-
>  io/channel-socket.c                     | 26 +++++++-------
>  net/dgram.c                             | 28 ++++++++-------
>  net/l2tpv3.c                            |  5 +--
>  net/socket.c                            | 27 ++++++++++-----
>  net/stream.c                            |  9 ++---
>  net/stream_data.c                       | 10 +++---
>  net/tap-bsd.c                           | 12 +++++--
>  net/tap-linux.c                         |  8 ++++-
>  net/tap-solaris.c                       |  7 +++-
>  net/tap.c                               | 21 ++++--------
>  qga/channel-posix.c                     |  7 +++-
>  qga/commands-posix.c                    |  3 +-
>  scsi/qemu-pr-helper.c                   |  4 +++
>  tests/qtest/fuzz/virtio_net_fuzz.c      |  2 +-
>  tests/qtest/tpm-emu.c                   |  1 +
>  tests/qtest/vhost-user-test.c           |  3 +-
>  tests/unit/socket-helpers.c             |  5 ++-
>  tests/unit/test-crypto-tlssession.c     |  8 ++---
>  tests/unit/test-io-channel-socket.c     |  1 +
>  tests/unit/test-iov.c                   |  5 +--
>  ui/input-linux.c                        |  3 +-
>  util/event_notifier-posix.c             |  5 +--
>  util/main-loop.c                        |  6 +++-
>  util/oslib-posix.c                      | 27 +++++++++------
>  util/oslib-win32.c                      | 25 ++++++--------
>  util/vhost-user-server.c                |  9 +++--
>  45 files changed, 244 insertions(+), 165 deletions(-)
>
> --
> 2.48.1
>
>