On Fri, Apr 22, 2022 at 12:36:37PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> API available since glib 2.30. It also preserves errno.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> hw/misc/ivshmem.c | 2 +-
> util/event_notifier-posix.c | 6 ++----
> util/main-loop.c | 2 +-
> 3 files changed, 4 insertions(+), 6 deletions(-)
There are many more places in QEMU setting O_NONBLOCK.
$ git grep '\bO_NONBLOCK' | grep -i setfl
hw/misc/ivshmem.c: fcntl_setfl(fd, O_NONBLOCK); /* msix/irqfd poll non block */
hw/rdma/rdma_backend.c: rc = fcntl(backend_dev->channel->fd, F_SETFL, flags | O_NONBLOCK);
linux-user/syscall.c: if (fcntl(fd, F_SETFL, O_NONBLOCK | flags) == -1) {
net/tap-bsd.c: fcntl(fd, F_SETFL, O_NONBLOCK);
net/tap-bsd.c: fcntl(fd, F_SETFL, O_NONBLOCK);
net/tap-linux.c: fcntl(fd, F_SETFL, O_NONBLOCK);
net/tap-solaris.c: fcntl(fd, F_SETFL, O_NONBLOCK);
tests/qtest/fuzz/virtio_net_fuzz.c: fcntl(sockfds[0], F_SETFL, O_NONBLOCK);
tests/tcg/multiarch/linux-test.c: chk_error(fcntl(fds[0], F_SETFL, O_NONBLOCK));
tests/tcg/multiarch/linux-test.c: chk_error(fcntl(fds[1], F_SETFL, O_NONBLOCK));
tests/unit/test-iov.c: fcntl(sv[1], F_SETFL, O_RDWR|O_NONBLOCK);
tests/unit/test-iov.c: fcntl(sv[0], F_SETFL, O_RDWR|O_NONBLOCK);
util/event_notifier-posix.c: ret = fcntl_setfl(fds[0], O_NONBLOCK);
util/event_notifier-posix.c: ret = fcntl_setfl(fds[1], O_NONBLOCK);
util/main-loop.c: fcntl_setfl(sigfd, O_NONBLOCK);
util/oslib-posix.c: f = fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
util/oslib-posix.c: if (fcntl(fd, F_SETFL, f | O_NONBLOCK) == -1) {
As you may have guessed, the goal was to move fcntl_setfl() to block/, as done in next patch.
It looks like other callers generally do more than just setting nonblock, they need more careful review.
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 :|