qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/7] vhost-user: Add SHMEM_MAP/UNMAP requests
@ 2025-06-09 14:47 Albert Esteve
  2025-06-09 14:47 ` [PATCH v5 1/7] vhost-user: Add VirtIO Shared Memory map request Albert Esteve
                   ` (6 more replies)
  0 siblings, 7 replies; 19+ messages in thread
From: Albert Esteve @ 2025-06-09 14:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, slp, david, Michael S. Tsirkin, Stefano Garzarella,
	jasowang, stevensd, hi, Alex Bennée, Albert Esteve

Hi all,

v4->v5
- Change vdev->shmem_list to QSIMPLEQ type
- Dropped MEM_READ/WRITE messages
- Improved message handling for
  SHMEM_MAP/UNMAP (fix leaks, fix
  response logic, reworked field
  checks, etc.)
- Changed VHOST_USER_FLAG_MAP_* to
  have only read-write flag

The goal of this patch is to support
dynamic fd-backed memory maps initiated
from vhost-user backends.
There are many devices that could already
benefit of this feature, e.g.,
virtiofs, virtio-gpu, or the recently
added to the spec, virtio-media device.

After receiving the SHMEM_MAP/UNMAP request,
the frontend creates the RAMBlock form the
fd and maps it by adding it as a subregion
of the shared memory region container.

The VIRTIO Shared Memory Region list is
declared in the `VirtIODevice` struct
to make it generic.

The message handling code has been tested
with a rust-vmm device, which entails
some level of validation.

This patch also includes:
- SHMEM_CONFIG frontend request that is
specifically meant to allow generic
vhost-user-device frontend to be able to
query VIRTIO Shared Memory settings from the
backend (as this device is generic and agnostic
of the actual backend configuration).

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-devive: Add shmem BAR

 docs/interop/vhost-user.rst               |  98 +++++++++++
 hw/virtio/vhost-user-base.c               |  47 +++++-
 hw/virtio/vhost-user-device-pci.c         |  34 +++-
 hw/virtio/vhost-user.c                    | 193 ++++++++++++++++++++++
 hw/virtio/virtio-qmp.c                    |   3 +
 hw/virtio/virtio.c                        |  97 +++++++++++
 include/hw/virtio/vhost-backend.h         |  10 ++
 include/hw/virtio/vhost-user.h            |   1 +
 include/hw/virtio/virtio.h                |  31 ++++
 subprojects/libvhost-user/libvhost-user.c |  70 ++++++++
 subprojects/libvhost-user/libvhost-user.h |  54 ++++++
 11 files changed, 633 insertions(+), 5 deletions(-)

-- 
2.49.0



^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: [PATCH v5 7/7] vhost-user-devive: Add shmem BAR
@ 2025-06-20  9:08 Dorinda Bassey
  2025-06-20 11:31 ` Albert Esteve
  0 siblings, 1 reply; 19+ messages in thread
From: Dorinda Bassey @ 2025-06-20  9:08 UTC (permalink / raw)
  To: Albert Esteve
  Cc: alex.bennee, David Hildenbrand, hi, Jason Wang, Michael Tsirkin,
	qemu-devel, Stefano Garzarella, Sergio Lopez Pascual,
	Stefan Hajnoczi, stevensd

Hi Albert,

Thank you for these patches, just a small issue you could add to your
next series.

>
> +
> +            memory_region_init(virtio_new_shmem_region(vdev, i)->mr,
> +                               OBJECT(vdev), "vub-shm-" + i,
> +                               memory_sizes[i]);

Here, `"vub-shm-" + i` looks like string concatenation but uses
pointer arithmetic,
which could cause a crash at runtime for e.g., when `i` is > 0. I
believe you can use
g_strdup_printf("vub-shm-%d", i) to fix this, it constructs a new
null-terminated
string like "vub-shm-0", "vub-shm-1", "vub-shm-2", etc. If that was
your intention.

BR,
Dorinda.



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

end of thread, other threads:[~2025-06-25 18:53 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-09 14:47 [PATCH v5 0/7] vhost-user: Add SHMEM_MAP/UNMAP requests Albert Esteve
2025-06-09 14:47 ` [PATCH v5 1/7] vhost-user: Add VirtIO Shared Memory map request Albert Esteve
2025-06-10 10:43   ` David Hildenbrand
2025-06-12 16:18   ` Stefan Hajnoczi
     [not found]     ` <CADSE00LrrTNYLKnGqUNSH_HqtPA4n0t6Qq1JA5b1=mUQ2XO0iA@mail.gmail.com>
2025-06-16 15:33       ` Albert Esteve
2025-06-09 14:47 ` [PATCH v5 2/7] vhost_user.rst: Align VhostUserMsg excerpt members Albert Esteve
2025-06-10 10:44   ` David Hildenbrand
2025-06-09 14:47 ` [PATCH v5 3/7] vhost_user.rst: Add SHMEM_MAP/_UNMAP to spec Albert Esteve
2025-06-11  6:20   ` Alyssa Ross
2025-06-11  8:53     ` Albert Esteve
2025-06-09 14:47 ` [PATCH v5 4/7] vhost_user: Add frontend get_shmem_config command Albert Esteve
2025-06-24 19:23   ` Stefan Hajnoczi
2025-06-09 14:47 ` [PATCH v5 5/7] vhost_user.rst: Add GET_SHMEM_CONFIG message Albert Esteve
2025-06-09 14:47 ` [PATCH v5 6/7] qmp: add shmem feature map Albert Esteve
2025-06-09 14:47 ` [PATCH v5 7/7] vhost-user-devive: Add shmem BAR Albert Esteve
2025-06-11  6:29   ` Alyssa Ross
2025-06-25 16:47   ` Stefan Hajnoczi
  -- strict thread matches above, loose matches on Subject: below --
2025-06-20  9:08 Dorinda Bassey
2025-06-20 11:31 ` Albert Esteve

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).