qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] vhost-user: support any POSIX system (tested on macOS and FreeBSD)
@ 2024-02-28 11:47 Stefano Garzarella
  2024-02-28 11:47 ` [PATCH 1/9] libvhost-user: set msg.msg_control to NULL when it is empty Stefano Garzarella
                   ` (9 more replies)
  0 siblings, 10 replies; 19+ messages in thread
From: Stefano Garzarella @ 2024-02-28 11:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, qemu-block, Daniel P. Berrangé, Thomas Huth,
	Michael S. Tsirkin, Jason Wang, Philippe Mathieu-Daudé,
	Marc-André Lureau, Markus Armbruster, Eric Blake, Coiby Xu,
	slp, Eduardo Habkost, Hanna Reitz, Igor Mammedov, Raphael Norwitz,
	Kevin Wolf, David Hildenbrand, stefanha, gmaglione,
	Stefano Garzarella

The vhost-user protocol is not really Linux-specific, so let's try support
QEMU's frontends and backends (including libvhost-user) in any POSIX system
with this series. The main use case is to be able to use virtio devices that
we don't have built-in in QEMU (e.g. virtiofsd, vhost-user-vsock, etc.) even
in non-Linux systems.

The first 5 patches are more like fixes discovered at runtime on macOS or
FreeBSD that could go even independently of this series.

Patches 6, 7, and 8 enable building of frontends and backends (including
libvhost-user) with associated code changes to succeed in compilation.

The latest patch (9) adds support for the POSIX shm_open() API to create
shared memory which is identified by an fd that can be shared with vhost-user
backends. This is useful on those systems (like macOS) where we don't have
memfd_create() or special filesystems like "/dev/shm".

I put the whole series in RFC because I have some questions especially in
patch 6 and 9, but in general any comment/suggestion/test are really welcome.

Maybe the first 5 patches can go separately, but I only discovered those
problems after testing patches 6 - 9, so I have included them in this series
for now. Please let me know if you prefer that I send them separately.

For now I tested this series using vhost-user-blk and QSD on
macOS Sonoma 14.3.1 (aarch64), FreeBSD 14 (x86_64), and Fedora 39 (x86_64)
in this way:

- Start vhost-user-blk or QSD (same commands for all systems)

  vhost-user-blk -s /tmp/vhost.socket \
    -b Fedora-Cloud-Base-39-1.5.x86_64.raw

  qemu-storage-daemon \
    --blockdev file,filename=Fedora-Cloud-Base-39-1.5.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

- macOS (aarch64): start QEMU (using hvf accelerator)

  qemu-system-aarch64 -smp 2 -cpu host -M virt,accel=hvf,memory-backend=mem \
    -drive file=./build/pc-bios/edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on \
    -device virtio-net-device,netdev=net0 -netdev user,id=net0 \
    -device ramfb -device usb-ehci -device usb-kbd \
    -object memory-backend-file,mem-path="/mem0",shm=on,share=on,id=mem,size=512M \
    -device vhost-user-blk-pci,num-queues=1,disable-legacy=on,chardev=char0 \
    -chardev socket,id=char0,path=/tmp/vhost.socket

- FreeBSD (x86_64): start QEMU (no accelerators available)

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

- Fedora (x86_64): start QEMU (using kvm accelerator)

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

Thanks,
Stefano

Stefano Garzarella (9):
  libvhost-user: set msg.msg_control to NULL when it is empty
  libvhost-user: fail vu_message_write() if sendmsg() is failing
  libvhost-user: mask F_INFLIGHT_SHMFD if memfd is not supported
  vhost-user-server: don't abort if we can't set fd non-blocking
  contrib/vhost-user-blk: fix bind() using the right size of the address
  vhost-user: enable frontends on any POSIX system
  libvhost-user: enable it on any POSIX system
  contrib/vhost-user-blk: enabled it on any POSIX system
  hostmem-file: support POSIX shm_open()

 meson.build                               |  5 +-
 qapi/qom.json                             |  4 ++
 subprojects/libvhost-user/libvhost-user.h |  2 +-
 backends/hostmem-file.c                   | 57 ++++++++++++++++-
 contrib/vhost-user-blk/vhost-user-blk.c   | 23 +++++--
 hw/net/vhost_net.c                        |  8 ++-
 subprojects/libvhost-user/libvhost-user.c | 76 ++++++++++++++++++++++-
 util/vhost-user-server.c                  |  6 +-
 backends/meson.build                      |  2 +-
 hw/block/Kconfig                          |  2 +-
 qemu-options.hx                           | 10 ++-
 util/meson.build                          |  4 +-
 12 files changed, 179 insertions(+), 20 deletions(-)

-- 
2.43.2



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2024-02-29 11:02 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-28 11:47 [PATCH 0/9] vhost-user: support any POSIX system (tested on macOS and FreeBSD) Stefano Garzarella
2024-02-28 11:47 ` [PATCH 1/9] libvhost-user: set msg.msg_control to NULL when it is empty Stefano Garzarella
2024-02-28 11:47 ` [PATCH 2/9] libvhost-user: fail vu_message_write() if sendmsg() is failing Stefano Garzarella
2024-02-28 11:47 ` [PATCH 3/9] libvhost-user: mask F_INFLIGHT_SHMFD if memfd is not supported Stefano Garzarella
2024-02-28 11:47 ` [PATCH 4/9] vhost-user-server: don't abort if we can't set fd non-blocking Stefano Garzarella
2024-02-28 11:47 ` [PATCH 5/9] contrib/vhost-user-blk: fix bind() using the right size of the address Stefano Garzarella
2024-02-28 11:47 ` [PATCH 6/9] vhost-user: enable frontends on any POSIX system Stefano Garzarella
2024-02-28 11:47 ` [PATCH 7/9] libvhost-user: enable it " Stefano Garzarella
2024-02-28 11:47 ` [PATCH 8/9] contrib/vhost-user-blk: enabled " Stefano Garzarella
2024-02-28 11:47 ` [PATCH 9/9] hostmem-file: support POSIX shm_open() Stefano Garzarella
2024-02-28 12:01   ` David Hildenbrand
2024-02-29  8:46     ` Stefano Garzarella
2024-02-28 12:08   ` Daniel P. Berrangé
2024-02-29  8:49     ` Stefano Garzarella
2024-02-28 12:32   ` Markus Armbruster
2024-02-29  8:57     ` Stefano Garzarella
2024-02-29 10:28       ` Markus Armbruster
2024-02-29 11:01         ` Stefano Garzarella
2024-02-28 11:51 ` [PATCH 0/9] vhost-user: support any POSIX system (tested on macOS and FreeBSD) Stefano Garzarella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).