[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 08/10] Use g_unix_set_fd_nonblocking()
From: |
marcandre . lureau |
Subject: |
[PATCH 08/10] Use g_unix_set_fd_nonblocking() |
Date: |
Fri, 22 Apr 2022 12:36:37 +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>
---
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..a1cd3dcc51cf 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 df21c2583e1f..21d40b2f1154 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 (!g_unix_open_pipe(fds, FD_CLOEXEC, NULL)) {
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..60ac77602bbb 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
- [PATCH 02/10] Use QEMU_SANITIZE_ADDRESS, (continued)
- [PATCH 02/10] Use QEMU_SANITIZE_ADDRESS, marcandre . lureau, 2022/04/22
- [PATCH 03/10] include: move qemu_*_exec_dir() to cutils, marcandre . lureau, 2022/04/22
- [PATCH 04/10] tests: move libqtest.h back under qtest/, marcandre . lureau, 2022/04/22
- [PATCH 05/10] libqtest: split QMP part in libqmp, marcandre . lureau, 2022/04/22
- [PATCH 06/10] Replace qemu_pipe() with g_unix_open_pipe(), marcandre . lureau, 2022/04/22
- [PATCH 07/10] tests: make libqmp buildable for win32, marcandre . lureau, 2022/04/22
- [PATCH 08/10] Use g_unix_set_fd_nonblocking(),
marcandre . lureau <=
- [PATCH 09/10] block: move fcntl_setfl(), marcandre . lureau, 2022/04/22
- [PATCH 10/10] util/win32: simplify qemu_get_local_state_dir(), marcandre . lureau, 2022/04/22