[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/9] vhost-user-server: don't abort if we can't set fd non-blocki
From: |
Stefano Garzarella |
Subject: |
[PATCH 4/9] vhost-user-server: don't abort if we can't set fd non-blocking |
Date: |
Wed, 28 Feb 2024 12:47:54 +0100 |
From: Stefano Garzarella <stefanogarzarella@gmail.com>
In vhost-user-server we set all fd received from the other peer
in non-blocking mode. For some of them (e.g. memfd, shm_open, etc.)
if we fail, it's not really a problem, because we don't use these
fd with blocking operations, but only to map memory.
In these cases a failure is not bad, so let's just report a warning
instead of panicking if we fail to set some fd in non-blocking mode.
This for example occurs in macOS where setting shm_open() fd
non-blocking is failing (errno -25).
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
util/vhost-user-server.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/util/vhost-user-server.c b/util/vhost-user-server.c
index 3bfb1ad3ec..064999f0b7 100644
--- a/util/vhost-user-server.c
+++ b/util/vhost-user-server.c
@@ -66,7 +66,11 @@ static void vmsg_unblock_fds(VhostUserMsg *vmsg)
{
int i;
for (i = 0; i < vmsg->fd_num; i++) {
- qemu_socket_set_nonblock(vmsg->fds[i]);
+ int ret = qemu_socket_try_set_nonblock(vmsg->fds[i]);
+ if (ret) {
+ warn_report("Failed to set fd %d nonblock for request %d: %s",
+ vmsg->fds[i], vmsg->request, strerror(-ret));
+ }
}
}
--
2.43.2
- [PATCH 0/9] vhost-user: support any POSIX system (tested on macOS and FreeBSD), Stefano Garzarella, 2024/02/28
- [PATCH 1/9] libvhost-user: set msg.msg_control to NULL when it is empty, Stefano Garzarella, 2024/02/28
- [PATCH 2/9] libvhost-user: fail vu_message_write() if sendmsg() is failing, Stefano Garzarella, 2024/02/28
- [PATCH 4/9] vhost-user-server: don't abort if we can't set fd non-blocking,
Stefano Garzarella <=
- [PATCH 3/9] libvhost-user: mask F_INFLIGHT_SHMFD if memfd is not supported, Stefano Garzarella, 2024/02/28
- [PATCH 5/9] contrib/vhost-user-blk: fix bind() using the right size of the address, Stefano Garzarella, 2024/02/28
- [PATCH 6/9] vhost-user: enable frontends on any POSIX system, Stefano Garzarella, 2024/02/28
- [PATCH 8/9] contrib/vhost-user-blk: enabled it on any POSIX system, Stefano Garzarella, 2024/02/28
- [PATCH 7/9] libvhost-user: enable it on any POSIX system, Stefano Garzarella, 2024/02/28
- [PATCH 9/9] hostmem-file: support POSIX shm_open(), Stefano Garzarella, 2024/02/28