OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

virtio-dev message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [virtio-dev] [RFC PATCH v2] docs/interop: define PROBE feature for vhost-user VirtIO devices


This looks great! Thanks for this proposal.

On Fri, Sep 1, 2023 at 1:00âPM Alex BennÃe <alex.bennee@linaro.org> wrote:
Currently QEMU has to know some details about the VirtIO device
supported by a vhost-user daemon to be able to setup the guest. This
makes it hard for QEMU to add support for additional vhost-user
daemons without adding specific stubs for each additional VirtIO
device.

This patch suggests a new feature flag (VHOST_USER_PROTOCOL_F_PROBE)
which the back-end can advertise which allows a probe message to be
sent to get all the details QEMU needs to know in one message.

Together with the existing features VHOST_USER_PROTOCOL_F_STATUS and
VHOST_USER_PROTOCOL_F_CONFIG we can create "standalone" vhost-user
daemons which are capable of handling all aspects of the VirtIO
transactions with only a generic stub on the QEMU side. These daemons
can also be used without QEMU in situations where there isn't a full
VMM managing their setup.

Signed-off-by: Alex BennÃe <alex.bennee@linaro.org>

---
v2
 - dropped F_STANDALONE in favour of F_PROBE
 - split probe details across several messages
 - probe messages don't automatically imply a standalone daemon
 - add wording where probe details interact (F_MQ/F_CONFIG)
 - define VMM and make clear QEMU is only one of many potential VMMs
 - reword commit message
---
Âdocs/interop/vhost-user.rst | 90 ++++++++++++++++++++++++++++++++-----
Âhw/virtio/vhost-user.c   | 8 ++++
Â2 files changed, 88 insertions(+), 10 deletions(-)

diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst
index 5a070adbc1..ba3b5e07b7 100644
--- a/docs/interop/vhost-user.rst
+++ b/docs/interop/vhost-user.rst
@@ -7,6 +7,7 @@ Vhost-user Protocol
Â..
 ÂCopyright 2014 Virtual Open Systems Sarl.
 ÂCopyright 2019 Intel Corporation
+Â Copyright 2023 Linaro Ltd
 ÂLicence: This work is licensed under the terms of the GNU GPL,
      version 2 or later. See the COPYING file in the top-level
      directory.
@@ -27,17 +28,31 @@ The protocol defines 2 sides of the communication, *front-end* and
Â*back-end*. The *front-end* is the application that shares its virtqueues, in
Âour case QEMU. The *back-end* is the consumer of the virtqueues.

-In the current implementation QEMU is the *front-end*, and the *back-end*
-is the external process consuming the virtio queues, for example a
-software Ethernet switch running in user space, such as Snabbswitch,
-or a block device back-end processing read & write to a virtual
-disk. In order to facilitate interoperability between various back-end
-implementations, it is recommended to follow the :ref:`Backend program
-conventions <backend_conventions>`.
+In the current implementation a Virtual Machine Manager (VMM) such as
+QEMU is the *front-end*, and the *back-end* is the external process
+consuming the virtio queues, for example a software Ethernet switch
+running in user space, such as Snabbswitch, or a block device back-end
+processing read & write to a virtual disk. In order to facilitate
+interoperability between various back-end implementations, it is
+recommended to follow the :ref:`Backend program conventions
+<backend_conventions>`.

ÂThe *front-end* and *back-end* can be either a client (i.e. connecting) or
Âserver (listening) in the socket communication.

+Probing device details
+----------------------
+
+Traditionally the vhost-user daemon *back-end* shares configuration
+responsibilities with the VMM *front-end* which needs to know certain
+key bits of information about the device. This means the VMM needs to
+define at least a minimal stub for each VirtIO device it wants to
+support. If the daemon supports the right set of protocol features the
+VMM can probe the daemon for the information it needs to setup the
+device. See :ref:`Probing features for standalone daemons
+<probing_features>` for more details.
+
+
ÂSupport for platforms other than Linux
Â--------------------------------------

@@ -316,6 +331,7 @@ replies. Here is a list of the ones that do:
Â* ``VHOST_USER_GET_VRING_BASE``
Â* ``VHOST_USER_SET_LOG_BASE`` (if ``VHOST_USER_PROTOCOL_F_LOG_SHMFD``)
Â* ``VHOST_USER_GET_INFLIGHT_FD`` (if ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD``)
+* ``VHOST_USER_GET_BACKEND_SPECS`` (if ``VHOST_USER_PROTOCOL_F_STANDALONE``)

Â.. seealso::

@@ -396,9 +412,10 @@ must support changing some configuration aspects on the fly.
ÂMultiple queue support
Â----------------------

