From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"Viresh Kumar" <viresh.kumar@linaro.org>,
"Raphael Norwitz" <raphael.norwitz@nutanix.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
qemu-block@nongnu.org, "Eric Blake" <eblake@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Kevin Wolf" <kwolf@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Mathieu Poirier" <mathieu.poirier@linaro.org>,
"Hanna Reitz" <hreitz@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Erik Schilling" <erik.schilling@linaro.org>,
"Gonglei (Arei)" <arei.gonglei@huawei.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Fam Zheng" <fam@euphon.net>,
virtio-fs@redhat.com, "Stefan Hajnoczi" <stefanha@redhat.com>
Subject: [PATCH v3 08/20] virtio: add PCI stub for vhost-user-device
Date: Mon, 10 Jul 2023 16:35:10 +0100 [thread overview]
Message-ID: <20230710153522.3469097-9-alex.bennee@linaro.org> (raw)
In-Reply-To: <20230710153522.3469097-1-alex.bennee@linaro.org>
This is all pretty much boilerplate.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Erik Schilling <erik.schilling@linaro.org>
---
hw/virtio/vhost-user-device-pci.c | 71 +++++++++++++++++++++++++++++++
hw/virtio/meson.build | 1 +
2 files changed, 72 insertions(+)
create mode 100644 hw/virtio/vhost-user-device-pci.c
diff --git a/hw/virtio/vhost-user-device-pci.c b/hw/virtio/vhost-user-device-pci.c
new file mode 100644
index 0000000000..41f9b7905b
--- /dev/null
+++ b/hw/virtio/vhost-user-device-pci.c
@@ -0,0 +1,71 @@
+/*
+ * Vhost-user generic virtio device PCI glue
+ *
+ * Copyright (c) 2023 Linaro Ltd
+ * Author: Alex Bennée <alex.bennee@linaro.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/qdev-properties.h"
+#include "hw/virtio/vhost-user-device.h"
+#include "hw/virtio/virtio-pci.h"
+
+struct VHostUserDevicePCI {
+ VirtIOPCIProxy parent_obj;
+ VHostUserBase vub;
+};
+
+typedef struct VHostUserDevicePCI VHostUserDevicePCI;
+
+#define TYPE_VHOST_USER_DEVICE_PCI "vhost-user-device-pci-base"
+
+DECLARE_INSTANCE_CHECKER(VHostUserDevicePCI,
+ VHOST_USER_DEVICE_PCI,
+ TYPE_VHOST_USER_DEVICE_PCI)
+
+static void vhost_user_device_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
+{
+ VHostUserDevicePCI *dev = VHOST_USER_DEVICE_PCI(vpci_dev);
+ DeviceState *vdev = DEVICE(&dev->vub);
+
+ vpci_dev->nvectors = 1;
+ qdev_realize(vdev, BUS(&vpci_dev->bus), errp);
+}
+
+static void vhost_user_device_pci_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
+ PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
+ k->realize = vhost_user_device_pci_realize;
+ set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
+ pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
+ pcidev_k->device_id = 0; /* Set by virtio-pci based on virtio id */
+ pcidev_k->revision = 0x00;
+ pcidev_k->class_id = PCI_CLASS_COMMUNICATION_OTHER;
+}
+
+static void vhost_user_device_pci_instance_init(Object *obj)
+{
+ VHostUserDevicePCI *dev = VHOST_USER_DEVICE_PCI(obj);
+
+ virtio_instance_init_common(obj, &dev->vub, sizeof(dev->vub),
+ TYPE_VHOST_USER_DEVICE);
+}
+
+static const VirtioPCIDeviceTypeInfo vhost_user_device_pci_info = {
+ .base_name = TYPE_VHOST_USER_DEVICE_PCI,
+ .non_transitional_name = "vhost-user-device-pci",
+ .instance_size = sizeof(VHostUserDevicePCI),
+ .instance_init = vhost_user_device_pci_instance_init,
+ .class_init = vhost_user_device_pci_class_init,
+};
+
+static void vhost_user_device_pci_register(void)
+{
+ virtio_pci_types_register(&vhost_user_device_pci_info);
+}
+
+type_init(vhost_user_device_pci_register);
diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build
index b87c5523e7..1e1df77783 100644
--- a/hw/virtio/meson.build
+++ b/hw/virtio/meson.build
@@ -18,6 +18,7 @@ if have_vhost
# fixme - this really should be generic
specific_virtio_ss.add(files('vhost-user.c'))
softmmu_virtio_ss.add(files('vhost-user-device.c'))
+ softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c'))
endif
if have_vhost_vdpa
specific_virtio_ss.add(files('vhost-vdpa.c', 'vhost-shadow-virtqueue.c'))
--
2.39.2
next prev parent reply other threads:[~2023-07-10 15:37 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-10 15:35 [PATCH v3 00/20] virtio: add vhost-user-generic, reduce c&p and support standalone Alex Bennée
2023-07-10 15:35 ` [PATCH v3 01/20] include: attempt to document device_class_set_props Alex Bennée
2023-07-10 15:35 ` [PATCH v3 02/20] include/hw: document the device_class_set_parent_* fns Alex Bennée
2023-07-10 15:35 ` [PATCH v3 03/20] hw/virtio: fix typo in VIRTIO_CONFIG_IRQ_IDX comments Alex Bennée
2023-07-10 21:56 ` Philippe Mathieu-Daudé
2023-07-10 15:35 ` [PATCH v3 04/20] include/hw/virtio: document virtio_notify_config Alex Bennée
2023-07-10 15:35 ` [PATCH v3 05/20] include/hw/virtio: add kerneldoc for virtio_init Alex Bennée
2023-07-10 21:58 ` Philippe Mathieu-Daudé
2023-07-10 15:35 ` [PATCH v3 06/20] include/hw/virtio: document some more usage of notifiers Alex Bennée
2023-07-10 15:35 ` [PATCH v3 07/20] virtio: add vhost-user-base and a generic vhost-user-device Alex Bennée
2023-07-10 20:15 ` Michael S. Tsirkin
2023-09-05 14:19 ` Matias Ezequiel Vara Larsen
2023-09-05 17:01 ` Alex Bennée
2023-09-06 9:21 ` Matias Ezequiel Vara Larsen
2023-07-10 15:35 ` Alex Bennée [this message]
2023-07-10 15:35 ` [PATCH v3 09/20] hw/virtio: derive vhost-user-rng from vhost-user-device Alex Bennée
2023-07-10 15:35 ` [PATCH v3 10/20] hw/virtio: add config support to vhost-user-device Alex Bennée
2023-07-10 19:58 ` Michael S. Tsirkin
2023-08-31 14:23 ` Albert Esteve
2023-08-31 15:47 ` Alex Bennée
2023-09-01 5:56 ` Erik Schilling
2023-09-01 8:34 ` Albert Esteve
2023-07-10 15:35 ` [PATCH v3 11/20] hw/virtio: derive vhost-user-gpio from vhost-user-device Alex Bennée
2023-07-10 15:35 ` [PATCH v3 12/20] hw/virtio: derive vhost-user-i2c from vhost-user-base Alex Bennée
2023-07-10 15:35 ` [RFC PATCH v3 13/20] docs/system: add a basic enumeration of vhost-user devices Alex Bennée
2023-07-10 15:35 ` [RFC PATCH v3 14/20] docs/interop: define STANDALONE protocol feature for vhost-user Alex Bennée
2023-07-10 15:35 ` [RFC PATCH v3 15/20] hw/virtio: move vhost_user_init earlier Alex Bennée
2023-07-10 15:35 ` [RFC PATCH v3 16/20] hw/virtio: move virtq initialisation into internal helper Alex Bennée
2023-07-10 15:35 ` [RFC PATCH v3 17/20] hw/virtio: push down allocation responsibility for vhost_dev->vqs Alex Bennée
2023-07-10 15:35 ` [RFC PATCH v3 18/20] hw/virtio: validate F_STANDALONE also supports other protocol features Alex Bennée
2023-07-10 15:35 ` [RFC PATCH v3 19/20] hw/virtio: probe backend for specs if it supports it Alex Bennée
2023-07-10 15:35 ` [RFC PATCH v3 20/20] hw/virtio: allow vhost-user-device to be driven by backend Alex Bennée
2023-09-01 10:00 ` 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=20230710153522.3469097-9-alex.bennee@linaro.org \
--to=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=fam@euphon.net \
--cc=hreitz@redhat.com \
--cc=jasowang@redhat.com \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mathieu.poirier@linaro.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=raphael.norwitz@nutanix.com \
--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).