treewide: use qemu_set_blocking instead of g_unix_set_fd_nonblocking

Instead of open-coded g_unix_set_fd_nonblocking() calls, use
QEMU wrapper qemu_set_blocking().

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
[DB: fix missing closing ) in tap-bsd.c, remove now unused GError var]
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Vladimir Sementsov-Ogievskiy
2025-09-16 16:13:59 +03:00
committed by Daniel P. Berrangé
parent 5d1d32ce9d
commit 6f607941b1
21 changed files with 67 additions and 55 deletions
+10 -2
View File
@@ -98,7 +98,12 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
return -1;
}
}
g_unix_set_fd_nonblocking(fd, true, NULL);
if (!qemu_set_blocking(fd, false, errp)) {
close(fd);
return -1;
}
return fd;
}
@@ -189,7 +194,10 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
goto error;
}
g_unix_set_fd_nonblocking(fd, true, NULL);
if (!qemu_set_blocking(fd, false, errp)) {
goto error;
}
return fd;
error:
+6 -1
View File
@@ -124,7 +124,12 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
return -1;
}
pstrcpy(ifname, ifname_size, ifr.ifr_name);
g_unix_set_fd_nonblocking(fd, true, NULL);
if (!qemu_set_blocking(fd, false, errp)) {
close(fd);
return -1;
}
return fd;
}
+6 -1
View File
@@ -198,7 +198,12 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
return -1;
}
}
g_unix_set_fd_nonblocking(fd, true, NULL);
if (!qemu_set_blocking(fd, false, errp)) {
close(fd);
return -1;
}
return fd;
}
+6 -15
View File
@@ -627,8 +627,7 @@ int net_init_bridge(const Netdev *netdev, const char *name,
return -1;
}
if (!g_unix_set_fd_nonblocking(fd, true, NULL)) {
error_setg_errno(errp, errno, "Failed to set FD nonblocking");
if (!qemu_set_blocking(fd, false, errp)) {
return -1;
}
vnet_hdr = tap_probe_vnet_hdr(fd, errp);
@@ -729,9 +728,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
error_propagate(errp, err);
goto failed;
}
if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) {
error_setg_errno(errp, errno, "%s: Can't use file descriptor %d",
name, fd);
if (!qemu_set_blocking(vhostfd, false, errp)) {
goto failed;
}
} else {
@@ -741,8 +738,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
"tap: open vhost char device failed");
goto failed;
}
if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) {
error_setg_errno(errp, errno, "Failed to set FD nonblocking");
if (!qemu_set_blocking(vhostfd, false, errp)) {
goto failed;
}
}
@@ -839,9 +835,7 @@ int net_init_tap(const Netdev *netdev, const char *name,
return -1;
}
if (!g_unix_set_fd_nonblocking(fd, true, NULL)) {
error_setg_errno(errp, errno, "%s: Can't use file descriptor %d",
name, fd);
if (!qemu_set_blocking(fd, false, errp)) {
close(fd);
return -1;
}
@@ -895,10 +889,8 @@ int net_init_tap(const Netdev *netdev, const char *name,
goto free_fail;
}
if (!g_unix_set_fd_nonblocking(fd, true, NULL)) {
if (!qemu_set_blocking(fd, false, errp)) {
ret = -1;
error_setg_errno(errp, errno, "%s: Can't use file descriptor %d",
name, fd);
goto free_fail;
}
@@ -951,8 +943,7 @@ free_fail:
return -1;
}
if (!g_unix_set_fd_nonblocking(fd, true, NULL)) {
error_setg_errno(errp, errno, "Failed to set FD nonblocking");
if (!qemu_set_blocking(fd, false, errp)) {
return -1;
}
vnet_hdr = tap_probe_vnet_hdr(fd, errp);