Skip to contentSkip to conversation

qtests/libqos: Introduce pci-arm

PATCH Superseded Eric Auger 3 participants 15 messages Jan 10, 2022 – Jan 18, 2022 Arm/Amlogic Meson SoC support

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Eric Auger

author
#0 lore raw

cover qtests/libqos: Introduce pci-arm

Up to now the virt-machine node only contains a virtio-mmio driver node but no driver that eventually produces any pci-bus interface.

Hence, PCI libqos tests cannot be run with aarch64 binary.

This series brings the pieces needed to be able to run PCI tests with the aarch64 binary: a generic-pcihost driver node gets instantiated by the machine. This later contains a pci-bus-arm driver which produces a pci-bus interface. Then all tests consuming the pci-bus interface can be run with the libqos arm virt machine.

One of the first goal was to be able to run the virtio-iommu-pci tests as the virtio-iommu was initially targetting ARM and it was awkard to be run the test with the pc machine. This is now possible.

Only the tests doing hotplug cannot be run yet as hotplug is not possible on the root bus. This will be dealt with separately by adding a root port to the object tree.

Best Regards

Eric

This series can be found at:
https://github.com/eauger/qemu/tree/libqos-pci-arm-v1

Eric Auger (6):
tests/qtest/vhost-user-test.c: Use vhostforce=on tests/qtest/libqos/pci: Introduce pio_limit tests/qtest/libqos: Skip hotplug tests if pci root bus is not
hotpluggable
tests/qtest/vhost-user-blk-test: Setup MSIx to avoid error on aarch64 tests/qtest/vhost-user-blk-test: Factorize vq setup code tests/qtest/libqos: Add pci-arm and add a pci-arm producer in arm-virt
machine

 tests/qtest/e1000e-test.c             |   6 +
 tests/qtest/libqos/arm-virt-machine.c |  47 +++++-
 tests/qtest/libqos/meson.build        |   3 +
 tests/qtest/libqos/pci-arm.c          | 219 ++++++++++++++++++++++++++
 tests/qtest/libqos/pci-arm.h          |  56 +++++++
 tests/qtest/libqos/pci-pc.c           |   1 +
 tests/qtest/libqos/pci-spapr.c        |   1 +
 tests/qtest/libqos/pci.c              |  78 +++++----
 tests/qtest/libqos/pci.h              |   7 +-
 tests/qtest/libqos/qgraph.c           |   7 +
 tests/qtest/libqos/qgraph.h           |  15 ++
 tests/qtest/vhost-user-blk-test.c     |  39 ++++-
 tests/qtest/vhost-user-test.c         |   2 +-
 tests/qtest/virtio-blk-test.c         |   5 +
 tests/qtest/virtio-net-test.c         |   5 +
 tests/qtest/virtio-rng-test.c         |   5 +
 16 files changed, 452 insertions(+), 44 deletions(-)
 create mode 100644 tests/qtest/libqos/pci-arm.c
 create mode 100644 tests/qtest/libqos/pci-arm.h
Signature · 1 line
2.26.3
author
#1 lore raw

PATCH 1/6 tests/qtest/vhost-user-test.c: Use vhostforce=on

-netdev vhost-user,vhostforce is deprecated and vhostforce=on should be used instead.

---
 tests/qtest/vhost-user-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/vhost-user-test.c +1 -1
index 3d6337fb5c5..6e79935c47e 100644
@@ -42,7 +42,7 @@
 #define QEMU_CMD_MEMFD  " -m %d -object memory-backend-memfd,id=mem,size=%dM," \
                         " -numa node,memdev=mem"
 #define QEMU_CMD_CHR    " -chardev socket,id=%s,path=%s%s"
-#define QEMU_CMD_NETDEV " -netdev vhost-user,id=hs0,chardev=%s,vhostforce"
+#define QEMU_CMD_NETDEV " -netdev vhost-user,id=hs0,chardev=%s,vhostforce=on"
 
 #define HUGETLBFS_MAGIC       0x958458f6
 
Signature · 1 line
2.26.3
Reviewed-by on v1 1/6
#2 lore raw

Re: [PATCH 1/6] tests/qtest/vhost-user-test.c: Use vhostforce=on

Quoted 13 lines · Eric Auger

-netdev vhost-user,vhostforce is deprecated and vhostforce=on should be used instead.

---
  tests/qtest/vhost-user-test.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/vhost-user-test.c +0 -0
index 3d6337fb5c5..6e79935c47e 100644

tests/qtest/vhost-user-test.c line 48

Quoted 8 lines
tests/qtest/vhost-user-test.c +1 -1
@@ -42,7 +42,7 @@
  #define QEMU_CMD_MEMFD  " -m %d -object memory-backend-memfd,id=mem,size=%dM," \
                          " -numa node,memdev=mem"
  #define QEMU_CMD_CHR    " -chardev socket,id=%s,path=%s%s"
-#define QEMU_CMD_NETDEV " -netdev vhost-user,id=hs0,chardev=%s,vhostforce"
+#define QEMU_CMD_NETDEV " -netdev vhost-user,id=hs0,chardev=%s,vhostforce=on"
 
  #define HUGETLBFS_MAGIC       0x958458f6
 
author
#3 lore raw

PATCH 2/6 tests/qtest/libqos/pci: Introduce pio_limit

In reply to Eric Auger

At the moment the IO space limit is hardcoded to QPCI_PIO_LIMIT = 0x10000. When accesses are performed to a bar, the base address of this latter is compared against the limit to decide whether we perform an IO or a memory access.

On ARM, we cannot keep this PIO limit as the arm-virt machine uses [0x3eff0000, 0x3f000000 ] for the IO space map and we are mandated to allocate at 0x0.

Add a new flag in QPCIBar indicating whether it is an IO bar or a memory bar. This flag is set on QPCIBar allocation and provisionned based on the BAR configuration. Then the new flag is used in access functions and in iomap() function.

---
 tests/qtest/libqos/pci-pc.c    |  1 +
 tests/qtest/libqos/pci-spapr.c |  1 +
 tests/qtest/libqos/pci.c       | 78 ++++++++++++++++++++++------------
 tests/qtest/libqos/pci.h       |  5 +--
 4 files changed, 54 insertions(+), 31 deletions(-)
tests/qtest/libqos/pci-pc.c +1 -0
index f97844289f1..8051a0881a0 100644
@@ -150,6 +150,7 @@ void qpci_init_pc(QPCIBusPC *qpci, QTestState *qts, QGuestAllocator *alloc)
 
     qpci->bus.qts = qts;
     qpci->bus.pio_alloc_ptr = 0xc000;
