aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2022-10-12 16:00:15 -0400
committerStefan Hajnoczi <stefanha@redhat.com>2022-10-12 16:00:15 -0400
commitcdcb7dcb401757b5853ca99c1967a6d66e1deea5 (patch)
tree629a0b8da58fe630498804183659a7e6818cd655 /tests
parentcdda364e1da45edcb70fad7fa77bd2bb5e6c023f (diff)
parent3216ab2acb08b47d4ff83e709406690d37e44aff (diff)
Merge tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging
pc,virtio: features, tests, fixes, cleanups virtio introspection new serial number opton for cxl vhost user blk dynamic config size virtio-gpio vhost user backend Tests fixes cleanups all over the place Signed-off-by: Michael S. Tsirkin <mst@redhat.com> # -----BEGIN PGP SIGNATURE----- # # iQFDBAABCAAtFiEEXQn9CHHI+FuUyooNKB8NuNKNVGkFAmNEVeoPHG1zdEByZWRo # YXQuY29tAAoJECgfDbjSjVRph8YH+gMWpb5IglE0Q+H2JiQPBwB/Ghy1ohRKnOvZ # lChB7+oy18o2xXRFTOXwG9Ijqsbdn0QMbU/r3NWxBuMzxDow012xiMDniJlJmcXw # /4POOCSTKrIfzVBhsEErVSA9NwSE5cQKr1oiRBGIa9UdZfZ//v7s6SoP4vtyj8RZ # UJVYVnMDtq/0PaN92IMs06lhqo/LkegE7gTGHMBf8Nvw4SgQoZgfPyp1eR+dKOhz # lXNqqvTds9yt8yS65UWbuSrZ9d7GpCQf8nuyLaLaENHd6FQUVfmTTT37l2EKziwp # PK0EwWMHeGkj7LHrylztradhE9xBlIW23ROP8wPdGZHmgLNHbC0= # =20Zb # -----END PGP SIGNATURE----- # gpg: Signature made Mon 10 Oct 2022 13:27:06 EDT # gpg: using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469 # gpg: issuer "mst@redhat.com" # gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" [full] # gpg: aka "Michael S. Tsirkin <mst@redhat.com>" [full] # Primary key fingerprint: 0270 606B 6F3C DF3D 0B17 0970 C350 3912 AFBE 8E67 # Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA 8A0D 281F 0DB8 D28D 5469 * tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu: (55 commits) x86: pci: acpi: consolidate PCI slots creation tests: acpi: update expected blobs x86: pci: acpi: reorder Device's _DSM method tests: acpi: whitelist pc/q35 DSDT before moving _ADR field tests: acpi: update expected blobs x86: pci: acpi: reorder Device's _ADR and _SUN fields tests: acpi: whitelist pc/q35 DSDT before moving _ADR field tests: acpi: update expected blobs x86: acpi: cleanup PCI device _DSM duplication tests: acpi: whitelist pc/q35 DSDT before switching _DSM to use ASUN tests: acpi: update expected blobs x86: acpi: _DSM: use Package to pass parameters acpi: x86: refactor PDSM method to reduce nesting tests: acpi: whitelist pc/q35 DSDT due to HPET AML move tests: acpi: update expected blobs after HPET move acpi: x86: deduplicate HPET AML building tests: acpi: whitelist pc/q35 DSDT due to HPET AML move hw/smbios: support for type 8 (port connector) pci: Sanity check mask argument to pci_set_*_by_mask() pci: Remove unused pci_get_*_by_mask() functions ... Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/data/acpi/pc/DSDTbin5987 -> 6422 bytes
-rw-r--r--tests/data/acpi/pc/DSDT.acpierstbin5954 -> 6382 bytes
-rw-r--r--tests/data/acpi/pc/DSDT.acpihmatbin7312 -> 7747 bytes
-rw-r--r--tests/data/acpi/pc/DSDT.bridgebin8653 -> 9496 bytes
-rw-r--r--tests/data/acpi/pc/DSDT.cphpbin6451 -> 6886 bytes
-rw-r--r--tests/data/acpi/pc/DSDT.dimmpxmbin7641 -> 8076 bytes
-rw-r--r--tests/data/acpi/pc/DSDT.hpbridgebin5954 -> 6382 bytes
-rw-r--r--tests/data/acpi/pc/DSDT.hpbrrootbin3069 -> 3069 bytes
-rw-r--r--tests/data/acpi/pc/DSDT.ipmikcsbin6059 -> 6494 bytes
-rw-r--r--tests/data/acpi/pc/DSDT.memhpbin7346 -> 7781 bytes
-rw-r--r--tests/data/acpi/pc/DSDT.nohpetbin5845 -> 6280 bytes
-rw-r--r--tests/data/acpi/pc/DSDT.numamembin5993 -> 6428 bytes
-rw-r--r--tests/data/acpi/pc/DSDT.roothpbin6195 -> 6656 bytes
-rw-r--r--tests/data/acpi/q35/DSDTbin8274 -> 8320 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.acpierstbin8291 -> 8337 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.acpihmatbin9599 -> 9645 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.applesmcbin8320 -> 8366 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.bridgebin10988 -> 11449 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.cphpbin8738 -> 8784 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.cxlbin9600 -> 9646 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.dimmpxmbin9928 -> 9974 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.ipmibtbin8349 -> 8395 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.ipmismbusbin8363 -> 8409 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.ivrsbin8291 -> 8337 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.memhpbin9633 -> 9679 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.mmio64bin9404 -> 9450 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.multi-bridgebin8568 -> 8640 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.nohpetbin8132 -> 8178 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.numamembin8280 -> 8326 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.pvpanic-isabin8375 -> 8421 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.tis.tpm12bin8880 -> 8926 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.tis.tpm2bin8906 -> 8952 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.viotbin9383 -> 9429 bytes
-rw-r--r--tests/data/acpi/q35/DSDT.xapicbin35637 -> 35683 bytes
-rw-r--r--tests/data/acpi/virt/GTDTbin96 -> 96 bytes
-rw-r--r--tests/data/acpi/virt/GTDT.memhpbin96 -> 96 bytes
-rw-r--r--tests/data/acpi/virt/GTDT.numamembin96 -> 96 bytes
-rw-r--r--tests/qtest/libqos/meson.build1
-rw-r--r--tests/qtest/libqos/virtio-gpio.c171
-rw-r--r--tests/qtest/libqos/virtio-gpio.h35
-rw-r--r--tests/qtest/libqos/virtio.c4
-rw-r--r--tests/qtest/qmp-cmd-test.c1
-rw-r--r--tests/qtest/qos-test.c9
-rw-r--r--tests/qtest/vhost-user-test.c175
44 files changed, 376 insertions, 20 deletions
diff --git a/tests/data/acpi/pc/DSDT b/tests/data/acpi/pc/DSDT
index e80bef3031..da2a3e5c05 100644
--- a/tests/data/acpi/pc/DSDT
+++ b/tests/data/acpi/pc/DSDT
Binary files differ
diff --git a/tests/data/acpi/pc/DSDT.acpierst b/tests/data/acpi/pc/DSDT.acpierst
index d5a2ca5165..abcd6d9d30 100644
--- a/tests/data/acpi/pc/DSDT.acpierst
+++ b/tests/data/acpi/pc/DSDT.acpierst
Binary files differ
diff --git a/tests/data/acpi/pc/DSDT.acpihmat b/tests/data/acpi/pc/DSDT.acpihmat
index f86c743c4d..884d4871a2 100644
--- a/tests/data/acpi/pc/DSDT.acpihmat
+++ b/tests/data/acpi/pc/DSDT.acpihmat
Binary files differ
diff --git a/tests/data/acpi/pc/DSDT.bridge b/tests/data/acpi/pc/DSDT.bridge
index 14ed0d995a..31a79aa476 100644
--- a/tests/data/acpi/pc/DSDT.bridge
+++ b/tests/data/acpi/pc/DSDT.bridge
Binary files differ
diff --git a/tests/data/acpi/pc/DSDT.cphp b/tests/data/acpi/pc/DSDT.cphp
index c653302a84..8b0cae4dbf 100644
--- a/tests/data/acpi/pc/DSDT.cphp
+++ b/tests/data/acpi/pc/DSDT.cphp
Binary files differ
diff --git a/tests/data/acpi/pc/DSDT.dimmpxm b/tests/data/acpi/pc/DSDT.dimmpxm
index 247a1796b1..38865fb667 100644
--- a/tests/data/acpi/pc/DSDT.dimmpxm
+++ b/tests/data/acpi/pc/DSDT.dimmpxm
Binary files differ
diff --git a/tests/data/acpi/pc/DSDT.hpbridge b/tests/data/acpi/pc/DSDT.hpbridge
index d5a2ca5165..abcd6d9d30 100644
--- a/tests/data/acpi/pc/DSDT.hpbridge
+++ b/tests/data/acpi/pc/DSDT.hpbridge
Binary files differ
diff --git a/tests/data/acpi/pc/DSDT.hpbrroot b/tests/data/acpi/pc/DSDT.hpbrroot
index ec99b16229..dd2c8c0c8c 100644
--- a/tests/data/acpi/pc/DSDT.hpbrroot
+++ b/tests/data/acpi/pc/DSDT.hpbrroot
Binary files differ
diff --git a/tests/data/acpi/pc/DSDT.ipmikcs b/tests/data/acpi/pc/DSDT.ipmikcs
index f0d9e75841..e819ce6946 100644
--- a/tests/data/acpi/pc/DSDT.ipmikcs
+++ b/tests/data/acpi/pc/DSDT.ipmikcs
Binary files differ
diff --git a/tests/data/acpi/pc/DSDT.memhp b/tests/data/acpi/pc/DSDT.memhp
index d0a7c46209..03a9decdc1 100644
--- a/tests/data/acpi/pc/DSDT.memhp
+++ b/tests/data/acpi/pc/DSDT.memhp
Binary files differ
diff --git a/tests/data/acpi/pc/DSDT.nohpet b/tests/data/acpi/pc/DSDT.nohpet
index cb7bf7d850..b413d9f31d 100644
--- a/tests/data/acpi/pc/DSDT.nohpet
+++ b/tests/data/acpi/pc/DSDT.nohpet
Binary files differ
diff --git a/tests/data/acpi/pc/DSDT.numamem b/tests/data/acpi/pc/DSDT.numamem
index 2f512cfbe1..9e701b2983 100644
--- a/tests/data/acpi/pc/DSDT.numamem
+++ b/tests/data/acpi/pc/DSDT.numamem
Binary files differ
diff --git a/tests/data/acpi/pc/DSDT.roothp b/tests/data/acpi/pc/DSDT.roothp
index 46e03d39e0..8c3956c9ec 100644
--- a/tests/data/acpi/pc/DSDT.roothp
+++ b/tests/data/acpi/pc/DSDT.roothp
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT b/tests/data/acpi/q35/DSDT
index 2cd8d5fc47..3870958969 100644
--- a/tests/data/acpi/q35/DSDT
+++ b/tests/data/acpi/q35/DSDT
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.acpierst b/tests/data/acpi/q35/DSDT.acpierst
index 0bc5de8065..c9c18fa4e4 100644
--- a/tests/data/acpi/q35/DSDT.acpierst
+++ b/tests/data/acpi/q35/DSDT.acpierst
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.acpihmat b/tests/data/acpi/q35/DSDT.acpihmat
index af10345e88..a32e90b5d9 100644
--- a/tests/data/acpi/q35/DSDT.acpihmat
+++ b/tests/data/acpi/q35/DSDT.acpihmat
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.applesmc b/tests/data/acpi/q35/DSDT.applesmc
index 00092aacc6..5507b6b8f5 100644
--- a/tests/data/acpi/q35/DSDT.applesmc
+++ b/tests/data/acpi/q35/DSDT.applesmc
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.bridge b/tests/data/acpi/q35/DSDT.bridge
index d820098355..a42eb674fa 100644
--- a/tests/data/acpi/q35/DSDT.bridge
+++ b/tests/data/acpi/q35/DSDT.bridge
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.cphp b/tests/data/acpi/q35/DSDT.cphp
index ac8456a43d..2d8cb603c9 100644
--- a/tests/data/acpi/q35/DSDT.cphp
+++ b/tests/data/acpi/q35/DSDT.cphp
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.cxl b/tests/data/acpi/q35/DSDT.cxl
index 369ae90196..20d0fb64ea 100644
--- a/tests/data/acpi/q35/DSDT.cxl
+++ b/tests/data/acpi/q35/DSDT.cxl
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.dimmpxm b/tests/data/acpi/q35/DSDT.dimmpxm
index bb0eadf869..b23339513a 100644
--- a/tests/data/acpi/q35/DSDT.dimmpxm
+++ b/tests/data/acpi/q35/DSDT.dimmpxm
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.ipmibt b/tests/data/acpi/q35/DSDT.ipmibt
index bb25827950..8af2695ede 100644
--- a/tests/data/acpi/q35/DSDT.ipmibt
+++ b/tests/data/acpi/q35/DSDT.ipmibt
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.ipmismbus b/tests/data/acpi/q35/DSDT.ipmismbus
index 15000c357f..479df48cd3 100644
--- a/tests/data/acpi/q35/DSDT.ipmismbus
+++ b/tests/data/acpi/q35/DSDT.ipmismbus
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.ivrs b/tests/data/acpi/q35/DSDT.ivrs
index 0bc5de8065..c9c18fa4e4 100644
--- a/tests/data/acpi/q35/DSDT.ivrs
+++ b/tests/data/acpi/q35/DSDT.ivrs
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.memhp b/tests/data/acpi/q35/DSDT.memhp
index 663456fc0d..a5730b8ab8 100644
--- a/tests/data/acpi/q35/DSDT.memhp
+++ b/tests/data/acpi/q35/DSDT.memhp
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.mmio64 b/tests/data/acpi/q35/DSDT.mmio64
index 91afd01d59..a4293c20fe 100644
--- a/tests/data/acpi/q35/DSDT.mmio64
+++ b/tests/data/acpi/q35/DSDT.mmio64
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.multi-bridge b/tests/data/acpi/q35/DSDT.multi-bridge
index afde339a18..88bf47ab18 100644
--- a/tests/data/acpi/q35/DSDT.multi-bridge
+++ b/tests/data/acpi/q35/DSDT.multi-bridge
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.nohpet b/tests/data/acpi/q35/DSDT.nohpet
index 0fb09121cf..6feed2ee10 100644
--- a/tests/data/acpi/q35/DSDT.nohpet
+++ b/tests/data/acpi/q35/DSDT.nohpet
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.numamem b/tests/data/acpi/q35/DSDT.numamem
index e537669949..414b8af67b 100644
--- a/tests/data/acpi/q35/DSDT.numamem
+++ b/tests/data/acpi/q35/DSDT.numamem
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.pvpanic-isa b/tests/data/acpi/q35/DSDT.pvpanic-isa
index cc545b5d25..7277a01050 100644
--- a/tests/data/acpi/q35/DSDT.pvpanic-isa
+++ b/tests/data/acpi/q35/DSDT.pvpanic-isa
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.tis.tpm12 b/tests/data/acpi/q35/DSDT.tis.tpm12
index a97d884c50..253a66e658 100644
--- a/tests/data/acpi/q35/DSDT.tis.tpm12
+++ b/tests/data/acpi/q35/DSDT.tis.tpm12
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.tis.tpm2 b/tests/data/acpi/q35/DSDT.tis.tpm2
index 1f5392919b..76bd4661e6 100644
--- a/tests/data/acpi/q35/DSDT.tis.tpm2
+++ b/tests/data/acpi/q35/DSDT.tis.tpm2
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.viot b/tests/data/acpi/q35/DSDT.viot
index e20e4ee5e9..3f14b57f07 100644
--- a/tests/data/acpi/q35/DSDT.viot
+++ b/tests/data/acpi/q35/DSDT.viot
Binary files differ
diff --git a/tests/data/acpi/q35/DSDT.xapic b/tests/data/acpi/q35/DSDT.xapic
index 3cab5956ee..baa88f6f21 100644
--- a/tests/data/acpi/q35/DSDT.xapic
+++ b/tests/data/acpi/q35/DSDT.xapic
Binary files differ
diff --git a/tests/data/acpi/virt/GTDT b/tests/data/acpi/virt/GTDT
index 9408b71b59..6f8cb9b8f3 100644
--- a/tests/data/acpi/virt/GTDT
+++ b/tests/data/acpi/virt/GTDT
Binary files differ
diff --git a/tests/data/acpi/virt/GTDT.memhp b/tests/data/acpi/virt/GTDT.memhp
index 9408b71b59..6f8cb9b8f3 100644
--- a/tests/data/acpi/virt/GTDT.memhp
+++ b/tests/data/acpi/virt/GTDT.memhp
Binary files differ
diff --git a/tests/data/acpi/virt/GTDT.numamem b/tests/data/acpi/virt/GTDT.numamem
index 9408b71b59..6f8cb9b8f3 100644
--- a/tests/data/acpi/virt/GTDT.numamem
+++ b/tests/data/acpi/virt/GTDT.numamem
Binary files differ
diff --git a/tests/qtest/libqos/meson.build b/tests/qtest/libqos/meson.build
index cff83c86d9..a5b6d5197a 100644
--- a/tests/qtest/libqos/meson.build
+++ b/tests/qtest/libqos/meson.build
@@ -45,6 +45,7 @@ libqos_srcs = files(
'virtio-scsi.c',
'virtio-serial.c',
'virtio-iommu.c',
+ 'virtio-gpio.c',
'generic-pcihost.c',
# qgraph machines:
diff --git a/tests/qtest/libqos/virtio-gpio.c b/tests/qtest/libqos/virtio-gpio.c
new file mode 100644
index 0000000000..762aa6695b
--- /dev/null
+++ b/tests/qtest/libqos/virtio-gpio.c
@@ -0,0 +1,171 @@
+/*
+ * virtio-gpio nodes for testing
+ *
+ * Copyright (c) 2022 Linaro Ltd
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "standard-headers/linux/virtio_config.h"
+#include "../libqtest.h"
+#include "qemu/module.h"
+#include "qgraph.h"
+#include "virtio-gpio.h"
+
+static QGuestAllocator *alloc;
+
+static void virtio_gpio_cleanup(QVhostUserGPIO *gpio)
+{
+ QVirtioDevice *vdev = gpio->vdev;
+ int i;
+
+ for (i = 0; i < 2; i++) {
+ qvirtqueue_cleanup(vdev->bus, gpio->queues[i], alloc);
+ }
+ g_free(gpio->queues);
+}
+
+/*
+ * This handles the VirtIO setup from the point of view of the driver
+ * frontend and therefor doesn't present any vhost specific features
+ * and in fact masks of the re-used bit.
+ */
+static void virtio_gpio_setup(QVhostUserGPIO *gpio)
+{
+ QVirtioDevice *vdev = gpio->vdev;
+ uint64_t features;
+ int i;
+
+ features = qvirtio_get_features(vdev);
+ features &= ~QVIRTIO_F_BAD_FEATURE;
+ qvirtio_set_features(vdev, features);
+
+ gpio->queues = g_new(QVirtQueue *, 2);
+ for (i = 0; i < 2; i++) {
+ gpio->queues[i] = qvirtqueue_setup(vdev, alloc, i);
+ }
+ qvirtio_set_driver_ok(vdev);
+}
+
+static void *qvirtio_gpio_get_driver(QVhostUserGPIO *v_gpio,
+ const char *interface)
+{
+ if (!g_strcmp0(interface, "vhost-user-gpio")) {
+ return v_gpio;
+ }
+ if (!g_strcmp0(interface, "virtio")) {
+ return v_gpio->vdev;
+ }
+
+ g_assert_not_reached();
+}
+
+static void *qvirtio_gpio_device_get_driver(void *object,
+ const char *interface)
+{
+ QVhostUserGPIODevice *v_gpio = object;
+ return qvirtio_gpio_get_driver(&v_gpio->gpio, interface);
+}
+
+/* virtio-gpio (mmio) */
+static void qvirtio_gpio_device_destructor(QOSGraphObject *obj)
+{
+ QVhostUserGPIODevice *gpio_dev = (QVhostUserGPIODevice *) obj;
+ virtio_gpio_cleanup(&gpio_dev->gpio);
+}
+
+static void qvirtio_gpio_device_start_hw(QOSGraphObject *obj)
+{
+ QVhostUserGPIODevice *gpio_dev = (QVhostUserGPIODevice *) obj;
+ virtio_gpio_setup(&gpio_dev->gpio);
+}
+
+static void *virtio_gpio_device_create(void *virtio_dev,
+ QGuestAllocator *t_alloc,
+ void *addr)
+{
+ QVhostUserGPIODevice *virtio_device = g_new0(QVhostUserGPIODevice, 1);
+ QVhostUserGPIO *interface = &virtio_device->gpio;
+
+ interface->vdev = virtio_dev;
+ alloc = t_alloc;
+
+ virtio_device->obj.get_driver = qvirtio_gpio_device_get_driver;
+ virtio_device->obj.start_hw = qvirtio_gpio_device_start_hw;
+ virtio_device->obj.destructor = qvirtio_gpio_device_destructor;
+
+ return &virtio_device->obj;
+}
+
+/* virtio-gpio-pci */
+static void qvirtio_gpio_pci_destructor(QOSGraphObject *obj)
+{
+ QVhostUserGPIOPCI *gpio_pci = (QVhostUserGPIOPCI *) obj;
+ QOSGraphObject *pci_vobj = &gpio_pci->pci_vdev.obj;
+
+ virtio_gpio_cleanup(&gpio_pci->gpio);
+ qvirtio_pci_destructor(pci_vobj);
+}
+
+static void qvirtio_gpio_pci_start_hw(QOSGraphObject *obj)
+{
+ QVhostUserGPIOPCI *gpio_pci = (QVhostUserGPIOPCI *) obj;
+ QOSGraphObject *pci_vobj = &gpio_pci->pci_vdev.obj;
+
+ qvirtio_pci_start_hw(pci_vobj);
+ virtio_gpio_setup(&gpio_pci->gpio);
+}
+
+static void *qvirtio_gpio_pci_get_driver(void *object, const char *interface)
+{
+ QVhostUserGPIOPCI *v_gpio = object;
+
+ if (!g_strcmp0(interface, "pci-device")) {
+ return v_gpio->pci_vdev.pdev;
+ }
+ return qvirtio_gpio_get_driver(&v_gpio->gpio, interface);
+}
+
+static void *virtio_gpio_pci_create(void *pci_bus, QGuestAllocator *t_alloc,
+ void *addr)
+{
+ QVhostUserGPIOPCI *virtio_spci = g_new0(QVhostUserGPIOPCI, 1);
+ QVhostUserGPIO *interface = &virtio_spci->gpio;
+ QOSGraphObject *obj = &virtio_spci->pci_vdev.obj;
+
+ virtio_pci_init(&virtio_spci->pci_vdev, pci_bus, addr);
+ interface->vdev = &virtio_spci->pci_vdev.vdev;
+ alloc = t_alloc;
+
+ obj->get_driver = qvirtio_gpio_pci_get_driver;
+ obj->start_hw = qvirtio_gpio_pci_start_hw;
+ obj->destructor = qvirtio_gpio_pci_destructor;
+
+ return obj;
+}
+
+static void virtio_gpio_register_nodes(void)
+{
+ QPCIAddress addr = {
+ .devfn = QPCI_DEVFN(4, 0),
+ };
+
+ QOSGraphEdgeOptions edge_opts = { };
+
+ /* vhost-user-gpio-device */
+ edge_opts.extra_device_opts = "id=gpio0,chardev=chr-vhost-user-test";
+ qos_node_create_driver("vhost-user-gpio-device",
+ virtio_gpio_device_create);
+ qos_node_consumes("vhost-user-gpio-device", "virtio-bus", &edge_opts);
+ qos_node_produces("vhost-user-gpio-device", "vhost-user-gpio");
+
+ /* virtio-gpio-pci */
+ edge_opts.extra_device_opts = "id=gpio0,addr=04.0,chardev=chr-vhost-user-test";
+ add_qpci_address(&edge_opts, &addr);
+ qos_node_create_driver("vhost-user-gpio-pci", virtio_gpio_pci_create);
+ qos_node_consumes("vhost-user-gpio-pci", "pci-bus", &edge_opts);
+ qos_node_produces("vhost-user-gpio-pci", "vhost-user-gpio");
+}
+
+libqos_init(virtio_gpio_register_nodes);
diff --git a/tests/qtest/libqos/virtio-gpio.h b/tests/qtest/libqos/virtio-gpio.h
new file mode 100644
index 0000000000..f11d41bd19
--- /dev/null
+++ b/tests/qtest/libqos/virtio-gpio.h
@@ -0,0 +1,35 @@
+/*
+ * virtio-gpio structures
+ *
+ * Copyright (c) 2022 Linaro Ltd
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef TESTS_LIBQOS_VIRTIO_GPIO_H
+#define TESTS_LIBQOS_VIRTIO_GPIO_H
+
+#include "qgraph.h"
+#include "virtio.h"
+#include "virtio-pci.h"
+
+typedef struct QVhostUserGPIO QVhostUserGPIO;
+typedef struct QVhostUserGPIOPCI QVhostUserGPIOPCI;
+typedef struct QVhostUserGPIODevice QVhostUserGPIODevice;
+
+struct QVhostUserGPIO {
+ QVirtioDevice *vdev;
+ QVirtQueue **queues;
+};
+
+struct QVhostUserGPIOPCI {
+ QVirtioPCIDevice pci_vdev;
+ QVhostUserGPIO gpio;
+};
+
+struct QVhostUserGPIODevice {
+ QOSGraphObject obj;
+ QVhostUserGPIO gpio;
+};
+
+#endif
diff --git a/tests/qtest/libqos/virtio.c b/tests/qtest/libqos/virtio.c
index 09ec09b655..410513225f 100644
--- a/tests/qtest/libqos/virtio.c
+++ b/tests/qtest/libqos/virtio.c
@@ -101,6 +101,8 @@ uint64_t qvirtio_get_features(QVirtioDevice *d)
void qvirtio_set_features(QVirtioDevice *d, uint64_t features)
{
+ g_assert(!(features & QVIRTIO_F_BAD_FEATURE));
+
d->features = features;
d->bus->set_features(d, features);
@@ -108,7 +110,7 @@ void qvirtio_set_features(QVirtioDevice *d, uint64_t features)
* This could be a separate function for drivers that want to access
* configuration space before setting FEATURES_OK, but no existing users
* need that and it's less code for callers if this is done implicitly.
- */
+ */
if (features & (1ull << VIRTIO_F_VERSION_1)) {
uint8_t status = d->bus->get_status(d) |
VIRTIO_CONFIG_S_FEATURES_OK;
diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c
index af00712458..897e4e937b 100644
--- a/tests/qtest/qmp-cmd-test.c
+++ b/tests/qtest/qmp-cmd-test.c
@@ -103,6 +103,7 @@ static bool query_is_ignored(const char *cmd)
"query-gic-capabilities", /* arm */
/* Success depends on target-specific build configuration: */
"query-pci", /* CONFIG_PCI */
+ "x-query-virtio", /* CONFIG_VIRTIO */
/* Success depends on launching SEV guest */
"query-sev-launch-measure",
/* Success depends on Host or Hypervisor SEV support */
diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c
index 831db5cf2a..5da4091ec3 100644
--- a/tests/qtest/qos-test.c
+++ b/tests/qtest/qos-test.c
@@ -185,7 +185,9 @@ static void run_one_test(const void *arg)
static void subprocess_run_one_test(const void *arg)
{
const gchar *path = arg;
- g_test_trap_subprocess(path, 0, 0);
+ g_test_trap_subprocess(path, 180 * G_USEC_PER_SEC,
+ G_TEST_SUBPROCESS_INHERIT_STDOUT |
+ G_TEST_SUBPROCESS_INHERIT_STDERR);
g_test_trap_assert_passed();
}
@@ -319,6 +321,11 @@ static void walk_path(QOSGraphNode *orig_path, int len)
int main(int argc, char **argv, char** envp)
{
g_test_init(&argc, &argv, NULL);
+
+ if (g_test_subprocess()) {
+ qos_printf("qos_test running single test in subprocess\n");
+ }
+
if (g_test_verbose()) {
qos_printf("ENVIRONMENT VARIABLES: {\n");
for (char **env = envp; *env != 0; env++) {
diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c
index 84498941a6..e8d2da7228 100644
--- a/tests/qtest/vhost-user-test.c
+++ b/tests/qtest/vhost-user-test.c
@@ -26,11 +26,13 @@
#include "libqos/virtio-pci.h"
#include "libqos/malloc-pc.h"
+#include "libqos/qgraph_internal.h"
#include "hw/virtio/virtio-net.h"
#include "standard-headers/linux/vhost_types.h"
#include "standard-headers/linux/virtio_ids.h"
#include "standard-headers/linux/virtio_net.h"
+#include "standard-headers/linux/virtio_gpio.h"
#ifdef CONFIG_LINUX
#include <sys/vfs.h>
@@ -52,9 +54,12 @@
#define VHOST_MAX_VIRTQUEUES 0x100
#define VHOST_USER_F_PROTOCOL_FEATURES 30
+#define VIRTIO_F_VERSION_1 32
+
#define VHOST_USER_PROTOCOL_F_MQ 0
#define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1
#define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN 6
+#define VHOST_USER_PROTOCOL_F_CONFIG 9
#define VHOST_LOG_PAGE 0x1000
@@ -78,6 +83,8 @@ typedef enum VhostUserRequest {
VHOST_USER_SET_PROTOCOL_FEATURES = 16,
VHOST_USER_GET_QUEUE_NUM = 17,
VHOST_USER_SET_VRING_ENABLE = 18,
+ VHOST_USER_GET_CONFIG = 24,
+ VHOST_USER_SET_CONFIG = 25,
VHOST_USER_MAX
} VhostUserRequest;
@@ -137,6 +144,7 @@ enum {
enum {
VHOST_USER_NET,
+ VHOST_USER_GPIO,
};
typedef struct TestServer {
@@ -168,10 +176,11 @@ struct vhost_user_ops {
const char *chr_opts);
/* VHOST-USER commands. */
+ uint64_t (*get_features)(TestServer *s);
void (*set_features)(TestServer *s, CharBackend *chr,
- VhostUserMsg *msg);
+ VhostUserMsg *msg);
void (*get_protocol_features)(TestServer *s,
- CharBackend *chr, VhostUserMsg *msg);
+ CharBackend *chr, VhostUserMsg *msg);
};
static const char *init_hugepagefs(void);
@@ -194,6 +203,19 @@ static void append_vhost_net_opts(TestServer *s, GString *cmd_line,
chr_opts, s->chr_name);
}
+/*
+ * For GPIO there are no other magic devices we need to add (like
+ * block or netdev) so all we need to worry about is the vhost-user
+ * chardev socket.
+ */
+static void append_vhost_gpio_opts(TestServer *s, GString *cmd_line,
+ const char *chr_opts)
+{
+ g_string_append_printf(cmd_line, QEMU_CMD_CHR,
+ s->chr_name, s->socket_path,
+ chr_opts);
+}
+
static void append_mem_opts(TestServer *server, GString *cmd_line,
int size, enum test_memfd memfd)
{
@@ -316,7 +338,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
}
if (size != VHOST_USER_HDR_SIZE) {
- g_test_message("Wrong message size received %d", size);
+ qos_printf("%s: Wrong message size received %d\n", __func__, size);
return;
}
@@ -327,28 +349,30 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
p += VHOST_USER_HDR_SIZE;
size = qemu_chr_fe_read_all(chr, p, msg.size);
if (size != msg.size) {
- g_test_message("Wrong message size received %d != %d",
- size, msg.size);
+ qos_printf("%s: Wrong message size received %d != %d\n",
+ __func__, size, msg.size);
return;
}
}
switch (msg.request) {
case VHOST_USER_GET_FEATURES:
+ /* Mandatory for tests to define get_features */
+ g_assert(s->vu_ops->get_features);
+
/* send back features to qemu */
msg.flags |= VHOST_USER_REPLY_MASK;
msg.size = sizeof(m.payload.u64);
- msg.payload.u64 = 0x1ULL << VHOST_F_LOG_ALL |
- 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES;
- if (s->queues > 1) {
- msg.payload.u64 |= 0x1ULL << VIRTIO_NET_F_MQ;
- }
+
if (s->test_flags >= TEST_FLAGS_BAD) {
msg.payload.u64 = 0;
s->test_flags = TEST_FLAGS_END;
+ } else {
+ msg.payload.u64 = s->vu_ops->get_features(s);
}
- p = (uint8_t *) &msg;
- qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size);
+
+ qemu_chr_fe_write_all(chr, (uint8_t *) &msg,
+ VHOST_USER_HDR_SIZE + msg.size);
break;
case VHOST_USER_SET_FEATURES:
@@ -357,12 +381,55 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
}
break;
+ case VHOST_USER_SET_OWNER:
+ /*
+ * We don't need to do anything here, the remote is just
+ * letting us know it is in charge. Just log it.
+ */
+ qos_printf("set_owner: start of session\n");
+ break;
+
case VHOST_USER_GET_PROTOCOL_FEATURES:
if (s->vu_ops->get_protocol_features) {
s->vu_ops->get_protocol_features(s, chr, &msg);
}
break;
+ case VHOST_USER_GET_CONFIG:
+ /*
+ * Treat GET_CONFIG as a NOP and just reply and let the guest
+ * consider we have updated its memory. Tests currently don't
+ * require working configs.
+ */
+ msg.flags |= VHOST_USER_REPLY_MASK;
+ p = (uint8_t *) &msg;
+ qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size);
+ break;
+
+ case VHOST_USER_SET_PROTOCOL_FEATURES:
+ /*
+ * We did set VHOST_USER_F_PROTOCOL_FEATURES so its valid for
+ * the remote end to send this. There is no handshake reply so
+ * just log the details for debugging.
+ */
+ qos_printf("set_protocol_features: 0x%"PRIx64 "\n", msg.payload.u64);
+ break;
+
+ /*
+ * A real vhost-user backend would actually set the size and
+ * address of the vrings but we can simply report them.
+ */
+ case VHOST_USER_SET_VRING_NUM:
+ qos_printf("set_vring_num: %d/%d\n",
+ msg.payload.state.index, msg.payload.state.num);
+ break;
+ case VHOST_USER_SET_VRING_ADDR:
+ qos_printf("set_vring_addr: 0x%"PRIx64"/0x%"PRIx64"/0x%"PRIx64"\n",
+ msg.payload.addr.avail_user_addr,
+ msg.payload.addr.desc_user_addr,
+ msg.payload.addr.used_user_addr);
+ break;
+
case VHOST_USER_GET_VRING_BASE:
/* send back vring base to qemu */
msg.flags |= VHOST_USER_REPLY_MASK;
@@ -427,7 +494,18 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size);
break;
+ case VHOST_USER_SET_VRING_ENABLE:
+ /*
+ * Another case we ignore as we don't need to respond. With a
+ * fully functioning vhost-user we would enable/disable the
+ * vring monitoring.
+ */
+ qos_printf("set_vring(%d)=%s\n", msg.payload.state.index,
+ msg.payload.state.num ? "enabled" : "disabled");
+ break;
+
default:
+ qos_printf("vhost-user: un-handled message: %d\n", msg.request);
break;
}
@@ -450,7 +528,7 @@ static const char *init_hugepagefs(void)
}
if (access(path, R_OK | W_OK | X_OK)) {
- g_test_message("access on path (%s): %s", path, strerror(errno));
+ qos_printf("access on path (%s): %s", path, strerror(errno));
g_test_fail();
return NULL;
}
@@ -460,13 +538,13 @@ static const char *init_hugepagefs(void)
} while (ret != 0 && errno == EINTR);
if (ret != 0) {
- g_test_message("statfs on path (%s): %s", path, strerror(errno));
+ qos_printf("statfs on path (%s): %s", path, strerror(errno));
g_test_fail();
return NULL;
}
if (fs.f_type != HUGETLBFS_MAGIC) {
- g_test_message("Warning: path not on HugeTLBFS: %s", path);
+ qos_printf("Warning: path not on HugeTLBFS: %s", path);
g_test_fail();
return NULL;
}
@@ -938,11 +1016,23 @@ static void test_multiqueue(void *obj, void *arg, QGuestAllocator *alloc)
wait_for_rings_started(s, s->queues * 2);
}
+
+static uint64_t vu_net_get_features(TestServer *s)
+{
+ uint64_t features = 0x1ULL << VHOST_F_LOG_ALL |
+ 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES;
+
+ if (s->queues > 1) {
+ features |= 0x1ULL << VIRTIO_NET_F_MQ;
+ }
+
+ return features;
+}
+
static void vu_net_set_features(TestServer *s, CharBackend *chr,
- VhostUserMsg *msg)
+ VhostUserMsg *msg)
{
- g_assert_cmpint(msg->payload.u64 &
- (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES), !=, 0ULL);
+ g_assert(msg->payload.u64 & (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES));
if (s->test_flags == TEST_FLAGS_DISCONNECT) {
qemu_chr_fe_disconnect(chr);
s->test_flags = TEST_FLAGS_BAD;
@@ -969,6 +1059,7 @@ static struct vhost_user_ops g_vu_net_ops = {
.append_opts = append_vhost_net_opts,
+ .get_features = vu_net_get_features,
.set_features = vu_net_set_features,
.get_protocol_features = vu_net_get_protocol_features,
};
@@ -1017,3 +1108,51 @@ static void register_vhost_user_test(void)
test_multiqueue, &opts);
}
libqos_init(register_vhost_user_test);
+
+static uint64_t vu_gpio_get_features(TestServer *s)
+{
+ return 0x1ULL << VIRTIO_F_VERSION_1 |
+ 0x1ULL << VIRTIO_GPIO_F_IRQ |
+ 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES;
+}
+
+/*
+ * This stub can't handle all the message types but we should reply
+ * that we support VHOST_USER_PROTOCOL_F_CONFIG as gpio would use it
+ * talking to a read vhost-user daemon.
+ */
+static void vu_gpio_get_protocol_features(TestServer *s, CharBackend *chr,
+ VhostUserMsg *msg)
+{
+ /* send back features to qemu */
+ msg->flags |= VHOST_USER_REPLY_MASK;
+ msg->size = sizeof(m.payload.u64);
+ msg->payload.u64 = 1ULL << VHOST_USER_PROTOCOL_F_CONFIG;
+
+ qemu_chr_fe_write_all(chr, (uint8_t *)msg, VHOST_USER_HDR_SIZE + msg->size);
+}
+
+static struct vhost_user_ops g_vu_gpio_ops = {
+ .type = VHOST_USER_GPIO,
+
+ .append_opts = append_vhost_gpio_opts,
+
+ .get_features = vu_gpio_get_features,
+ .set_features = vu_net_set_features,
+ .get_protocol_features = vu_gpio_get_protocol_features,
+};
+
+static void register_vhost_gpio_test(void)
+{
+ QOSGraphTestOptions opts = {
+ .before = vhost_user_test_setup,
+ .subprocess = true,
+ .arg = &g_vu_gpio_ops,
+ };
+
+ qemu_add_opts(&qemu_chardev_opts);
+
+ qos_add_test("read-guest-mem/memfile",
+ "vhost-user-gpio", test_read_guest_mem, &opts);
+}
+libqos_init(register_vhost_gpio_test);