[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/23] Use g_unix_set_fd_nonblocking()
From: |
marcandre . lureau |
Subject: |
[PULL 05/23] Use g_unix_set_fd_nonblocking() |
Date: |
Tue, 3 May 2022 17:00:05 +0400 |
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>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
hw/misc/ivshmem.c | 2 +-
util/event_notifier-posix.c | 6 ++----
util/main-loop.c | 2 +-
3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index e7c0099bdaf6..8270db53cda7 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -537,7 +537,7 @@ static void process_msg_connect(IVShmemState *s, uint16_t
posn, int fd,
IVSHMEM_DPRINTF("eventfds[%d][%d] = %d\n", posn, vector, fd);
event_notifier_init_fd(&peer->eventfds[vector], fd);
- fcntl_setfl(fd, O_NONBLOCK); /* msix/irqfd poll non block */
+ g_unix_set_fd_nonblocking(fd, true, NULL); /* msix/irqfd poll non block */
if (posn == s->vm_id) {
setup_interrupt(s, vector, errp);
diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c
index 8dc30c51414d..2aa14eabb38e 100644
--- a/util/event_notifier-posix.c
+++ b/util/event_notifier-posix.c
@@ -52,13 +52,11 @@ int event_notifier_init(EventNotifier *e, int active)
if (qemu_pipe(fds) < 0) {
return -errno;
}
- ret = fcntl_setfl(fds[0], O_NONBLOCK);
- if (ret < 0) {
+ if (!g_unix_set_fd_nonblocking(fds[0], true, NULL)) {
ret = -errno;
goto fail;
}
- ret = fcntl_setfl(fds[1], O_NONBLOCK);
- if (ret < 0) {
+ if (!g_unix_set_fd_nonblocking(fds[1], true, NULL)) {
ret = -errno;
goto fail;
}
diff --git a/util/main-loop.c b/util/main-loop.c
index b7b0ce4ca087..9afac10dff0f 100644
--- a/util/main-loop.c
+++ b/util/main-loop.c
@@ -114,7 +114,7 @@ static int qemu_signal_init(Error **errp)
return -errno;
}
- fcntl_setfl(sigfd, O_NONBLOCK);
+ g_unix_set_fd_nonblocking(sigfd, true, NULL);
qemu_set_fd_handler(sigfd, sigfd_handler, NULL, (void *)(intptr_t)sigfd);
--
2.36.0.44.g0f828332d5ac
- [PULL 00/23] Misc patches, marcandre . lureau, 2022/05/03
- [PULL 16/23] chardev: replace qemu_set_nonblock(), marcandre . lureau, 2022/05/03
- [PULL 22/23] tests: replace qemu_set_nonblock(), marcandre . lureau, 2022/05/03
- [PULL 14/23] Replace fcntl(O_NONBLOCK) with g_unix_set_fd_nonblocking(), marcandre . lureau, 2022/05/03
- [PULL 04/23] libqtest: split QMP part in libqmp, marcandre . lureau, 2022/05/03
- [PULL 13/23] io: replace pipe() with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/05/03
- [PULL 08/23] util: replace pipe()+cloexec with g_unix_open_pipe(), marcandre . lureau, 2022/05/03
- [PULL 05/23] Use g_unix_set_fd_nonblocking(),
marcandre . lureau <=
- [PULL 02/23] Use QEMU_SANITIZE_ADDRESS, marcandre . lureau, 2022/05/03
- [PULL 12/23] virtiofsd: replace pipe() with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/05/03
- [PULL 10/23] tests: replace pipe() with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/05/03
- [PULL 01/23] Use QEMU_SANITIZE_THREAD, marcandre . lureau, 2022/05/03
- [PULL 07/23] Replace qemu_pipe() with g_unix_open_pipe(), marcandre . lureau, 2022/05/03
- [PULL 19/23] hw: replace qemu_set_nonblock(), marcandre . lureau, 2022/05/03
- [PULL 06/23] block: move fcntl_setfl(), marcandre . lureau, 2022/05/03
- [PULL 09/23] qga: replace pipe() with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/05/03
- [PULL 20/23] ui: replace qemu_set_nonblock(), marcandre . lureau, 2022/05/03
- [PULL 03/23] tests: move libqtest.h back under qtest/, marcandre . lureau, 2022/05/03