-Many devices have a fixed number of virtqueues. In this case the front-end
-already knows the number of available virtqueues without communicating with the
-back-end.
+Many devices have a fixed number of virtqueues. In this case the
+*front-end* usually already knows the number of available virtqueues
+without communicating with the back-end. For standalone daemons this
+number can be can be probed with the ``VHOST_USER_GET_MIN_VQ`` message.

ÂSome devices do not have a fixed number of virtqueues. Instead the maximum
Ânumber of virtqueues is chosen by the back-end. The number can depend on host
@@ -885,6 +902,23 @@ Protocol features
 Â#define VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS 15
 Â#define VHOST_USER_PROTOCOL_F_STATUS       Â16
 Â#define VHOST_USER_PROTOCOL_F_XEN_MMAP      Â17
+Â #define VHOST_USER_PROTOCOL_F_PROBEÂ Â Â Â Â Â Â Â 18
+
+.. _probing_features:
+
+Probing features for standalone daemons
+---------------------------------------
+
+The protocol feature ``VHOST_USER_PROTOCOL_F_PROBE`` enables a number
+of additional messages which allow the *front-end* to probe details
+about the VirtIO device from the *back-end*. However for a *back-end*
+to be described as standalone it must also support:
+
+Â * ``VHOST_USER_PROTOCOL_F_STATUS``
+Â * ``VHOST_USER_PROTOCOL_F_CONFIG`` (if there is a config space)
+
+which are required to ensure the *back-end* daemon can operate
+without the *front-end* managing some aspects of its configuration.

ÂFront-end message types
Â-----------------------
@@ -1440,6 +1474,42 @@ Front-end message types
 Âquery the back-end for its device status as defined in the Virtio
 Âspecification.

+``VHOST_USER_GET_DEVICE_ID``
+Â :id: 41
+Â :request payload: N/A
+Â :reply payload: ``u32``
+
+Â When the ``VHOST_USER_PROTOCOL_F_PROBE`` protocol feature has been
+Â successfully negotiated, this message is submitted by the front-end
+Â to query what VirtIO device the back-end support. This is intended
+Â to remove the need for the front-end to know ahead of time what the
+Â VirtIO device the backend emulates is.
+
+``VHOST_USER_GET_CONFIG_SIZE``
+Â :id: 42
+Â :request payload: N/A
+Â :reply payload: ``u32``
+
+Â When the ``VHOST_USER_PROTOCOL_F_PROBE`` protocol feature has been
+Â successfully negotiated, this message is submitted by the front-end
+Â to query the size of the VirtIO device's config space. This is
+Â intended to remove the need for the front-end to know ahead of time
+Â what the size is. Replying with 0 when
+Â ``VHOST_USER_PROTOCOL_F_CONFIG`` has been negotiated would indicate
+Â an bug.
+
+``VHOST_USER_GET_MIN_VQ``
+Â :id: 43
+Â :request payload: N/A
+Â :reply payload: ``u32``
+
+Â When the ``VHOST_USER_PROTOCOL_F_PROBE`` protocol feature has been
+Â successfully negotiated, this message is submitted by the front-end to
+Â query minimum number of VQ's required to support the device. A
+Â device may support more than this number of VQ's if it advertises
+Â the ``VHOST_USER_PROTOCOL_F_MQ`` protocol feature. Reporting a
+Â number greater than the result of ``VHOST_USER_GET_QUEUE_NUM`` would
+Â indicate a bug.


Maybe I lack some background, but not sure what min_vq is here?
This looks like queringÂthe number of VQs the backend requires/uses.
Which, in case of MQ, it may be bigger (which is where I assume comes the `min`
part, if we consider `VHOST_USER_GET_QUEUE_NUM` the `max`).

Couldn't we reuse the `VHOST_USER_GET_QUEUE_NUM` type for this?
Â
ÂBack-end message types
Â----------------------
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 8dcf049d42..4d433cdf2b 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -202,6 +202,13 @@ typedef struct VhostUserInflight {
  Âuint16_t queue_size;
Â} VhostUserInflight;

+typedef struct VhostUserBackendSpecs {
+Â Â uint32_t device_id;
+Â Â uint32_t config_size;
+Â Â uint32_t min_vqs;
+Â Â uint32_t max_vqs;
+} VhostUserBackendSpecs;
+
Âtypedef struct {
  ÂVhostUserRequest request;

@@ -226,6 +233,7 @@ typedef union {
    ÂVhostUserCryptoSession session;
    ÂVhostUserVringArea area;
    ÂVhostUserInflight inflight;
+Â Â Â Â VhostUserBackendSpecs specs;
Â} VhostUserPayload;

Âtypedef struct VhostUserMsg {
--
2.39.2


---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]