+    qpci->bus.pio_limit = 0x10000;
     qpci->bus.mmio_alloc_ptr = 0xE0000000;
     qpci->bus.mmio_limit = 0x100000000ULL;
 
tests/qtest/libqos/pci-spapr.c +1 -0
index 262226985f3..870ffdd8b51 100644
@@ -197,6 +197,7 @@ void qpci_init_spapr(QPCIBusSPAPR *qpci, QTestState *qts,
 
     qpci->bus.qts = qts;
     qpci->bus.pio_alloc_ptr = 0xc000;
+    qpci->bus.pio_limit = 0x10000;
     qpci->bus.mmio_alloc_ptr = qpci->mmio32.pci_base;
     qpci->bus.mmio_limit = qpci->mmio32.pci_base + qpci->mmio32.size;
 
tests/qtest/libqos/pci.c +50 -28

173 lines not on this page · raw message

tests/qtest/libqos/pci.h +2 -3
index becb800f9e6..44f6806fe44 100644
@@ -16,8 +16,6 @@
 #include "libqtest.h"
 #include "qgraph.h"
 
-#define QPCI_PIO_LIMIT    0x10000
-
 #define QPCI_DEVFN(dev, fn) (((dev) << 3) | (fn))
 
 typedef struct QPCIDevice QPCIDevice;
@@ -51,7 +49,7 @@ struct QPCIBus {
                           uint8_t offset, uint32_t value);
 
     QTestState *qts;
-    uint16_t pio_alloc_ptr;
+    uint64_t pio_alloc_ptr, pio_limit;
     uint64_t mmio_alloc_ptr, mmio_limit;
     bool has_buggy_msi; /* TRUE for spapr, FALSE for pci */
 
@@ -59,6 +57,7 @@ struct QPCIBus {
 
 struct QPCIBar {
     uint64_t addr;
+    bool is_io;
 };
 
 struct QPCIDevice
Signature · 1 line
2.26.3
Reviewed-by on v1 2/6
#4 lore raw

Re: [PATCH 2/6] tests/qtest/libqos/pci: Introduce pio_limit

Quoted 14 lines · Eric Auger

At the moment the IO space limit is hardcoded to QPCI_PIO_LIMIT = 0x10000. When accesses are performed to a bar, the base address of this latter is compared against the limit to decide whether we perform an IO or a memory access.

On ARM, we cannot keep this PIO limit as the arm-virt machine uses [0x3eff0000, 0x3f000000 ] for the IO space map and we are mandated to allocate at 0x0.

Add a new flag in QPCIBar indicating whether it is an IO bar or a memory bar. This flag is set on QPCIBar allocation and provisionned based on the BAR configuration. Then the new flag is used in access functions and in iomap() function.

Quoted 7 lines
---
  tests/qtest/libqos/pci-pc.c    |  1 +
  tests/qtest/libqos/pci-spapr.c |  1 +
  tests/qtest/libqos/pci.c       | 78 ++++++++++++++++++++++------------
  tests/qtest/libqos/pci.h       |  5 +--
  4 files changed, 54 insertions(+), 31 deletions(-)
author
#5 lore raw

PATCH 3/6 tests/qtest/libqos: Skip hotplug tests if pci root bus is not hotpluggable

In reply to Eric Auger

ARM does not not support hotplug on pcie.0. Add a flag on the bus which tells if devices can be hotplugged and skip hotplug tests if the bus cannot be hotplugged. This is a temporary solution to enable the other pci tests on aarch64.

---
 tests/qtest/e1000e-test.c         |  6 ++++++
 tests/qtest/libqos/pci.h          |  1 +
 tests/qtest/vhost-user-blk-test.c | 10 ++++++++++
 tests/qtest/virtio-blk-test.c     |  5 +++++
 tests/qtest/virtio-net-test.c     |  5 +++++
 tests/qtest/virtio-rng-test.c     |  5 +++++
 6 files changed, 32 insertions(+)
tests/qtest/e1000e-test.c +6 -0
index 0273fe4c156..0d656d3af63 100644
@@ -235,6 +235,12 @@ static void test_e1000e_multiple_transfers(void *obj, void *data,
 static void test_e1000e_hotplug(void *obj, void *data, QGuestAllocator * alloc)
 {
     QTestState *qts = global_qtest;  /* TODO: get rid of global_qtest here */
+    QE1000E_PCI *dev = obj;
+
+    if (dev->pci_dev.bus->not_hotpluggable) {
+        g_test_skip("bus pci.0 does not support hotplug");
+        return;
+    }
 
     qtest_qmp_device_add(qts, "e1000e", "e1000e_net", "{'addr': '0x06'}");
     qpci_unplug_acpi_device_test(qts, "e1000e_net", 0x06);
tests/qtest/libqos/pci.h +1 -0
index 44f6806fe44..6a28b405221 100644
@@ -52,6 +52,7 @@ struct QPCIBus {
     uint64_t pio_alloc_ptr, pio_limit;
     uint64_t mmio_alloc_ptr, mmio_limit;
     bool has_buggy_msi; /* TRUE for spapr, FALSE for pci */
+    bool not_hotpluggable; /* TRUE if devices cannot be hotplugged */
 
 };
 
tests/qtest/vhost-user-blk-test.c +10 -0
index 62e670f39be..cea2570884b 100644
@@ -676,6 +676,11 @@ static void pci_hotplug(void *obj, void *data, QGuestAllocator *t_alloc)
     QVirtioPCIDevice *dev;
     QTestState *qts = dev1->pdev->bus->qts;
 
+    if (dev1->pdev->bus->not_hotpluggable) {
+        g_test_skip("bus pci.0 does not support hotplug");
+        return;
+    }
+
     /* plug secondary disk */
     qtest_qmp_device_add(qts, "vhost-user-blk-pci", "drv1",
                          "{'addr': %s, 'chardev': 'char2'}",
@@ -703,6 +708,11 @@ static void multiqueue(void *obj, void *data, QGuestAllocator *t_alloc)
     uint64_t features;
     uint16_t num_queues;
 
+    if (pdev1->pdev->bus->not_hotpluggable) {
+        g_test_skip("bus pci.0 does not support hotplug");
+        return;
+    }
+
     /*
      * The primary device has 1 queue and VIRTIO_BLK_F_MQ is not enabled. The
      * VIRTIO specification allows VIRTIO_BLK_F_MQ to be enabled when there is
tests/qtest/virtio-blk-test.c +5 -0
index 2a236982118..0d5fa5b3247 100644
@@ -701,6 +701,11 @@ static void pci_hotplug(void *obj, void *data, QGuestAllocator *t_alloc)
     QVirtioPCIDevice *dev;
     QTestState *qts = dev1->pdev->bus->qts;
 
+    if (dev1->pdev->bus->not_hotpluggable) {
+        g_test_skip("bus pci.0 does not support hotplug");
+        return;
+    }
+
     /* plug secondary disk */
     qtest_qmp_device_add(qts, "virtio-blk-pci", "drv1",
                          "{'addr': %s, 'drive': 'drive1'}",
tests/qtest/virtio-net-test.c +5 -0
index 8bf74e516cc..fdf7dd750b9 100644
@@ -174,6 +174,11 @@ static void hotplug(void *obj, void *data, QGuestAllocator *t_alloc)
     QTestState *qts = dev->pdev->bus->qts;
     const char *arch = qtest_get_arch();
 
+    if (dev->pdev->bus->not_hotpluggable) {
+        g_test_skip("bus pci.0 does not support hotplug");
+        return;
+    }
+
     qtest_qmp_device_add(qts, "virtio-net-pci", "net1",
                          "{'addr': %s}", stringify(PCI_SLOT_HP));
 
tests/qtest/virtio-rng-test.c +5 -0
index e6b8cd8e0cf..6b7d2b9eea4 100644
@@ -20,6 +20,11 @@ static void rng_hotplug(void *obj, void *data, QGuestAllocator *alloc)
     QVirtioPCIDevice *dev = obj;
     QTestState *qts = dev->pdev->bus->qts;
 
+   if (dev->pdev->bus->not_hotpluggable) {
+        g_test_skip("bus pci.0 does not support hotplug");
+        return;
+    }
+
     const char *arch = qtest_get_arch();
 
     qtest_qmp_device_add(qts, "virtio-rng-pci", "rng1",
Signature · 1 line
2.26.3
Acked-by on v1 3/6
#6 lore raw

Re: [PATCH 3/6] tests/qtest/libqos: Skip hotplug tests if pci root bus is not hotpluggable

Quoted 20 lines · Eric Auger

ARM does not not support hotplug on pcie.0. Add a flag on the bus which tells if devices can be hotplugged and skip hotplug tests if the bus cannot be hotplugged. This is a temporary solution to enable the other pci tests on aarch64.

---
  tests/qtest/e1000e-test.c         |  6 ++++++
  tests/qtest/libqos/pci.h          |  1 +
  tests/qtest/vhost-user-blk-test.c | 10 ++++++++++
  tests/qtest/virtio-blk-test.c     |  5 +++++
  tests/qtest/virtio-net-test.c     |  5 +++++
  tests/qtest/virtio-rng-test.c     |  5 +++++
  6 files changed, 32 insertions(+)
tests/qtest/e1000e-test.c +0 -0
index 0273fe4c156..0d656d3af63 100644

tests/qtest/e1000e-test.c static void test_e1000e_multiple_transfers(void *obj, void *data, · line 241

Quoted 7 lines
tests/qtest/e1000e-test.c +4 -0
@@ -235,6 +235,12 @@ static void test_e1000e_multiple_transfers(void *obj, void *data,
  static void test_e1000e_hotplug(void *obj, void *data, QGuestAllocator * alloc)
  {
      QTestState *qts = global_qtest;  /* TODO: get rid of global_qtest here */
+    QE1000E_PCI *dev = obj;
+
+    if (dev->pci_dev.bus->not_hotpluggable) {
+        g_test_skip("bus pci.0 does not support hotplug");

I'd maybe rather say "pci bus does not support hotplug", i.e. avoid "pci.0" here, in case this is ever used for another port, too.

Apart from that:

Quoted 2 lines
tests/qtest/e1000e-test.c +2 -0
+        return;
+    }
author
#7 lore raw

PATCH 4/6 tests/qtest/vhost-user-blk-test: Setup MSIx to avoid error on aarch64

In reply to Eric Auger

When run on ARM, basic and indirect tests currently fail with the following error:

ERROR:../tests/qtest/libqos/virtio.c:224:qvirtio_wait_used_elem:
assertion failed (got_desc_idx == desc_idx): (50331648 == 0) Bail out! ERROR:../tests/qtest/libqos/virtio.c:224: qvirtio_wait_used_elem:
assertion failed (got_desc_idx == desc_idx): (50331648 == 0)

Setting up and enabling MSIX fixes the issue.

Also remove the useless libqos/libqos-pc.h header inclusion.

---
 tests/qtest/vhost-user-blk-test.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
tests/qtest/vhost-user-blk-test.c +15 -1
index cea2570884b..2024aa5923e 100644
@@ -19,7 +19,6 @@
 #include "standard-headers/linux/virtio_pci.h"
 #include "libqos/qgraph.h"
 #include "libqos/vhost-user-blk.h"
-#include "libqos/libqos-pc.h"
 
 #define TEST_IMAGE_SIZE         (64 * 1024 * 1024)
 #define QVIRTIO_BLK_TIMEOUT_US  (30 * 1000 * 1000)
@@ -224,6 +223,10 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc)
     char *data;
     QTestState *qts = global_qtest;
     QVirtQueue *vq;
+    QVirtioPCIDevice *vpcidev = container_of(dev, QVirtioPCIDevice, vdev);
+
+    qpci_msix_enable(vpcidev->pdev);
+    qvirtio_pci_set_msix_configuration_vector(vpcidev, alloc, 0);
 
     features = qvirtio_get_features(dev);
     features = features & ~(QVIRTIO_F_BAD_FEATURE |
@@ -236,9 +239,12 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc)
     g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
 
     vq = qvirtqueue_setup(dev, alloc, 0);
+    qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, alloc, 1);
 
     qvirtio_set_driver_ok(dev);
 
+    qvirtio_wait_queue_isr(qts, dev, vq, QVIRTIO_BLK_TIMEOUT_US);
+
     /* Write and read with 3 descriptor layout */
     /* Write request */
     req.type = VIRTIO_BLK_T_OUT;
@@ -468,6 +474,10 @@ static void indirect(void *obj, void *u_data, QGuestAllocator *t_alloc)
     uint8_t status;
     char *data;
     QTestState *qts = global_qtest;
+    QVirtioPCIDevice *vpcidev = container_of(dev, QVirtioPCIDevice, vdev);
+
+    qpci_msix_enable(vpcidev->pdev);
+    qvirtio_pci_set_msix_configuration_vector(vpcidev, t_alloc, 0);
 
     features = qvirtio_get_features(dev);
     g_assert_cmphex(features & (1u << VIRTIO_RING_F_INDIRECT_DESC), !=, 0);
@@ -480,8 +490,12 @@ static void indirect(void *obj, void *u_data, QGuestAllocator *t_alloc)
     g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
 
     vq = qvirtqueue_setup(dev, t_alloc, 0);
+    qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, t_alloc, 1);
+
     qvirtio_set_driver_ok(dev);
 
+    qvirtio_wait_queue_isr(qts, dev, vq, QVIRTIO_BLK_TIMEOUT_US);
+
     /* Write request */
     req.type = VIRTIO_BLK_T_OUT;
     req.ioprio = 1;
Signature · 1 line
2.26.3
Acked-by on v1 4/6
#8 lore raw

Re: [PATCH 4/6] tests/qtest/vhost-user-blk-test: Setup MSIx to avoid error on aarch64

Quoted 8 lines · Eric Auger

When run on ARM, basic and indirect tests currently fail with the following error:

ERROR:../tests/qtest/libqos/virtio.c:224:qvirtio_wait_used_elem:
assertion failed (got_desc_idx == desc_idx): (50331648 == 0) Bail out! ERROR:../tests/qtest/libqos/virtio.c:224: qvirtio_wait_used_elem:
assertion failed (got_desc_idx == desc_idx): (50331648 == 0)

Quoted 8 lines

Setting up and enabling MSIX fixes the issue.

Also remove the useless libqos/libqos-pc.h header inclusion.

---
  tests/qtest/vhost-user-blk-test.c | 16 +++++++++++++++-
  1 file changed, 15 insertions(+), 1 deletion(-)
author
#9 lore raw

PATCH 5/6 tests/qtest/vhost-user-blk-test: Factorize vq setup code

In reply to Eric Auger

The vq setup code is repeated several times and can be easily factorized.

---
 tests/qtest/vhost-user-blk-test.c | 33 +++++++++++++++----------------
 1 file changed, 16 insertions(+), 17 deletions(-)
tests/qtest/vhost-user-blk-test.c +16 -17
index 2024aa5923e..236af80e4ad 100644
@@ -211,6 +211,19 @@ static void test_invalid_discard_write_zeroes(QVirtioDevice *dev,
     guest_free(alloc, req_addr);
 }
 
+static QVirtQueue *setup_vq(QVirtioDevice *dev, QGuestAllocator *alloc)
+{
+    QVirtioPCIDevice *vpcidev = container_of(dev, QVirtioPCIDevice, vdev);
+    QVirtQueue *vq;
+
+    qpci_msix_enable(vpcidev->pdev);
+    qvirtio_pci_set_msix_configuration_vector(vpcidev, alloc, 0);
+
+    vq = qvirtqueue_setup(dev, alloc, 0);
+    qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, alloc, 1);
+    return vq;
+}
+
 /* Returns the request virtqueue so the caller can perform further tests */
 static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc)
 {
@@ -223,10 +236,6 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc)
     char *data;
     QTestState *qts = global_qtest;
     QVirtQueue *vq;
-    QVirtioPCIDevice *vpcidev = container_of(dev, QVirtioPCIDevice, vdev);
-
-    qpci_msix_enable(vpcidev->pdev);
-    qvirtio_pci_set_msix_configuration_vector(vpcidev, alloc, 0);
 
     features = qvirtio_get_features(dev);
     features = features & ~(QVIRTIO_F_BAD_FEATURE |
@@ -238,8 +247,7 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc)
     capacity = qvirtio_config_readq(dev, 0);
     g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
 
-    vq = qvirtqueue_setup(dev, alloc, 0);
-    qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, alloc, 1);
+    vq = setup_vq(dev, alloc);
 
     qvirtio_set_driver_ok(dev);
 
@@ -474,10 +482,6 @@ static void indirect(void *obj, void *u_data, QGuestAllocator *t_alloc)
     uint8_t status;
     char *data;
     QTestState *qts = global_qtest;
-    QVirtioPCIDevice *vpcidev = container_of(dev, QVirtioPCIDevice, vdev);
-
-    qpci_msix_enable(vpcidev->pdev);
-    qvirtio_pci_set_msix_configuration_vector(vpcidev, t_alloc, 0);
 
     features = qvirtio_get_features(dev);
     g_assert_cmphex(features & (1u << VIRTIO_RING_F_INDIRECT_DESC), !=, 0);
@@ -489,8 +493,7 @@ static void indirect(void *obj, void *u_data, QGuestAllocator *t_alloc)
     capacity = qvirtio_config_readq(dev, 0);
     g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
 
-    vq = qvirtqueue_setup(dev, t_alloc, 0);
-    qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, t_alloc, 1);
+    vq = setup_vq(dev, t_alloc);
 
     qvirtio_set_driver_ok(dev);
 
@@ -576,9 +579,6 @@ static void idx(void *obj, void *u_data, QGuestAllocator *t_alloc)
         return;
     }
 
-    qpci_msix_enable(pdev->pdev);
-    qvirtio_pci_set_msix_configuration_vector(pdev, t_alloc, 0);
-
     features = qvirtio_get_features(dev);
     features = features & ~(QVIRTIO_F_BAD_FEATURE |
                             (1u << VIRTIO_RING_F_INDIRECT_DESC) |
@@ -589,8 +589,7 @@ static void idx(void *obj, void *u_data, QGuestAllocator *t_alloc)
     capacity = qvirtio_config_readq(dev, 0);
     g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
 
-    vq = qvirtqueue_setup(dev, t_alloc, 0);
-    qvirtqueue_pci_msix_setup(pdev, (QVirtQueuePCI *)vq, t_alloc, 1);
+    vq = setup_vq(dev, t_alloc);
 
     qvirtio_set_driver_ok(dev);
 
Signature · 1 line
2.26.3
Reviewed-by on v1 5/6
#10 lore raw

Re: [PATCH 5/6] tests/qtest/vhost-user-blk-test: Factorize vq setup code

Quoted 7 lines · Eric Auger

The vq setup code is repeated several times and can be easily factorized.

---
  tests/qtest/vhost-user-blk-test.c | 33 +++++++++++++++----------------
  1 file changed, 16 insertions(+), 17 deletions(-)
author
#11 lore raw

PATCH 6/6 tests/qtest/libqos: Add pci-arm and add a pci-arm producer in arm-virt machine

In reply to Eric Auger

Up to now the virt-machine node contains a virtio-mmio node. However no driver produces any PCI interface node. Hence, PCI tests cannot be run with aarch64 binary.

Add a GPEX driver node that produces a pci interface node. This latter then can be consumed by all the pci tests. One of the first motivation was to be able to run the virtio-iommu-pci tests.

We still face an issue with pci hotplug tests as hotplug cannot happen on the pcie root bus and require a generic root port. This will be addressed later on.

---
 tests/qtest/libqos/arm-virt-machine.c |  47 +++++-
 tests/qtest/libqos/meson.build        |   3 +
 tests/qtest/libqos/pci-arm.c          | 219 ++++++++++++++++++++++++++
 tests/qtest/libqos/pci-arm.h          |  56 +++++++
 tests/qtest/libqos/pci.h              |   1 +
 tests/qtest/libqos/qgraph.c           |   7 +
 tests/qtest/libqos/qgraph.h           |  15 ++
 7 files changed, 344 insertions(+), 4 deletions(-)
 create mode 100644 tests/qtest/libqos/pci-arm.c
 create mode 100644 tests/qtest/libqos/pci-arm.h
tests/qtest/libqos/arm-virt-machine.c +43 -4
index e0f59322845..130c45c51e2 100644
@@ -22,6 +22,8 @@
 #include "malloc.h"
 #include "qgraph.h"
 #include "virtio-mmio.h"
+#include "pci-arm.h"
+#include "hw/pci/pci_regs.h"
 
 #define ARM_PAGE_SIZE               4096
 #define VIRTIO_MMIO_BASE_ADDR       0x0A003E00
@@ -30,13 +32,40 @@
 #define VIRTIO_MMIO_SIZE            0x00000200
 
 typedef struct QVirtMachine QVirtMachine;
+typedef struct QGenericPCIHost QGenericPCIHost;
+
+struct QGenericPCIHost {
+    QOSGraphObject obj;
+    QPCIBusARM pci;
+};
 
 struct QVirtMachine {
     QOSGraphObject obj;
     QGuestAllocator alloc;
     QVirtioMMIODevice virtio_mmio;
+    QGenericPCIHost bridge;
 };
 
+/* QGenericPCIHost */
+
+static QOSGraphObject *generic_pcihost_get_device(void *obj, const char *device)
+{
+    QGenericPCIHost *host = obj;
+    if (!g_strcmp0(device, "pci-bus-arm")) {
+        return &host->pci.obj;
+    }
+    fprintf(stderr, "%s not present in generic-pcihost\n", device);
+    g_assert_not_reached();
+}
+
+static void qos_create_generic_pcihost(QGenericPCIHost *host,
+                                       QTestState *qts,
+                                       QGuestAllocator *alloc)
+{
+    host->obj.get_device = generic_pcihost_get_device;
+    qpci_init_arm(&host->pci, qts, alloc, false);
+}
+
 static void virt_destructor(QOSGraphObject *obj)
 {
     QVirtMachine *machine = (QVirtMachine *) obj;
@@ -57,11 +86,13 @@ static void *virt_get_driver(void *object, const char *interface)
 static QOSGraphObject *virt_get_device(void *obj, const char *device)
 {
     QVirtMachine *machine = obj;
-    if (!g_strcmp0(device, "virtio-mmio")) {
+    if (!g_strcmp0(device, "generic-pcihost")) {
+        return &machine->bridge.obj;
+    } else if (!g_strcmp0(device, "virtio-mmio")) {
         return &machine->virtio_mmio.obj;
     }
 
-    fprintf(stderr, "%s not present in arm/virtio\n", device);
+    fprintf(stderr, "%s not present in arm/virt\n", device);
     g_assert_not_reached();
 }
 
@@ -76,16 +107,24 @@ static void *qos_create_machine_arm_virt(QTestState *qts)
     qvirtio_mmio_init_device(&machine->virtio_mmio, qts, VIRTIO_MMIO_BASE_ADDR,
                              VIRTIO_MMIO_SIZE);
 
+    qos_create_generic_pcihost(&machine->bridge, qts, &machine->alloc);
+
     machine->obj.get_device = virt_get_device;
     machine->obj.get_driver = virt_get_driver;
     machine->obj.destructor = virt_destructor;
     return machine;
 }
 
-static void virtio_mmio_register_nodes(void)
+static void virt_machine_register_nodes(void)
 {
     qos_node_create_machine("arm/virt", qos_create_machine_arm_virt);
     qos_node_contains("arm/virt", "virtio-mmio", NULL);
+
+    qos_node_create_machine("aarch64/virt", qos_create_machine_arm_virt);
+    qos_node_contains("aarch64/virt", "generic-pcihost", NULL);
+
+    qos_node_create_driver("generic-pcihost", NULL);
+    qos_node_contains("generic-pcihost", "pci-bus-arm", NULL);
 }
 
-libqos_init(virtio_mmio_register_nodes);
+libqos_init(virt_machine_register_nodes);
tests/qtest/libqos/meson.build +3 -0
index e988d157917..af1bc723737 100644
@@ -19,6 +19,9 @@ libqos_srcs = files('../libqtest.c',
         'libqos-pc.c',
         'ahci.c',
 
+        # arm
+        'pci-arm.c',
+
         # usb
         'usb.c',
 
tests/qtest/libqos/pci-arm.c new file +219 -0

219 lines not on this page · raw message

tests/qtest/libqos/pci-arm.h new file +56 -0

56 lines not on this page · raw message

tests/qtest/libqos/pci.h +1 -0
index 6a28b405221..07393dda4ec 100644
@@ -51,6 +51,7 @@ struct QPCIBus {
     QTestState *qts;
     uint64_t pio_alloc_ptr, pio_limit;
     uint64_t mmio_alloc_ptr, mmio_limit;
+    uint64_t ecam_alloc_ptr;
     bool has_buggy_msi; /* TRUE for spapr, FALSE for pci */
     bool not_hotpluggable; /* TRUE if devices cannot be hotplugged */
 
tests/qtest/libqos/qgraph.c +7 -0
index 109ff04e1e8..e03fad35241 100644
@@ -667,6 +667,13 @@ void qos_node_produces(const char *producer, const char *interface)
     add_edge(producer, interface, QEDGE_PRODUCES, NULL);
 }
 
+void qos_node_produces_opts(const char *producer, const char *interface,
+                            QOSGraphEdgeOptions *opts)
+{
+    create_interface(interface);
+    add_edge(producer, interface, QEDGE_PRODUCES, opts);
+}
+
 void qos_node_consumes(const char *consumer, const char *interface,
                        QOSGraphEdgeOptions *opts)
 {
tests/qtest/libqos/qgraph.h +15 -0
index 871740c0dc8..9879af118d4 100644
@@ -284,6 +284,21 @@ void qos_node_contains(const char *container, const char *contained,
  */
 void qos_node_produces(const char *producer, const char *interface);
 
+/**
+ * qos_node_produces(): creates an edge of type QEDGE_PRODUCES and
+ * adds it to the edge list mapped to @producer in the
+ * edge hash table.
+ * @producer: Source node that "produces"
+ * @interface: Interface node that "is produced"
+ * @ops: Facultative options (see %QOSGraphEdgeOptions
+ *
+ * This edge will have @producer as source and @interface as destination.
+ * It also has the possibility to add an optional @opts
+ * (see %QOSGraphEdgeOptions)
+ */
+void qos_node_produces_opts(const char *producer, const char *interface,
+                            QOSGraphEdgeOptions *opts);
+
 /**
  * qos_node_consumes():  creates an edge of type QEDGE_CONSUMED_BY and
  * adds it to the edge list mapped to @interface in the
Signature · 1 line
2.26.3
Acked-by on v1 6/6
#12 lore raw

Re: [PATCH 6/6] tests/qtest/libqos: Add pci-arm and add a pci-arm producer in arm-virt machine

Quoted 24 lines · Eric Auger

Up to now the virt-machine node contains a virtio-mmio node. However no driver produces any PCI interface node. Hence, PCI tests cannot be run with aarch64 binary.

Add a GPEX driver node that produces a pci interface node. This latter then can be consumed by all the pci tests. One of the first motivation was to be able to run the virtio-iommu-pci tests.

We still face an issue with pci hotplug tests as hotplug cannot happen on the pcie root bus and require a generic root port. This will be addressed later on.

---
  tests/qtest/libqos/arm-virt-machine.c |  47 +++++-
  tests/qtest/libqos/meson.build        |   3 +
  tests/qtest/libqos/pci-arm.c          | 219 ++++++++++++++++++++++++++
  tests/qtest/libqos/pci-arm.h          |  56 +++++++
  tests/qtest/libqos/pci.h              |   1 +
  tests/qtest/libqos/qgraph.c           |   7 +
  tests/qtest/libqos/qgraph.h           |  15 ++
  7 files changed, 344 insertions(+), 4 deletions(-)

create mode 100644 tests/qtest/libqos/pci-arm.c
create mode 100644 tests/qtest/libqos/pci-arm.h

[...]

tests/qtest/libqos/pci-arm.c line 4

Quoted 10 lines
tests/qtest/libqos/pci-arm.c new file +4 -0
new file mode 100644
index 00000000000..64d826bb3c7
@@ -0,0 +1,219 @@
+/*
+ * libqos PCI bindings for ARM
+ *
+ * Copyright Red Hat Inc., 2021

You might want to update to 2022 now.

Apart from that:

Let me know if I should take this through my qtest branch - otherwise I'll assume it will go via Peter's arm branch.

Thomas

#13 lore raw

Re: [PATCH 6/6] tests/qtest/libqos: Add pci-arm and add a pci-arm producer in arm-virt machine

In reply to Eric Auger
Quoted 8 lines · Eric Auger

Up to now the virt-machine node contains a virtio-mmio node. However no driver produces any PCI interface node. Hence, PCI tests cannot be run with aarch64 binary.

Add a GPEX driver node that produces a pci interface node. This latter then can be consumed by all the pci tests. One of the first motivation was to be able to run the virtio-iommu-pci tests.

Quoted 5 lines

We still face an issue with pci hotplug tests as hotplug cannot happen on the pcie root bus and require a generic root port. This will be addressed later on.

Hey Eric,

it's great to have gpex support in libqos/qgraph! On the next versions you might also Cc Emanuele since he was the author of the framework.

Quoted 26 lines
---
  tests/qtest/libqos/arm-virt-machine.c |  47 +++++-
  tests/qtest/libqos/meson.build        |   3 +
  tests/qtest/libqos/pci-arm.c          | 219 ++++++++++++++++++++++++++
  tests/qtest/libqos/pci-arm.h          |  56 +++++++
  tests/qtest/libqos/pci.h              |   1 +
  tests/qtest/libqos/qgraph.c           |   7 +
  tests/qtest/libqos/qgraph.h           |  15 ++
  7 files changed, 344 insertions(+), 4 deletions(-)

create mode 100644 tests/qtest/libqos/pci-arm.c
create mode 100644 tests/qtest/libqos/pci-arm.h

tests/qtest/libqos/arm-virt-machine.c +2 -0
index e0f59322845..130c45c51e2 100644
@@ -22,6 +22,8 @@
  #include "malloc.h"
  #include "qgraph.h"
  #include "virtio-mmio.h"
+#include "pci-arm.h"
+#include "hw/pci/pci_regs.h"
 
  #define ARM_PAGE_SIZE               4096
  #define VIRTIO_MMIO_BASE_ADDR       0x0A003E00

tests/qtest/libqos/arm-virt-machine.c line 40

Quoted 9 lines
tests/qtest/libqos/arm-virt-machine.c +6 -0
@@ -30,13 +32,40 @@
  #define VIRTIO_MMIO_SIZE            0x00000200
 
  typedef struct QVirtMachine QVirtMachine;
+typedef struct QGenericPCIHost QGenericPCIHost;
+
+struct QGenericPCIHost {
+    QOSGraphObject obj;
+    QPCIBusARM pci;
+};

You can rename QPCIBusARM to QGenericPCIBus and move QGenericPCIHost to the same file. There's nothing ARM specific in either file, and nothing specific to -M virt in QGenericPCIHost.

Quoted 20 lines
tests/qtest/libqos/arm-virt-machine.c +14 -0
  struct QVirtMachine {
      QOSGraphObject obj;
      QGuestAllocator alloc;
      QVirtioMMIODevice virtio_mmio;
+    QGenericPCIHost bridge;
  };
 
+/* QGenericPCIHost */
+
+static QOSGraphObject *generic_pcihost_get_device(void *obj, const char *device)
+{
+    QGenericPCIHost *host = obj;
+    if (!g_strcmp0(device, "pci-bus-arm")) {
+        return &host->pci.obj;
+    }
+    fprintf(stderr, "%s not present in generic-pcihost\n", device);
+    g_assert_not_reached();
+}
+
+static void qos_create_generic_pcihost(QGenericPCIHost *host,

tests/qtest/libqos/arm-virt-machine.c line 71

Quoted 10 lines
tests/qtest/libqos/arm-virt-machine.c +7 -0
+                                       QTestState *qts,
+                                       QGuestAllocator *alloc)
+{
+    host->obj.get_device = generic_pcihost_get_device;
+    qpci_init_arm(&host->pci, qts, alloc, false);
+}
+
  static void virt_destructor(QOSGraphObject *obj)
  {
      QVirtMachine *machine = (QVirtMachine *) obj;

This should also be in the same file as the bus implementation.

tests/qtest/libqos/arm-virt-machine.c static void *qos_create_machine_arm_virt(QTestState *qts) · line 127

Quoted 2 lines
tests/qtest/libqos/arm-virt-machine.c +2 -0
+    qos_node_create_driver("generic-pcihost", NULL);
+    qos_node_contains("generic-pcihost", "pci-bus-arm", NULL);

This too, with a new libqos_init.

tests/qtest/libqos/arm-virt-machine.c

Quoted 3 lines
tests/qtest/libqos/arm-virt-machine.c +3 -0
+static uint8_t qpci_arm_config_readb(QPCIBus *bus, int devfn, uint8_t offset)
+{
+    uint64_t addr = bus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | offset);

ecam_alloc_ptr should be in QPCIBusARM (to be renamed to QGenericPCIBus), which you can retrieve from the "bus" QPCIBus* via container_of.

Quoted 50 lines
tests/qtest/libqos/pci-arm.h new file +44 -0
new file mode 100644
index 00000000000..8cd49ec2969
@@ -0,0 +1,56 @@
+/*
+ * libqos PCI bindings for ARM
+ *
+ * Copyright Red Hat Inc., 2021
+ *
+ * Authors:
+ *  Eric Auger   <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef LIBQOS_PCI_ARM_H
+#define LIBQOS_PCI_ARM_H
+
+#include "pci.h"
+#include "malloc.h"
+#include "qgraph.h"
+
+typedef struct QPCIBusARM {
+    QOSGraphObject obj;
+    QPCIBus bus;
+    uint64_t gpex_pio_base;
+} QPCIBusARM;
+
+/*
+ * qpci_init_arm():
+ * @ret: A valid QPCIBusARM * pointer
+ * @qts: The %QTestState for this ARM machine
+ * @alloc: A previously initialized @alloc providing memory for @qts
+ * @bool: devices can be hotplugged on this bus
+ *
+ * This function initializes an already allocated
+ * QPCIBusARM object.
+ */
+void qpci_init_arm(QPCIBusARM *ret, QTestState *qts,
+                   QGuestAllocator *alloc, bool hotpluggable);
+
+/*
+ * qpci_arm_new():
+ * @qts: The %QTestState for this ARM machine
+ * @alloc: A previously initialized @alloc providing memory for @qts
+ * @hotpluggable: the pci bus is hotpluggable
+ *

tests/qtest/libqos/pci-arm.h line 54

Quoted 10 lines
tests/qtest/libqos/pci-arm.h new file +10 -0
+ * This function creates a new QPCIBusARM object,
+ * and properly initialize its fields.
+ *
+ * Returns the QPCIBus *bus field of a newly
+ * allocated QPCIBusARM.
+ */
+QPCIBus *qpci_new_arm(QTestState *qts, QGuestAllocator *alloc,
+                      bool hotpluggable);
+
+void qpci_free_arm(QPCIBus *bus);

These two functions are not needed now. I'm not opposing non-qgraph tests that use the gpex device, but the functions should be introduced together with their users.

Quoted 5 lines
tests/qtest/libqos/qgraph.c +0 -0
index 109ff04e1e8..e03fad35241 100644

tests/qtest/libqos/qgraph.c void qos_node_produces(const char *producer, const char *interface) · line 676

Quoted 10 lines
tests/qtest/libqos/qgraph.c +7 -0
@@ -667,6 +667,13 @@ void qos_node_produces(const char *producer, const char *interface)
      add_edge(producer, interface, QEDGE_PRODUCES, NULL);
  }
 
+void qos_node_produces_opts(const char *producer, const char *interface,
+                            QOSGraphEdgeOptions *opts)
+{
+    create_interface(interface);
+    add_edge(producer, interface, QEDGE_PRODUCES, opts);
+}
+

This is not needed, I think.

Paolo

author
#14 lore raw

Re: [PATCH 6/6] tests/qtest/libqos: Add pci-arm and add a pci-arm producer in arm-virt machine

Hi Paolo,

Quoted 13 lines · Paolo Bonzini
Quoted 12 lines · Eric Auger

Up to now the virt-machine node contains a virtio-mmio node. However no driver produces any PCI interface node. Hence, PCI tests cannot be run with aarch64 binary.

Add a GPEX driver node that produces a pci interface node. This latter then can be consumed by all the pci tests. One of the first motivation was to be able to run the virtio-iommu-pci tests.

We still face an issue with pci hotplug tests as hotplug cannot happen on the pcie root bus and require a generic root port. This will be addressed later on.

Quoted 7 lines
Quoted 1 line

Hey Eric,

it's great to have gpex support in libqos/qgraph!  On the next versions you might also Cc Emanuele since he was the author of the framework.

sure!

Quoted 31 lines
Quoted 31 lines

---
  tests/qtest/libqos/arm-virt-machine.c |  47 +++++- tests/qtest/libqos/meson.build        |   3 + tests/qtest/libqos/pci-arm.c          | 219 ++++++++++++++++++++++++++ tests/qtest/libqos/pci-arm.h          |  56 +++++++ tests/qtest/libqos/pci.h              |   1 + tests/qtest/libqos/qgraph.c           |   7 + tests/qtest/libqos/qgraph.h           |  15 ++

  7 files changed, 344 insertions(+), 4 deletions(-)

  create mode 100644 tests/qtest/libqos/pci-arm.c
  create mode 100644 tests/qtest/libqos/pci-arm.h

tests/qtest/libqos/arm-virt-machine.c +4 -0
index e0f59322845..130c45c51e2 100644
@@ -22,6 +22,8 @@
   #include "malloc.h"
   #include "qgraph.h"
   #include "virtio-mmio.h"
+#include "pci-arm.h"
+#include "hw/pci/pci_regs.h"
     #define ARM_PAGE_SIZE               4096
   #define VIRTIO_MMIO_BASE_ADDR       0x0A003E00
@@ -30,13 +32,40 @@
   #define VIRTIO_MMIO_SIZE            0x00000200
     typedef struct QVirtMachine QVirtMachine;
+typedef struct QGenericPCIHost QGenericPCIHost;
+
Quoted 8 lines

tests/qtest/libqos/arm-virt-machine.c line 40

Quoted 4 lines
tests/qtest/libqos/arm-virt-machine.c +4 -0
+struct QGenericPCIHost {
+    QOSGraphObject obj;
+    QPCIBusARM pci;
+};

You can rename QPCIBusARM to QGenericPCIBus and move QGenericPCIHost to the same file.  There's nothing ARM specific in either file, and nothing specific to -M virt in QGenericPCIHost.

done

Quoted 25 lines
Quoted 25 lines
tests/qtest/libqos/arm-virt-machine.c +1 -0
   struct QVirtMachine {
       QOSGraphObject obj;
       QGuestAllocator alloc;
       QVirtioMMIODevice virtio_mmio;
+    QGenericPCIHost bridge;
   };

  +/* QGenericPCIHost */

tests/qtest/libqos/arm-virt-machine.c +2 -0
+
+static QOSGraphObject *generic_pcihost_get_device(void *obj, const

char *device)

tests/qtest/libqos/arm-virt-machine.c +14 -0
+{
+    QGenericPCIHost *host = obj;
+    if (!g_strcmp0(device, "pci-bus-arm")) {
+        return &host->pci.obj;
+    }
+    fprintf(stderr, "%s not present in generic-pcihost\n", device);
+    g_assert_not_reached();
+}
+
+static void qos_create_generic_pcihost(QGenericPCIHost *host,
+                                       QTestState *qts,
+                                       QGuestAllocator *alloc)
+{
+    host->obj.get_device = generic_pcihost_get_device;
Quoted 8 lines
Quoted 6 lines

+    qpci_init_arm(&host->pci, qts, alloc, false);

tests/qtest/libqos/arm-virt-machine.c +2 -0
+}
+

  static void virt_destructor(QOSGraphObject *obj) {
      QVirtMachine *machine = (QVirtMachine *) obj;

This should also be in the same file as the bus implementation.

done

Quoted 5 lines
Quoted 3 lines

+    qos_node_create_driver("generic-pcihost", NULL); +    qos_node_contains("generic-pcihost", "pci-bus-arm", NULL);

This too, with a new libqos_init.

done

Quoted 11 lines
Quoted 7 lines

+static uint8_t qpci_arm_config_readb(QPCIBus *bus, int devfn, uint8_t offset)
+{
+    uint64_t addr = bus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | offset);

ecam_alloc_ptr should be in QPCIBusARM (to be renamed to QGenericPCIBus), which you can retrieve from the "bus" QPCIBus* via container_of.

done

Quoted 58 lines
Quoted 58 lines
tests/qtest/libqos/pci-arm.h new file +9 -0
new file mode 100644
index 00000000000..8cd49ec2969
@@ -0,0 +1,56 @@
+/*
+ * libqos PCI bindings for ARM
+ *
+ * Copyright Red Hat Inc., 2021
+ *
+ * Authors:
+ *  Eric Auger   <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2

or later.
+ * See the COPYING file in the top-level directory.
+ */

tests/qtest/libqos/pci-arm.h new file +39 -0
+
+#ifndef LIBQOS_PCI_ARM_H
+#define LIBQOS_PCI_ARM_H
+
+#include "pci.h"
+#include "malloc.h"
+#include "qgraph.h"
+
+typedef struct QPCIBusARM {
+    QOSGraphObject obj;
+    QPCIBus bus;
+    uint64_t gpex_pio_base;
+} QPCIBusARM;
+
+/*
+ * qpci_init_arm():
+ * @ret: A valid QPCIBusARM * pointer
+ * @qts: The %QTestState for this ARM machine
+ * @alloc: A previously initialized @alloc providing memory for @qts
+ * @bool: devices can be hotplugged on this bus
+ *
+ * This function initializes an already allocated
+ * QPCIBusARM object.
+ */
+void qpci_init_arm(QPCIBusARM *ret, QTestState *qts,
+                   QGuestAllocator *alloc, bool hotpluggable);
+
+/*
+ * qpci_arm_new():
+ * @qts: The %QTestState for this ARM machine
+ * @alloc: A previously initialized @alloc providing memory for @qts
+ * @hotpluggable: the pci bus is hotpluggable
+ *
+ * This function creates a new QPCIBusARM object,
+ * and properly initialize its fields.
+ *
+ * Returns the QPCIBus *bus field of a newly
+ * allocated QPCIBusARM.
+ */
Quoted 8 lines

tests/qtest/libqos/pci-arm.h line 54

Quoted 4 lines
tests/qtest/libqos/pci-arm.h new file +4 -0
+QPCIBus *qpci_new_arm(QTestState *qts, QGuestAllocator *alloc,
+                      bool hotpluggable);
+
+void qpci_free_arm(QPCIBus *bus);

These two functions are not needed now.  I'm not opposing non-qgraph tests that use the gpex device, but the functions should be introduced together with their users.

removed

Quoted 11 lines
Quoted 11 lines
tests/qtest/libqos/qgraph.c +0 -0
index 109ff04e1e8..e03fad35241 100644
@@ -667,6 +667,13 @@ void qos_node_produces(const char *producer,
 const char *interface)
       add_edge(producer, interface, QEDGE_PRODUCES, NULL);
   }

  +void qos_node_produces_opts(const char *producer, const char *interface,

Quoted 8 lines

tests/qtest/libqos/qgraph.c void qos_node_produces(const char *producer, const char *interface) · line 676

Quoted 6 lines

+                            QOSGraphEdgeOptions *opts)

tests/qtest/libqos/qgraph.c +5 -0
+{
+    create_interface(interface);
+    add_edge(producer, interface, QEDGE_PRODUCES, opts);
+}
+

This is not needed, I think.

indeed, removed.

So you should see the above comments taken into account in just posted v2.

Thank you for the review!

Eric

Quoted 3 lines

Paolo