]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
vhost-user-test: no set non-blocking for cal fd less than 0.
authorYuxue Liu <yuxue.liu@jaguarmicro.com>
Thu, 11 Apr 2024 07:35:55 +0000 (15:35 +0800)
committerMichael Tokarev <mjt@tls.msk.ru>
Thu, 18 Sep 2025 08:04:46 +0000 (11:04 +0300)
In the scenario where vhost-user sets eventfd to -1,
qemu_chr_fe_get_msgfds retrieves fd as -1. When vhost_user_read
receives, it does not perform blocking operations on the descriptor
with fd=-1, so non-blocking operations should not be performed here
either.This is a normal use case. Calling g_unix_set_fd_nonblocking
at this point will cause the test to interrupt.

When vhost_user_write sets the call fd to -1, it sets the number of
fds to 0, so the fds obtained by qemu_chr_fe_get_msgfds will also
be 0.

Signed-off-by: Yuxue Liu <yuxue.liu@jaguarmicro.com>
Message-Id: <20240411073555.1357-1-yuxue.liu@jaguarmicro.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit f72fc16910c8f44edf052f52672e0e63bbbc773c)
(Mjt: pick this trivial focused change up for 7.2.x so that subsequent change(s) in this area apply cleanly)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
tests/qtest/vhost-user-test.c

index e4f95b2858f038c958f8b98a6079e33650ee91e4..6d9e53ff07a2c8d27bf8c10080dd9df40036cbe3 100644 (file)
@@ -456,7 +456,10 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
     case VHOST_USER_SET_VRING_KICK:
     case VHOST_USER_SET_VRING_CALL:
         /* consume the fd */
-        qemu_chr_fe_get_msgfds(chr, &fd, 1);
+        if (!qemu_chr_fe_get_msgfds(chr, &fd, 1) && fd < 0) {
+            qos_printf("call fd: %d, do not set non-blocking\n", fd);
+            break;
+        }
         /*
          * This is a non-blocking eventfd.
          * The receive function forces it to be blocking,