Skip to content

vhost-user: another try at supporting any POSIX system

Tim Pambor qemu-devel vhost-user 2 versions – In review

Get series with b4
b4 am [email protected] change-id 20261022-vhost-user-posix-e7b999aa751d

Versions newest first

  1. v2 Latest9 patches 1 replyIn review
  2. v18 patches 14 repliesSuperseded

Changes in v2 from the cover letter · 16 lines

- Moved "libvhost-user: detect memfd support with a link test" to the
front of the series.
- Added "libvhost-user: detect eventfd support with a link test".
- Replaced the library-owned self-kick notifier in libvhost-user with a
per-ring flag; the handlers of started rings now run at the end of
vu_dispatch(), after the reply has been sent.
- Dropped "io/channel-socket: only clear O_NONBLOCK on received fds if
set" and instead reimplemented qemu_set_blocking() with fcntl(), so
F_SETFL is only issued when O_NONBLOCK actually changes.
- vhost_net.c: replaced VHOST_FILE_UNBIND with -1 and dropped the
Linux header include instead of defining the constant for other
systems.
- Added a comment and an assert to "vhost-user: kick via
event_notifier_set()".
- New CI run: https://gitlab.com/tpambor/qemu/-/pipelines/3007880563
- Link to v1: https://lore.kernel.org/qemu-devel/[email protected]

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9libvhost-user: detect memfd support with a link testsubprojects/libvhost-user/libvhost-user.c subprojects/libvhost-user/meson.build+17 -90 replies
2/9libvhost-user: detect eventfd support with a link testsubprojects/libvhost-user/libvhost-user.c subprojects/libvhost-user/meson.build+22 -10 replies
3/9vhost-user: kick via event_notifier_set()hw/virtio/vhost-user.c+10 -90 replies
4/9libvhost-user: run handlers of started rings after the replysubprojects/libvhost-user/libvhost-user.c subprojects/libvhost-user/libvhost-user.h+32 -130 replies
5/9util/oslib-posix: implement qemu_set_blocking() with fcntl()util/oslib-posix.c+19 -70 replies
6/9chardev/char-socket: detect peer close portablychardev/char-socket.c+59 -190 replies
7/9vhost-user: enable frontends on any POSIX systemhw/block/Kconfig hw/net/vhost_net.c meson.build+2 -41 reply
8/9libvhost-user: enable it on any POSIX systemmeson.build subprojects/libvhost-user/libvhost-user.c subprojects/libvhost-user/libvhost-user.h+43 -30 replies
9/9contrib/vhost-user-blk: enable it on any POSIX systemcontrib/vhost-user-blk/vhost-user-blk.c meson.build util/meson.build+17 -30 replies

Reviews trailers per patch

3 of 9 patches have a Reviewed-by or Acked-by.

PatchStefano GarzarellaPhilippe Mathieu-DaudéStefan Hajnoczi
1/9
2/9
3/9
4/9
5/9
6/9
7/9Co-authored-by R-b
8/9R-b T-b A-b
9/9R-b T-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/9] vhost-user: another try at supporting any POSIX system

This series continues the work started by Stefano [1] to add support for any POSIX system to vhost-user.

Three patches from his original series were never applied due to failing tests [2]. I was able to reproduce these test failures on current master.

Patch 6 contains a fix for this problem. Patches 1-5 fix further issues I came across while testing, mostly on macOS. Patches 7-9 are the three patches from Stefano's series; patch 7 drops VHOST_FILE_UNBIND as discussed in v1, the other two are unmodified.

I have tested this patch series on Ubuntu 24.04, macOS 15, FreeBSD 14.2 and OpenBSD 7.7. On all platforms the tests are now passing. In addition, on these platforms I have tested successfully booting a Fedora image with

  qemu-storage-daemon \
    --blockdev file,filename=Fedora-Cloud-Base-Generic-44-1.7.x86_64.qcow2,node-name=file \
    --blockdev qcow2,file=file,node-name=qcow2 \
    --export vhost-user-blk,addr.type=unix,addr.path=/tmp/vhost.socket,id=vub,num-queues=1,node-name=qcow2,writable=on

  qemu-system-x86_64 -smp 2 -M q35,memory-backend=mem \
    -object memory-backend-shm,id=mem,size="512M" \
    -device vhost-user-blk-pci,num-queues=1,chardev=char0 \
    -chardev socket,id=char0,path=/tmp/vhost.socket

Full CI run: https://gitlab.com/tpambor/qemu/-/pipelines/3007880563

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/suvpzkb3ppdodjdyo5zcpngz5mwrrlq3nfowemh4tqjghbc4si@hzrsr23fganv/

---
Changes in v2:
- Moved "libvhost-user: detect memfd support with a link test" to the
front of the series.
- Added "libvhost-user: detect eventfd support with a link test".
- Replaced the library-owned self-kick notifier in libvhost-user with a
per-ring flag; the handlers of started rings now run at the end of
vu_dispatch(), after the reply has been sent.
- Dropped "io/channel-socket: only clear O_NONBLOCK on received fds if
set" and instead reimplemented qemu_set_blocking() with fcntl(), so
F_SETFL is only issued when O_NONBLOCK actually changes.
- vhost_net.c: replaced VHOST_FILE_UNBIND with -1 and dropped the
Linux header include instead of defining the constant for other
systems.
- Added a comment and an assert to "vhost-user: kick via
event_notifier_set()".
- New CI run: https://gitlab.com/tpambor/qemu/-/pipelines/3007880563
- Link to v1: https://lore.kernel.org/qemu-devel/[email protected]

To: [email protected]
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Stefano Garzarella <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Marc-André Lureau <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Hanna Reitz <[email protected]>
Cc: Jason Wang <[email protected]>
Cc: Pierrick Bouvier <[email protected]>
Cc: [email protected]
Cc: Raphael Norwitz <[email protected]>
Cc: Brad Smith <[email protected]>
Cc: [email protected]
Cc: Philippe Mathieu-Daudé <[email protected]>
Cc: Stefan Hajnoczi <[email protected]>

---
Stefano Garzarella (2):
libvhost-user: enable it on any POSIX system contrib/vhost-user-blk: enable it on any POSIX system

Tim Pambor (7):
libvhost-user: detect memfd support with a link test
libvhost-user: detect eventfd support with a link test
vhost-user: kick via event_notifier_set()
libvhost-user: run handlers of started rings after the reply util/oslib-posix: implement qemu_set_blocking() with fcntl() chardev/char-socket: detect peer close portably
vhost-user: enable frontends on any POSIX system

 chardev/char-socket.c                     |  78 +++++++++++++++-----
 contrib/vhost-user-blk/vhost-user-blk.c   |  14 ++++
 hw/block/Kconfig                          |   2 +-
 hw/net/vhost_net.c                        |   3 +-
 hw/virtio/vhost-user.c                    |  19 ++---
 meson.build                               |   5 +-
 subprojects/libvhost-user/libvhost-user.c | 118 ++++++++++++++++++++++++------
 subprojects/libvhost-user/libvhost-user.h |   3 +-
 subprojects/libvhost-user/meson.build     |  17 ++++-
 util/meson.build                          |   4 +-
 util/oslib-posix.c                        |  26 +++++--
 11 files changed, 221 insertions(+), 68 deletions(-)

---
base-commit: a19f59a72d96056d9a8f48cf6c77f5787491e414
change-id: 20261022-vhost-user-posix-e7b999aa751d

Best regards,

Signature · 1 line
Tim Pambor <[email protected]>