[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/23] hw: replace qemu_set_nonblock()
From: |
marcandre . lureau |
Subject: |
[PULL 19/23] hw: replace qemu_set_nonblock() |
Date: |
Tue, 3 May 2022 17:00:19 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Those calls are 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>
---
hw/input/virtio-input-host.c | 5 ++++-
hw/virtio/vhost-vsock.c | 11 +++++++----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/hw/input/virtio-input-host.c b/hw/input/virtio-input-host.c
index 137efba57b0f..fea7139382a1 100644
--- a/hw/input/virtio-input-host.c
+++ b/hw/input/virtio-input-host.c
@@ -114,7 +114,10 @@ static void virtio_input_host_realize(DeviceState *dev,
Error **errp)
error_setg_file_open(errp, errno, vih->evdev);
return;
}
- qemu_set_nonblock(vih->fd);
+ if (!g_unix_set_fd_nonblocking(vih->fd, true, NULL)) {
+ error_setg_errno(errp, errno, "Failed to set FD nonblocking");
+ goto err_close;
+ }
rc = ioctl(vih->fd, EVIOCGVERSION, &ver);
if (rc < 0) {
diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c
index 433d42d897df..714046210bd3 100644
--- a/hw/virtio/vhost-vsock.c
+++ b/hw/virtio/vhost-vsock.c
@@ -149,9 +149,8 @@ static void vhost_vsock_device_realize(DeviceState *dev,
Error **errp)
return;
}
- ret = qemu_try_set_nonblock(vhostfd);
- if (ret < 0) {
- error_setg_errno(errp, -ret,
+ if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) {
+ error_setg_errno(errp, errno,
"vhost-vsock: unable to set non-blocking mode");
return;
}
@@ -163,7 +162,11 @@ static void vhost_vsock_device_realize(DeviceState *dev,
Error **errp)
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;
+ }
}
vhost_vsock_common_realize(vdev, "vhost-vsock");
--
2.36.0.44.g0f828332d5ac
- [PULL 14/23] Replace fcntl(O_NONBLOCK) with g_unix_set_fd_nonblocking(), (continued)
- [PULL 14/23] Replace fcntl(O_NONBLOCK) with g_unix_set_fd_nonblocking(), marcandre . lureau, 2022/05/03
- [PULL 04/23] libqtest: split QMP part in libqmp, marcandre . lureau, 2022/05/03
- [PULL 13/23] io: replace pipe() with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/05/03
- [PULL 08/23] util: replace pipe()+cloexec with g_unix_open_pipe(), marcandre . lureau, 2022/05/03
- [PULL 05/23] Use g_unix_set_fd_nonblocking(), marcandre . lureau, 2022/05/03
- [PULL 02/23] Use QEMU_SANITIZE_ADDRESS, marcandre . lureau, 2022/05/03
- [PULL 12/23] virtiofsd: replace pipe() with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/05/03
- [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 <=
- [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, 2022/05/03
- [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