All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alyssa Ross <hi@alyssa.is>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: "Albert Esteve" <aesteve@redhat.com>,
	qemu-devel@nongnu.org, dbassey@redhat.com,
	manos.pitsidianakis@linaro.org, slp@redhat.com,
	stefanha@redhat.com, "Fabiano Rosas" <farosas@suse.de>,
	jasowang@redhat.com, "Alex Bennée" <alex.bennee@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	david@redhat.com, stevensd@chromium.org,
	"Stefano Garzarella" <sgarzare@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>
Subject: Re: [PATCH v11 3/7] vhost_user.rst: Add SHMEM_MAP/_UNMAP to spec
Date: Thu, 15 Jan 2026 14:35:53 +0100	[thread overview]
Message-ID: <87a4yfroau.fsf@alyssa.is> (raw)
In-Reply-To: <20260115081220-mutt-send-email-mst@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 4524 bytes --]

"Michael S. Tsirkin" <mst@redhat.com> writes:

> On Thu, Jan 15, 2026 at 01:10:44PM +0100, Alyssa Ross wrote:
>> Albert Esteve <aesteve@redhat.com> writes:
>> 
>> > Add SHMEM_MAP/_UNMAP request to the vhost-user
>> > spec documentation.
>> >
>> > Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
>> > Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
>> > Signed-off-by: Albert Esteve <aesteve@redhat.com>
>> > ---
>> >  docs/interop/vhost-user.rst | 59 +++++++++++++++++++++++++++++++++++++
>> >  1 file changed, 59 insertions(+)
>> >
>> > diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst
>> > index 17a68a62eb..6c1d66d7d3 100644
>> > --- a/docs/interop/vhost-user.rst
>> > +++ b/docs/interop/vhost-user.rst
>> > @@ -350,6 +350,27 @@ Device state transfer parameters
>> >    In the future, additional phases might be added e.g. to allow
>> >    iterative migration while the device is running.
>> >  
>> > +MMAP request
>> > +^^^^^^^^^^^^
>> > +
>> > ++-------+---------+-----------+------------+-----+-------+
>> > +| shmid | padding | fd_offset | shm_offset | len | flags |
>> > ++-------+---------+-----------+------------+-----+-------+
>> > +
>> > +:shmid: a 8-bit shared memory region identifier
>> > +
>> > +:fd_offset: a 64-bit offset of this area from the start
>> > +            of the supplied file descriptor
>> > +
>> > +:shm_offset: a 64-bit offset from the start of the
>> > +             pointed shared memory region
>> > +
>> > +:len: a 64-bit size of the memory to map
>> > +
>> > +:flags: a 64-bit value:
>> > +  - 0: Pages are mapped read-only
>> > +  - 1: Pages are mapped read-write
>> > +
>> >  C structure
>> >  -----------
>> >  
>> > @@ -375,6 +396,7 @@ In QEMU the vhost-user message is implemented with the following struct:
>> >            VhostUserInflight inflight;
>> >            VhostUserShared object;
>> >            VhostUserTransferDeviceState transfer_state;
>> > +          VhostUserMMap mmap;
>> >        };
>> >    } QEMU_PACKED VhostUserMsg;
>> >  
>> > @@ -1064,6 +1086,7 @@ Protocol features
>> >    #define VHOST_USER_PROTOCOL_F_XEN_MMAP             17
>> >    #define VHOST_USER_PROTOCOL_F_SHARED_OBJECT        18
>> >    #define VHOST_USER_PROTOCOL_F_DEVICE_STATE         19
>> > +  #define VHOST_USER_PROTOCOL_F_SHMEM                20
>> >  
>> >  Front-end message types
>> >  -----------------------
>> > @@ -1872,6 +1895,42 @@ is sent by the front-end.
>> >    when the operation is successful, or non-zero otherwise. Note that if the
>> >    operation fails, no fd is sent to the backend.
>> >  
>> > +``VHOST_USER_BACKEND_SHMEM_MAP``
>> > +  :id: 9
>> > +  :equivalent ioctl: N/A
>> > +  :request payload: fd and ``struct VhostUserMMap``
>> > +  :reply payload: N/A
>> > +
>> > +  When the ``VHOST_USER_PROTOCOL_F_SHMEM`` protocol feature has been
>> > +  successfully negotiated, this message can be submitted by the backends to
>> > +  advertise a new mapping to be made in a given VIRTIO Shared Memory Region.
>> > +  Upon receiving the message, the front-end will mmap the given fd into the
>> > +  VIRTIO Shared Memory Region with the requested ``shmid``.
>> > +  If ``VHOST_USER_PROTOCOL_F_REPLY_ACK`` is negotiated, and
>> > +  back-end set the ``VHOST_USER_NEED_REPLY`` flag, the front-end
>> > +  must respond with zero when operation is successfully completed,
>> > +  or non-zero otherwise.
>> 
>> Having now tried to implement this, I'm wondering whether replies should
>> be mandatory, even without VHOST_USER_PROTOCOL_F_REPLY_ACK, like they
>> are for some other messages.  Without waiting for a reply, a backend
>> doesn't know when it can tell the driver to start using the mapped
>> memory, so I'm not sure there's ever a case in which a backend would not
>> want to wait for a reply after sending VHOST_USER_BACKEND_SHMEM_MAP,
>> even if it doesn't wait habitually wait for replies for other messages.
>> (crosvm is like this — its backends don't negotiate
>> VHOST_USER_PROTOCOL_F_REPLY_ACK, and their non-standard map/unmap
>> requests had mandatory replies.)
>
> the use-case would be multiple MAP request and a single ack at the end
> to confirm them all.
>
> behaviour of sending ack without VHOST_USER_PROTOCOL_F_REPLY_ACK is
> legacy. let's just stick to the simple rule - if you want
> an ack set VHOST_USER_PROTOCOL_F_REPLY_ACK.

