Use g_unix_set_fd_nonblocking()
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 29 Mar 2022 11:25:05 +0000 (15:25 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 3 May 2022 11:17:30 +0000 (15:17 +0400)
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
util/event_notifier-posix.c
util/main-loop.c

index e7c0099bdaf6578c97dd1f5304f029e9d55e8c00..8270db53cda7bd49f619c9f19d2c443dfeb0af40 100644 (file)
@@ -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);
index 8dc30c51414d915653bf073cd38ee44303c940b5..2aa14eabb38eec6e9de35a019b531e3a49a404cb 100644 (file)
@@ -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;
         }
index b7b0ce4ca08797c01c43457f6276f4ecaf7580cb..9afac10dff0fdeb0aee68adbb73b034dffba10e5 100644 (file)
@@ -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);