qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org, "Gonglei (Arei)" <arei.gonglei@huawei.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	virtio-fs@redhat.com,
	"Erik Schilling" <erik.schilling@linaro.org>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"Mathieu Poirier" <mathieu.poirier@linaro.org>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>
Subject: Re: [PATCH 00/12] virtio: add vhost-user-generic and reduce copy and paste
Date: Mon, 17 Apr 2023 08:32:58 -0400	[thread overview]
Message-ID: <CAJSP0QURbJrEoFY8FhMnq_B6tx-qYspfu-OB6=6hz5=qAwE=6A@mail.gmail.com> (raw)
In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org>

On Fri, 14 Apr 2023 at 12:06, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> A lot of our vhost-user stubs are large chunks of boilerplate that do
> (mostly) the same thing. This series attempts to fix that by defining
> a new base class for vhost-user devices and then converting the rng
> and gpio devices to be based off them. You can even use
> vhost-user-device directly if you supply it with the right magic
> numbers (which is helpful for development).
>
> However the final patch runs into the weeds because I don't yet have a
> clean way to represent in QOM the fixing of certain properties for the
> specialised classes.
>
> The series is a net reduction in code and an increase in
> documentation but obviously needs to iron out a few more warts. I'm
> open to suggestions on the best way to tweak the QOM stuff.

--device vhost-user-device is not really possible because vhost-user
devices are not full VIRTIO devices. vhost-user devices depend on
device-specific code in the VMM by design.

The "subset of a VIRTIO device" design made sense for vhost_net.
Nowadays there are other device types that are close to full VIRTIO
devices, although the vhost-user protocol doesn't support the full
VIRTIO device lifecycle.

I think a user-creatable --device vhost-user-device is not a good idea
today. It creates confusion. Many people aren't aware of the
architectural difference between vhost-user and VIRTIO devices. The
result is that VMMs and vhost-user backends implement increasingly
brittle VIRTIO configuration space and feature bit logic as they
knowingly or unknowingly try to paper over the fact that a traditional
vhost-user device isn't a full VIRTIO device.

It is possible to resolve this difference and make --device
vhost-user-device work properly for devices that want to be full
VIRTIO devices. See "Making VMM device shims optional" here:
https://blog.vmsplice.net/2020/09/on-unifying-vhost-user-and-virtio.html

Even after extending the vhost-user protocol to solve the current
limitations, existing backends would still only be partial VIRTIO
devices that wouldn't work with --device vhost-user-device.

Reducing boilerplate is helpful, but I think --device
vhost-user-device should not be user-creatable.

Stefan

