[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 19/26] chardev: replace qemu_set_nonblock()
From: |
marcandre . lureau |
Subject: |
[PATCH v2 19/26] chardev: replace qemu_set_nonblock() |
Date: |
Tue, 26 Apr 2022 13:27:08 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Those calls are either for non-socket fd, or are POSIX-specific. Use the
dedicated GLib API. (qemu_set_nonblock() is for socket-like)
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
chardev/char-fd.c | 4 ++--
chardev/char-pty.c | 5 ++++-
chardev/char-serial.c | 5 ++++-
chardev/char-stdio.c | 5 ++++-
4 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/chardev/char-fd.c b/chardev/char-fd.c
index 6ec9682b22f2..cf7845484174 100644
--- a/chardev/char-fd.c
+++ b/chardev/char-fd.c
@@ -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) {
diff --git a/chardev/char-pty.c b/chardev/char-pty.c
index 1e2863f532a8..53f25c6bbd0c 100644
--- a/chardev/char-pty.c
+++ b/chardev/char-pty.c
@@ -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",
diff --git a/chardev/char-serial.c b/chardev/char-serial.c
index 7c3d84ae243e..4b0b83d5b45e 100644
--- a/chardev/char-serial.c
+++ b/chardev/char-serial.c
@@ -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);
diff --git a/chardev/char-stdio.c b/chardev/char-stdio.c
index 403da308c980..3c648678ab14 100644
--- a/chardev/char-stdio.c
+++ b/chardev/char-stdio.c
@@ -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));
--
2.36.0
- [PATCH v2 12/26] qga: replace pipe() with g_unix_open_pipe(CLOEXEC), (continued)
- [PATCH v2 12/26] qga: replace pipe() with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/04/26
- [PATCH v2 14/26] os-posix: replace pipe()+cloexec with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/04/26
- [PATCH v2 17/26] Replace fcntl(0_NONBLOCK) with g_unix_set_fd_nonblocking(), marcandre . lureau, 2022/04/26
- [PATCH v2 16/26] io: replace pipe() with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/04/26
- [PATCH v2 15/26] virtiofsd: replace pipe() with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/04/26
- [PATCH v2 19/26] chardev: replace qemu_set_nonblock(),
marcandre . lureau <=
- [PATCH v2 18/26] io: make qio_channel_command_new_pid() static, marcandre . lureau, 2022/04/26
- [PATCH v2 20/26] io: replace qemu_set{_non}block(), marcandre . lureau, 2022/04/26
- [PATCH v2 22/26] hw: replace qemu_set_nonblock(), marcandre . lureau, 2022/04/26
- [PATCH v2 21/26] qga: replace qemu_set_nonblock(), marcandre . lureau, 2022/04/26
- [PATCH v2 23/26] ui: replace qemu_set_nonblock(), marcandre . lureau, 2022/04/26
- [PATCH v2 24/26] net: replace qemu_set_nonblock(), marcandre . lureau, 2022/04/26
- [PATCH v2 25/26] tests: replace qemu_set_nonblock(), marcandre . lureau, 2022/04/26