Add SCMI vhost-user VIRTIO device
v2 cover Add SCMI vhost-user VIRTIO device
This patch series adds a vhost-user VIRTIO device for SCMI. It's similar to other similar vhost-user VIRTIO devices.
I'm aware of the work in progress by Alex Bennée to simplify similar devices and avoid excessive code duplication. I think the SCMI device support doesn't bring anything special and it can be rebased on the given work if/once it is merged.
The device has been tested with a prototype rust-vmm based vhost-user-scmi daemon emulating a sensor device and a Linux guest OS (the production version of the vhost-user daemon is developed at
https://github.com/mz-pdm/vhost-device/tree/scmi).
v2:
- A missing trailing space additionally added in the comment typo fix.
- A note about testing added above.
Milan Zamazal (4):
hw/virtio: Add boilerplate for vhost-user-scmi device hw/virtio: Add vhost-user-scmi-pci boilerplate tests/qtest: Fix a comment typo in vhost-user-test.c tests/qtest: enable tests for virtio-scmi
MAINTAINERS | 7 + hw/virtio/Kconfig | 5 + hw/virtio/meson.build | 2 + hw/virtio/vhost-user-scmi-pci.c | 68 +++++++ hw/virtio/vhost-user-scmi.c | 306 ++++++++++++++++++++++++++++ include/hw/virtio/vhost-user-scmi.h | 30 +++ tests/qtest/libqos/meson.build | 1 + tests/qtest/libqos/virtio-scmi.c | 174 ++++++++++++++++ tests/qtest/libqos/virtio-scmi.h | 34 ++++ tests/qtest/vhost-user-test.c | 46 ++++- 10 files changed, 672 insertions(+), 1 deletion(-) create mode 100644 hw/virtio/vhost-user-scmi-pci.c create mode 100644 hw/virtio/vhost-user-scmi.c create mode 100644 include/hw/virtio/vhost-user-scmi.h create mode 100644 tests/qtest/libqos/virtio-scmi.c create mode 100644 tests/qtest/libqos/virtio-scmi.h
Signature · 1 line
2.40.1
PATCH v2 1/4 hw/virtio: Add boilerplate for vhost-user-scmi device
This creates the QEMU side of the vhost-user-scmi device which connects to the remote daemon. It is based on code of similar vhost-user devices.
--- MAINTAINERS | 6 + hw/virtio/Kconfig | 5 + hw/virtio/meson.build | 1 + hw/virtio/vhost-user-scmi.c | 306 ++++++++++++++++++++++++++++ include/hw/virtio/vhost-user-scmi.h | 30 +++ 5 files changed, 348 insertions(+) create mode 100644 hw/virtio/vhost-user-scmi.c create mode 100644 include/hw/virtio/vhost-user-scmi.h
MAINTAINERS +6 -0
@@ -2204,6 +2204,12 @@ F: hw/virtio/vhost-user-gpio* F: include/hw/virtio/vhost-user-gpio.h F: tests/qtest/libqos/virtio-gpio.* +vhost-user-scmi +R: [email protected] +S: Supported +F: hw/virtio/vhost-user-scmi* +F: include/hw/virtio/vhost-user-scmi.h + virtio-crypto M: Gonglei <[email protected]> S: Supported
hw/virtio/Kconfig +5 -0
@@ -90,3 +90,8 @@ config VHOST_VDPA_DEV bool default y depends on VIRTIO && VHOST_VDPA && LINUX + +config VHOST_USER_SCMI + bool + default y + depends on VIRTIO && VHOST_USER
hw/virtio/meson.build +1 -0
@@ -32,6 +32,7 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c')) specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c')) +specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev.c')) virtio_pci_ss = ss.source_set()
hw/virtio/vhost-user-scmi.c new file +306 -0
306 lines not on this page · raw message
include/hw/virtio/vhost-user-scmi.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* Vhost-user SCMI virtio device +* +* Copyright (c) 2023 Red Hat, Inc. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef _QEMU_VHOST_USER_SCMI_H +#define _QEMU_VHOST_USER_SCMI_H + +#include "hw/virtio/virtio.h" +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" + +#define TYPE_VHOST_USER_SCMI "vhost-user-scmi" +OBJECT_DECLARE_SIMPLE_TYPE (VHostUserSCMI,VHOST_USER_SCMI ); + +struct VHostUserSCMI { +VirtIODevice parent; +CharBackend chardev; +struct vhost_virtqueue *vhost_vqs; +struct vhost_dev vhost_dev; +VhostUserState vhost_user; +VirtQueue *cmd_vq; +VirtQueue *event_vq; +bool connected; +}; + +#endif /* _QEMU_VHOST_USER_SCMI_H */
Signature · 1 line
2.40.1
PATCH v2 2/4 hw/virtio: Add vhost-user-scmi-pci boilerplate
In reply to Milan ZamazalThis allows is to instantiate a vhost-user-scmi device as part of a PCI bus. It is mostly boilerplate similar to the other vhost-user-*-pci boilerplates of similar devices.
--- hw/virtio/meson.build | 1 + hw/virtio/vhost-user-scmi-pci.c | 68 +++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 hw/virtio/vhost-user-scmi-pci.c
hw/virtio/meson.build +1 -0
@@ -33,6 +33,7 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c')) specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c')) +specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SCMI'], if_true: files('vhost-user-scmi-pci.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev.c')) virtio_pci_ss = ss.source_set()
hw/virtio/vhost-user-scmi-pci.c new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
2.40.1
PATCH v2 3/4 tests/qtest: Fix a comment typo in vhost-user-test.c
In reply to Milan Zamazal--- tests/qtest/vhost-user-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/vhost-user-test.c +1 -1
@@ -281,7 +281,7 @@ static void read_guest_mem_server(QTestState *qts, TestServer *s)/* iterate all regions */ for (i =0 ; i < s->fds_num; i++) { -/* We'll check only the region statring at 0x0*/ +/* We'll check only the region starting at 0x0 */ if (s->memory.regions[i].guest_phys_addr !=0x0 ) {continue ; }
Signature · 1 line
2.40.1
PATCH v2 4/4 tests/qtest: enable tests for virtio-scmi
In reply to Milan ZamazalWe don't have a virtio-scmi implementation in QEMU and only support a vhost-user backend. This is very similar to virtio-gpio and we add the same set of tests, just passing some vhost-user messages over the control socket.
--- MAINTAINERS | 1 + tests/qtest/libqos/meson.build | 1 + tests/qtest/libqos/virtio-scmi.c | 174 +++++++++++++++++++++++++++++++ tests/qtest/libqos/virtio-scmi.h | 34 ++++++ tests/qtest/vhost-user-test.c | 44 ++++++++ 5 files changed, 254 insertions(+) create mode 100644 tests/qtest/libqos/virtio-scmi.c create mode 100644 tests/qtest/libqos/virtio-scmi.h
MAINTAINERS +1 -0
@@ -2209,6 +2209,7 @@ R: [email protected] S: Supported F: hw/virtio/vhost-user-scmi* F: include/hw/virtio/vhost-user-scmi.h +F: tests/qtest/libqos/virtio-scmi.* virtio-crypto M: Gonglei <[email protected]>
tests/qtest/libqos/meson.build +1 -0
@@ -46,6 +46,7 @@ libqos_srcs = files( 'virtio-serial.c', 'virtio-iommu.c', 'virtio-gpio.c', + 'virtio-scmi.c', 'generic-pcihost.c', # qgraph machines:
tests/qtest/libqos/virtio-scmi.c new file +174 -0
174 lines not on this page · raw message
tests/qtest/libqos/virtio-scmi.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* virtio-scmi structures +* +* SPDX-FileCopyrightText: Red Hat, Inc. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef TESTS_LIBQOS_VIRTIO_SCMI_H +#define TESTS_LIBQOS_VIRTIO_SCMI_H + +#include "qgraph.h" +#include "virtio.h" +#include "virtio-pci.h" + +typedef struct QVhostUserSCMI QVhostUserSCMI ; +typedef struct QVhostUserSCMIPCI QVhostUserSCMIPCI ; +typedef struct QVhostUserSCMIDevice QVhostUserSCMIDevice ; + +struct QVhostUserSCMI { +QVirtioDevice *vdev; +QVirtQueue **queues; +}; + +struct QVhostUserSCMIPCI { +QVirtioPCIDevice pci_vdev; +QVhostUserSCMI scmi; +}; + +struct QVhostUserSCMIDevice { +QOSGraphObject obj; +QVhostUserSCMI scmi; +}; + +#endif
tests/qtest/vhost-user-test.c +44 -0
59 lines not on this page · raw message
Signature · 1 line
2.40.1