>
> Alex.
>
> Alex Bennée (12):
>   hw/virtio: fix typo in VIRTIO_CONFIG_IRQ_IDX comments
>   include/hw/virtio: document virtio_notify_config
>   include/hw/virtio: add kerneldoc for virtio_init
>   include/hw/virtio: document some more usage of notifiers
>   virtio: add generic vhost-user-device
>   virtio: add PCI stub for vhost-user-device
>   include: attempt to document device_class_set_props
>   qom: allow for properties to become "fixed"
>   hw/virtio: derive vhost-user-rng from vhost-user-device
>   hw/virtio: add config support to vhost-user-device
>   hw/virtio: derive vhost-user-gpio from vhost-user-device (!BROKEN)
>   docs/system: add a basic enumeration of vhost-user devices
>
>  docs/system/devices/vhost-user-rng.rst |   2 +
>  docs/system/devices/vhost-user.rst     |  41 +++
>  qapi/qom.json                          |   2 +
>  include/hw/qdev-core.h                 |   9 +
>  include/hw/virtio/vhost-user-device.h  |  33 ++
>  include/hw/virtio/vhost-user-gpio.h    |  23 +-
>  include/hw/virtio/vhost-user-rng.h     |  11 +-
>  include/hw/virtio/virtio.h             |  21 ++
>  include/qom/object.h                   |  16 +-
>  hw/display/vhost-user-gpu.c            |   4 +-
>  hw/net/virtio-net.c                    |   4 +-
>  hw/virtio/vhost-user-device-pci.c      |  71 +++++
>  hw/virtio/vhost-user-device.c          | 359 ++++++++++++++++++++++
>  hw/virtio/vhost-user-fs.c              |   4 +-
>  hw/virtio/vhost-user-gpio.c            | 405 +------------------------
>  hw/virtio/vhost-user-rng.c             | 264 +---------------
>  hw/virtio/vhost-vsock-common.c         |   4 +-
>  hw/virtio/virtio-crypto.c              |   4 +-
>  qom/object.c                           |  14 +
>  qom/object_interfaces.c                |   9 +-
>  qom/qom-qmp-cmds.c                     |   1 +
>  softmmu/qdev-monitor.c                 |   1 +
>  hw/virtio/meson.build                  |   3 +
>  23 files changed, 613 insertions(+), 692 deletions(-)
>  create mode 100644 include/hw/virtio/vhost-user-device.h
>  create mode 100644 hw/virtio/vhost-user-device-pci.c
>  create mode 100644 hw/virtio/vhost-user-device.c
>
> --
> 2.39.2
>
>


  parent reply	other threads:[~2023-04-17 12:34 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-14 16:04 [PATCH 00/12] virtio: add vhost-user-generic and reduce copy and paste Alex Bennée
2023-04-14 16:04 ` [PATCH 01/12] hw/virtio: fix typo in VIRTIO_CONFIG_IRQ_IDX comments Alex Bennée
2023-04-14 16:04 ` [PATCH 02/12] include/hw/virtio: document virtio_notify_config Alex Bennée
2023-04-14 16:04 ` [PATCH 03/12] include/hw/virtio: add kerneldoc for virtio_init Alex Bennée
2023-04-14 16:04 ` [PATCH 04/12] include/hw/virtio: document some more usage of notifiers Alex Bennée
2023-04-14 16:04 ` [PATCH 05/12] virtio: add generic vhost-user-device Alex Bennée
2023-04-14 16:04 ` [PATCH 06/12] virtio: add PCI stub for vhost-user-device Alex Bennée
2023-04-18  8:28   ` Erik Schilling
2023-04-14 16:04 ` [PATCH 07/12] include: attempt to document device_class_set_props Alex Bennée
2023-04-14 16:04 ` [PATCH 08/12] qom: allow for properties to become "fixed" Alex Bennée
2023-04-17 10:02   ` Markus Armbruster
2023-04-17 11:26     ` Alex Bennée
2023-04-17 12:04       ` Peter Maydell
2023-04-14 16:04 ` [PATCH 09/12] hw/virtio: derive vhost-user-rng from vhost-user-device Alex Bennée
2023-04-14 16:04 ` [PATCH 10/12] hw/virtio: add config support to vhost-user-device Alex Bennée
2023-04-14 16:04 ` [PATCH 11/12] hw/virtio: derive vhost-user-gpio from vhost-user-device (!BROKEN) Alex Bennée
2023-04-14 16:04 ` [PATCH 12/12] docs/system: add a basic enumeration of vhost-user devices Alex Bennée
2023-04-17  4:26 ` [PATCH 00/12] virtio: add vhost-user-generic and reduce copy and paste Viresh Kumar
2023-04-17  8:42   ` Alex Bennée
2023-04-17 12:32 ` Stefan Hajnoczi [this message]
2023-04-17 16:14   ` Alex Bennée
2023-04-18 16:04     ` Stefan Hajnoczi

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='CAJSP0QURbJrEoFY8FhMnq_B6tx-qYspfu-OB6=6hz5=qAwE=6A@mail.gmail.com' \
    --to=stefanha@gmail.com \
    --cc=alex.bennee@linaro.org \
    --cc=arei.gonglei@huawei.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=erik.schilling@linaro.org \
    --cc=jasowang@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mathieu.poirier@linaro.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=viresh.kumar@linaro.org \
    --cc=virtio-fs@redhat.com \
    /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 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).