Okay, makes sense to me.  I'll try to fix crosvm's implementation.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

  reply	other threads:[~2026-01-15 13:37 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-11  9:10 [PATCH v11 0/7] vhost-user: Add SHMEM_MAP/UNMAP requests Albert Esteve
2025-11-11  9:10 ` [PATCH v11 1/7] vhost-user: Add VirtIO Shared Memory map request Albert Esteve
2026-02-03 21:20   ` Michael S. Tsirkin
2026-02-03 21:22   ` Michael S. Tsirkin
2026-02-03 21:51   ` Michael S. Tsirkin
2025-11-11  9:10 ` [PATCH v11 2/7] vhost_user.rst: Align VhostUserMsg excerpt members Albert Esteve
2025-11-11  9:10 ` [PATCH v11 3/7] vhost_user.rst: Add SHMEM_MAP/_UNMAP to spec Albert Esteve
2026-01-15 12:10   ` Alyssa Ross
2026-01-15 12:45     ` Albert Esteve
2026-01-15 13:13     ` Michael S. Tsirkin
2026-01-15 13:35       ` Alyssa Ross [this message]
2025-11-11  9:10 ` [PATCH v11 4/7] vhost_user: Add frontend get_shmem_config command Albert Esteve
2025-11-11  9:10 ` [PATCH v11 5/7] vhost_user.rst: Add GET_SHMEM_CONFIG message Albert Esteve
2026-01-16 10:20   ` Albert Esteve
2026-01-16 10:23     ` Manos Pitsidianakis
2026-01-16 11:15     ` Michael S. Tsirkin
2026-01-16 13:04       ` Albert Esteve
2026-01-19 11:34         ` Albert Esteve
2025-11-11  9:10 ` [PATCH v11 6/7] qmp: add shmem feature map Albert Esteve
2025-11-11  9:10 ` [PATCH v11 7/7] vhost-user-device: Add shared memory BAR Albert Esteve
2026-02-03 21:46   ` Michael S. Tsirkin
2026-02-04  7:46     ` Albert Esteve
2025-12-02 19:50 ` [PATCH v11 0/7] vhost-user: Add SHMEM_MAP/UNMAP requests Michael S. Tsirkin
2025-12-10  7:59   ` Albert Esteve

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a4yfroau.fsf@alyssa.is \
    --to=hi@alyssa.is \
    --cc=aesteve@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=david@redhat.com \
    --cc=dbassey@redhat.com \
    --cc=farosas@suse.de \
    --cc=jasowang@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sgarzare@redhat.com \
    --cc=slp@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=stevensd@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.