This patch set introduces a slave message in vhost-user to allow slave to share its VFIO container fd to master and do the IOMMU programming based on virtio device's DMA address space for the VFIO groups inside this container in QEMU.
For the vhost-user backends which support vDPA, they could leverage this message to ask master to do IOMMU programming in QEMU for the vDPA device in backend. This is helpful to support vIOMMU in vDPA. Below are the simple steps to test this function: # Build the QEMU with trace support ./configure --enable-trace-backends=simple --target-list=x86_64-softmmu make # Set the events we want to trace echo vfio_new_container > /tmp/events echo vfio_free_container >> /tmp/events echo vfio_listener_region_add_ram >> /tmp/events echo vfio_listener_region_del >> /tmp/events # Launch vhost-user-bridge with VFIO enabled make tests/vhost-user-bridge ./tests/vhost-user-bridge -G /dev/vfio/$GROUP_NO # Launch QEMU on another terminal ./x86_64-softmmu/qemu-system-x86_64 \ -smp 4 -m 1024M -cpu host -enable-kvm \ -hda "$DISK" \ -object memory-backend-file,id=mem,size=1024M,mem-path=/dev/shm,share=on \ -numa node,memdev=mem -mem-prealloc \ -chardev socket,id=char0,path=/tmp/vubr.sock \ -netdev type=vhost-user,id=net0,chardev=char0 \ -device virtio-net-pci,netdev=net0,page-per-vq=on \ --trace events=/tmp/events # Dump the trace events ./scripts/simpletrace.py ./trace-events-all ./trace-"$QEMU_PID" More details can be found from the patches. Thanks! RFC -> RFC v2: - Share VFIO container fd instead of group fd to QEMU; - Extend libvhost-user and vhost-user-bridge for testing; Tiwei Bie (4): vfio: support creating VFIOContainer directly vhost-user: support programming VFIO container in master libvhost-user: support VFIO container message vhost-user-bridge: support VFIO container message contrib/libvhost-user/libvhost-user.c | 29 ++++- contrib/libvhost-user/libvhost-user.h | 12 ++ docs/interop/vhost-user.txt | 21 ++++ hw/vfio/common.c | 164 +++++++++++++++++++++++++- hw/vfio/trace-events | 2 + hw/virtio/vhost-user.c | 45 +++++++ include/hw/vfio/vfio-common.h | 9 ++ include/hw/virtio/vhost-user.h | 2 + tests/vhost-user-bridge.c | 63 +++++++++- 9 files changed, 343 insertions(+), 4 deletions(-) -- 2.18.0