docs/interop/vhost-user.rst | 104 ++++++++ hw/virtio/vhost-user-base.c | 46 +++- hw/virtio/vhost-user-test-device-pci.c | 42 +++- hw/virtio/vhost-user.c | 274 ++++++++++++++++++++++ hw/virtio/virtio-qmp.c | 3 + hw/virtio/virtio.c | 201 ++++++++++++++++ include/hw/virtio/vhost-backend.h | 10 + include/hw/virtio/vhost-user.h | 1 + include/hw/virtio/virtio.h | 136 +++++++++++ include/system/memory.h | 2 +- subprojects/libvhost-user/libvhost-user.c | 70 ++++++ subprojects/libvhost-user/libvhost-user.h | 54 +++++ system/memory.c | 14 ++ 13 files changed, 951 insertions(+), 6 deletions(-)
Hi all, v13->v14 - Switched F_SHMEM id to 21 to avoid collision after rebasing - Fixed all occurrences of shmem->mr.size to memory_region_size() - Other small fixes following reviews from previous version v12->v13 - SMEM_UNMAP spec update to explicitly state the use of VHOST_USER_PROTOCOL_F_REPLY_ACK for replies - Removed confusing remark for 0-sized regions in GET_SHMEM_CONFIG v11->v12 - Refined VIRTIO Shared Memory Region configuration mem size spec description - Removed unused name in vhost-user-base's vub_device_realize to avoid build error - Initialize shmem in vhost_user_backend_handle_shmem_unmap to avoid compiler being confused - Added stub for memory_region_init_ram_from_fd in memory.h for windows builds - Use memory_region_size for shmem_region handlers instead of accessing size member directly in shmem mrs v10->v11 - Rebase to grab commit fde5930cc37175cfcd0f03a089e26f4458a52311 and explicitly unset reply_ack on the SHMEM_MAP/UNMAP msg. - Mention mapping cleanup on device reset in the spec. This patch series implements dynamic fd-backed memory mapping support for vhost-user backends, enabling backends to dynamically request memory mappings and unmappings during runtime through the new VHOST_USER_BACKEND_SHMEM_MAP/UNMAP protocol messages. This feature benefits various VIRTIO devices that require dynamic shared memory management, including virtiofs (for DAX mappings), virtio-gpu (for resource sharing), and the recently standardized virtio-media. The implementation introduces a QOM-based architecture for managing shared memory lifecycle: - VirtioSharedMemoryMapping: an intermediate object that manages individual memory mappings by acting as generic container for regions declared in any vhost-user device type - Dynamic Mapping: backends can request mappings via SHMEM_MAP messages, with the frontend creating MemoryRegions from the provided file descriptors and adding them as subregions When a SHMEM_MAP request is received, the frontend: 1. Creates VirtioSharedMemoryMapping to manage the mapping lifecycle 2. Maps the provided fd with memory_region_init_ram_from_fd() 3. Creates a MemoryRegion backed by the mapped memory 4. Adds it as a subregion of the appropiate VIRTIO Shared Memory Region The QOM reference counting ensures automatic cleanup when mappings are removed or the device is destroyed. This patch also includes: - VHOST_USER_GET_SHMEM_CONFIG: a new frontend request allowing generic vhost-user devices to query shared memory configuration from backends at device initialization, enabling the generic vhost-user-device frontend to work with any backend regardless of specific shared memory requirements. The implementation has been tested with rust-vmm based backends. Albert Esteve (7): vhost-user: Add VirtIO Shared Memory map request vhost_user.rst: Align VhostUserMsg excerpt members vhost_user.rst: Add SHMEM_MAP/_UNMAP to spec vhost_user: Add frontend get_shmem_config command vhost_user.rst: Add GET_SHMEM_CONFIG message qmp: add shmem feature map vhost-user-device: Add shared memory BAR docs/interop/vhost-user.rst | 104 ++++++++ hw/virtio/vhost-user-base.c | 46 +++- hw/virtio/vhost-user-test-device-pci.c | 42 +++- hw/virtio/vhost-user.c | 274 ++++++++++++++++++++++ hw/virtio/virtio-qmp.c | 3 + hw/virtio/virtio.c | 201 ++++++++++++++++ include/hw/virtio/vhost-backend.h | 10 + include/hw/virtio/vhost-user.h | 1 + include/hw/virtio/virtio.h | 136 +++++++++++ include/system/memory.h | 2 +- subprojects/libvhost-user/libvhost-user.c | 70 ++++++ subprojects/libvhost-user/libvhost-user.h | 54 +++++ system/memory.c | 14 ++ 13 files changed, 951 insertions(+), 6 deletions(-) -- 2.52.0
On Wed, Mar 04, 2026 at 05:52:16PM +0100, Albert Esteve wrote: >Hi all, Thanks! This is now fully reviewed, Michael can we queue it? Thanks, Stefano > >v13->v14 >- Switched F_SHMEM id to 21 to avoid collision after rebasing >- Fixed all occurrences of shmem->mr.size to memory_region_size() >- Other small fixes following reviews from previous version >v12->v13 >- SMEM_UNMAP spec update to explicitly state the use of > VHOST_USER_PROTOCOL_F_REPLY_ACK for replies >- Removed confusing remark for 0-sized regions in > GET_SHMEM_CONFIG >v11->v12 >- Refined VIRTIO Shared Memory Region configuration mem size > spec description >- Removed unused name in vhost-user-base's vub_device_realize to > avoid build error >- Initialize shmem in vhost_user_backend_handle_shmem_unmap > to avoid compiler being confused >- Added stub for memory_region_init_ram_from_fd in memory.h > for windows builds >- Use memory_region_size for shmem_region handlers instead > of accessing size member directly in shmem mrs >v10->v11 >- Rebase to grab commit fde5930cc37175cfcd0f03a089e26f4458a52311 > and explicitly unset reply_ack on the SHMEM_MAP/UNMAP msg. >- Mention mapping cleanup on device reset in the spec. > >This patch series implements dynamic fd-backed memory mapping support >for vhost-user backends, enabling backends to dynamically request memory >mappings and unmappings during runtime through the new >VHOST_USER_BACKEND_SHMEM_MAP/UNMAP protocol messages. > >This feature benefits various VIRTIO devices that require dynamic shared >memory management, including virtiofs (for DAX mappings), virtio-gpu >(for resource sharing), and the recently standardized virtio-media. > >The implementation introduces a QOM-based architecture for managing >shared memory lifecycle: > >- VirtioSharedMemoryMapping: an intermediate object that manages > individual memory mappings by acting as generic container for regions > declared in any vhost-user device type >- Dynamic Mapping: backends can request mappings via SHMEM_MAP messages, > with the frontend creating MemoryRegions from the provided file > descriptors and adding them as subregions > >When a SHMEM_MAP request is received, the frontend: >1. Creates VirtioSharedMemoryMapping to manage the mapping lifecycle >2. Maps the provided fd with memory_region_init_ram_from_fd() >3. Creates a MemoryRegion backed by the mapped memory >4. Adds it as a subregion of the appropiate VIRTIO Shared Memory Region > >The QOM reference counting ensures automatic cleanup when mappings are >removed or the device is destroyed. > >This patch also includes: >- VHOST_USER_GET_SHMEM_CONFIG: a new frontend request allowing generic > vhost-user devices to query shared memory configuration from backends > at device initialization, enabling the generic vhost-user-device > frontend to work with any backend regardless of specific shared memory > requirements. > >The implementation has been tested with rust-vmm based backends. > >Albert Esteve (7): > vhost-user: Add VirtIO Shared Memory map request > vhost_user.rst: Align VhostUserMsg excerpt members > vhost_user.rst: Add SHMEM_MAP/_UNMAP to spec > vhost_user: Add frontend get_shmem_config command > vhost_user.rst: Add GET_SHMEM_CONFIG message > qmp: add shmem feature map > vhost-user-device: Add shared memory BAR > > docs/interop/vhost-user.rst | 104 ++++++++ > hw/virtio/vhost-user-base.c | 46 +++- > hw/virtio/vhost-user-test-device-pci.c | 42 +++- > hw/virtio/vhost-user.c | 274 ++++++++++++++++++++++ > hw/virtio/virtio-qmp.c | 3 + > hw/virtio/virtio.c | 201 ++++++++++++++++ > include/hw/virtio/vhost-backend.h | 10 + > include/hw/virtio/vhost-user.h | 1 + > include/hw/virtio/virtio.h | 136 +++++++++++ > include/system/memory.h | 2 +- > subprojects/libvhost-user/libvhost-user.c | 70 ++++++ > subprojects/libvhost-user/libvhost-user.h | 54 +++++ > system/memory.c | 14 ++ > 13 files changed, 951 insertions(+), 6 deletions(-) > >-- >2.52.0 >
On Thu, Mar 05, 2026 at 09:06:20AM +0100, Stefano Garzarella wrote: > On Wed, Mar 04, 2026 at 05:52:16PM +0100, Albert Esteve wrote: > > Hi all, > > Thanks! > > This is now fully reviewed, Michael can we queue it? > > Thanks, > Stefano yes, I tagged it already. > > > > v13->v14 > > - Switched F_SHMEM id to 21 to avoid collision after rebasing > > - Fixed all occurrences of shmem->mr.size to memory_region_size() > > - Other small fixes following reviews from previous version > > v12->v13 > > - SMEM_UNMAP spec update to explicitly state the use of > > VHOST_USER_PROTOCOL_F_REPLY_ACK for replies > > - Removed confusing remark for 0-sized regions in > > GET_SHMEM_CONFIG > > v11->v12 > > - Refined VIRTIO Shared Memory Region configuration mem size > > spec description > > - Removed unused name in vhost-user-base's vub_device_realize to > > avoid build error > > - Initialize shmem in vhost_user_backend_handle_shmem_unmap > > to avoid compiler being confused > > - Added stub for memory_region_init_ram_from_fd in memory.h > > for windows builds > > - Use memory_region_size for shmem_region handlers instead > > of accessing size member directly in shmem mrs > > v10->v11 > > - Rebase to grab commit fde5930cc37175cfcd0f03a089e26f4458a52311 > > and explicitly unset reply_ack on the SHMEM_MAP/UNMAP msg. > > - Mention mapping cleanup on device reset in the spec. > > > > This patch series implements dynamic fd-backed memory mapping support > > for vhost-user backends, enabling backends to dynamically request memory > > mappings and unmappings during runtime through the new > > VHOST_USER_BACKEND_SHMEM_MAP/UNMAP protocol messages. > > > > This feature benefits various VIRTIO devices that require dynamic shared > > memory management, including virtiofs (for DAX mappings), virtio-gpu > > (for resource sharing), and the recently standardized virtio-media. > > > > The implementation introduces a QOM-based architecture for managing > > shared memory lifecycle: > > > > - VirtioSharedMemoryMapping: an intermediate object that manages > > individual memory mappings by acting as generic container for regions > > declared in any vhost-user device type > > - Dynamic Mapping: backends can request mappings via SHMEM_MAP messages, > > with the frontend creating MemoryRegions from the provided file > > descriptors and adding them as subregions > > > > When a SHMEM_MAP request is received, the frontend: > > 1. Creates VirtioSharedMemoryMapping to manage the mapping lifecycle > > 2. Maps the provided fd with memory_region_init_ram_from_fd() > > 3. Creates a MemoryRegion backed by the mapped memory > > 4. Adds it as a subregion of the appropiate VIRTIO Shared Memory Region > > > > The QOM reference counting ensures automatic cleanup when mappings are > > removed or the device is destroyed. > > > > This patch also includes: > > - VHOST_USER_GET_SHMEM_CONFIG: a new frontend request allowing generic > > vhost-user devices to query shared memory configuration from backends > > at device initialization, enabling the generic vhost-user-device > > frontend to work with any backend regardless of specific shared memory > > requirements. > > > > The implementation has been tested with rust-vmm based backends. > > > > Albert Esteve (7): > > vhost-user: Add VirtIO Shared Memory map request > > vhost_user.rst: Align VhostUserMsg excerpt members > > vhost_user.rst: Add SHMEM_MAP/_UNMAP to spec > > vhost_user: Add frontend get_shmem_config command > > vhost_user.rst: Add GET_SHMEM_CONFIG message > > qmp: add shmem feature map > > vhost-user-device: Add shared memory BAR > > > > docs/interop/vhost-user.rst | 104 ++++++++ > > hw/virtio/vhost-user-base.c | 46 +++- > > hw/virtio/vhost-user-test-device-pci.c | 42 +++- > > hw/virtio/vhost-user.c | 274 ++++++++++++++++++++++ > > hw/virtio/virtio-qmp.c | 3 + > > hw/virtio/virtio.c | 201 ++++++++++++++++ > > include/hw/virtio/vhost-backend.h | 10 + > > include/hw/virtio/vhost-user.h | 1 + > > include/hw/virtio/virtio.h | 136 +++++++++++ > > include/system/memory.h | 2 +- > > subprojects/libvhost-user/libvhost-user.c | 70 ++++++ > > subprojects/libvhost-user/libvhost-user.h | 54 +++++ > > system/memory.c | 14 ++ > > 13 files changed, 951 insertions(+), 6 deletions(-) > > > > -- > > 2.52.0 > >
© 2016 - 2026 Red Hat, Inc.