[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 21/23] net: replace qemu_set_nonblock()
From: |
marcandre . lureau |
Subject: |
[PULL 21/23] net: replace qemu_set_nonblock() |
Date: |
Tue, 3 May 2022 17:00:21 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Those calls 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>
---
net/tap.c | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/net/tap.c b/net/tap.c
index 6190fa699d2f..b3ddfd4a74b1 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -619,7 +619,10 @@ int net_init_bridge(const Netdev *netdev, const char *name,
return -1;
}
- qemu_set_nonblock(fd);
+ if (!g_unix_set_fd_nonblocking(fd, true, NULL)) {
+ error_setg_errno(errp, errno, "Failed to set FD nonblocking");
+ return -1;
+ }
vnet_hdr = tap_probe_vnet_hdr(fd, errp);
if (vnet_hdr < 0) {
close(fd);
@@ -716,8 +719,6 @@ static void net_init_tap_one(const NetdevTapOptions *tap,
NetClientState *peer,
}
if (vhostfdname) {
- int ret;
-
vhostfd = monitor_fd_param(monitor_cur(), vhostfdname, &err);
if (vhostfd == -1) {
if (tap->has_vhostforce && tap->vhostforce) {
@@ -727,9 +728,8 @@ static void net_init_tap_one(const NetdevTapOptions *tap,
NetClientState *peer,
}
return;
}
- ret = qemu_try_set_nonblock(vhostfd);
- if (ret < 0) {
- error_setg_errno(errp, -ret, "%s: Can't use file descriptor
%d",
+ if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) {
+ error_setg_errno(errp, errno, "%s: Can't use file descriptor
%d",
name, fd);
return;
}
@@ -745,7 +745,10 @@ static void net_init_tap_one(const NetdevTapOptions *tap,
NetClientState *peer,
}
return;
}
- qemu_set_nonblock(vhostfd);
+ if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) {
+ error_setg_errno(errp, errno, "Failed to set FD nonblocking");
+ return;
+ }
}
options.opaque = (void *)(uintptr_t)vhostfd;
options.nvqs = 2;
@@ -832,9 +835,8 @@ int net_init_tap(const Netdev *netdev, const char *name,
return -1;
}
- ret = qemu_try_set_nonblock(fd);
- if (ret < 0) {
- error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
+ if (!g_unix_set_fd_nonblocking(fd, true, NULL)) {
+ error_setg_errno(errp, errno, "%s: Can't use file descriptor %d",
name, fd);
close(fd);
return -1;
@@ -889,9 +891,9 @@ int net_init_tap(const Netdev *netdev, const char *name,
goto free_fail;
}
- ret = qemu_try_set_nonblock(fd);
- if (ret < 0) {
- error_setg_errno(errp, -ret, "%s: Can't use file descriptor
%d",
+ ret = g_unix_set_fd_nonblocking(fd, true, NULL);
+ if (!ret) {
+ error_setg_errno(errp, errno, "%s: Can't use file descriptor
%d",
name, fd);
goto free_fail;
}
@@ -946,7 +948,10 @@ free_fail:
return -1;
}
- qemu_set_nonblock(fd);
+ if (!g_unix_set_fd_nonblocking(fd, true, NULL)) {
+ error_setg_errno(errp, errno, "Failed to set FD nonblocking");
+ return -1;
+ }
vnet_hdr = tap_probe_vnet_hdr(fd, errp);
if (vnet_hdr < 0) {
close(fd);
--
2.36.0.44.g0f828332d5ac
- [PULL 10/23] tests: replace pipe() with g_unix_open_pipe(CLOEXEC), (continued)
- [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
- [PULL 17/23] io: replace qemu_set{_non}block(), marcandre . lureau, 2022/05/03
- [PULL 23/23] util: rename qemu_*block() socket functions, marcandre . lureau, 2022/05/03
- [PULL 21/23] net: replace qemu_set_nonblock(),
marcandre . lureau <=
- [PULL 18/23] qga: replace qemu_set_nonblock(), marcandre . lureau, 2022/05/03
- [PULL 15/23] io: make qio_channel_command_new_pid() static, marcandre . lureau, 2022/05/03
- [PULL 11/23] os-posix: replace pipe()+cloexec with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/05/03
- [PULL 00/23] Misc patches, marcandre . lureau, 2022/05/03
- [PULL 19/23] hw: replace qemu_set_nonblock(), marcandre . lureau, 2022/05/03
- [PULL 09/23] qga: replace pipe() with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/05/03
- Re: [PULL 00/23] Misc patches, Richard Henderson, 2022/05/03
- [PULL 11/23] os-posix: replace pipe()+cloexec with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/05/03
- [PULL 03/23] tests: move libqtest.h back under qtest/, marcandre . lureau, 2022/05/03
- [PULL 01/23] Use QEMU_SANITIZE_THREAD, marcandre . lureau, 2022/05/03