]> git.proxmox.com Git - mirror_qemu.git/commitdiff
chardev: replace qemu_set_nonblock()
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 25 Apr 2022 13:39:06 +0000 (17:39 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 3 May 2022 11:51:52 +0000 (15:51 +0400)
Those calls are either for non-socket fd, or are POSIX-specific. Use the
dedicated GLib API. (qemu_set_nonblock() is for socket-like)

(this is a preliminary patch before renaming qemu_set_nonblock())

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
chardev/char-fd.c
chardev/char-pty.c
chardev/char-serial.c
chardev/char-stdio.c

index 6ec9682b22f27f78f9fe9ed3bcb9f0ed190217bf..cf78454841741bb922a2885d443b9eec47f4c860 100644 (file)
@@ -212,8 +212,8 @@ void qemu_chr_open_fd(Chardev *chr,
     FDChardev *s = FD_CHARDEV(chr);
     g_autofree char *name = NULL;
 
-    if (fd_out >= 0) {
-        qemu_set_nonblock(fd_out);
+    if (fd_out >= 0 && !g_unix_set_fd_nonblocking(fd_out, true, NULL)) {
+        assert(!"Failed to set FD nonblocking");
     }
 
     if (fd_out == fd_in && fd_in >= 0) {
index 1e2863f532a8a9bfe9cd9da325024b8146d3f95a..53f25c6bbd0c7fdab2931273bbdfd8a51d7155a3 100644 (file)
@@ -324,7 +324,10 @@ static void char_pty_open(Chardev *chr,
     }
 
     close(slave_fd);
-    qemu_set_nonblock(master_fd);
+    if (!g_unix_set_fd_nonblocking(master_fd, true, NULL)) {
+        error_setg_errno(errp, errno, "Failed to set FD nonblocking");
+        return;
+    }
 
     chr->filename = g_strdup_printf("pty:%s", pty_name);
     qemu_printf("char device redirected to %s (label %s)\n",
index 7c3d84ae243e9fdea610673fe5acfd8dda10c516..4b0b83d5b45e82c2aa58819883d0472ee220f9ae 100644 (file)
@@ -271,7 +271,10 @@ static void qmp_chardev_open_serial(Chardev *chr,
     if (fd < 0) {
         return;
     }
-    qemu_set_nonblock(fd);
+    if (!g_unix_set_fd_nonblocking(fd, true, NULL)) {
+        error_setg_errno(errp, errno, "Failed to set FD nonblocking");
+        return;
+    }
     tty_serial_init(fd, 115200, 'N', 8, 1);
 
     qemu_chr_open_fd(chr, fd, fd);
index 403da308c980ebf24eaacb61cc2e77c6ffb5ad03..3c648678ab14c7bbbd802a0400e3d5625f81207b 100644 (file)
@@ -103,7 +103,10 @@ static void qemu_chr_open_stdio(Chardev *chr,
     stdio_in_use = true;
     old_fd0_flags = fcntl(0, F_GETFL);
     tcgetattr(0, &oldtty);
-    qemu_set_nonblock(0);
+    if (!g_unix_set_fd_nonblocking(0, true, NULL)) {
+        error_setg_errno(errp, errno, "Failed to set FD nonblocking");
+        return;
+    }
     atexit(term_exit);
 
     memset(&act, 0, sizeof(act));