Skip to contentSkip to conversation

tests: qtest: Add virtio-iommu test

PATCH In review Eric Auger 2 participants 5 messages Nov 1, 2021 – Nov 4, 2021 Arm/Amlogic Meson SoC support

lore
Share & tools
lore

Eric Auger

author
#0 lore raw

PATCH v5 1/1 tests: qtest: Add virtio-iommu test

Add the framework to test the virtio-iommu-pci device and tests exercising the attach/detach, map/unmap API.

---

v4 -> v5:
- remove printf and move a comment
- Added Jean-Philippe's T-b and R-b

---
 tests/qtest/libqos/meson.build    |   1 +
 tests/qtest/libqos/virtio-iommu.c | 126 ++++++++++++
 tests/qtest/libqos/virtio-iommu.h |  40 ++++
 tests/qtest/meson.build           |   1 +
 tests/qtest/virtio-iommu-test.c   | 326 ++++++++++++++++++++++++++++++
 5 files changed, 494 insertions(+)
 create mode 100644 tests/qtest/libqos/virtio-iommu.c
 create mode 100644 tests/qtest/libqos/virtio-iommu.h
 create mode 100644 tests/qtest/virtio-iommu-test.c
tests/qtest/libqos/meson.build +1 -0
index 1f5c8f1053..ba90bbe2b8 100644
@@ -40,6 +40,7 @@ libqos_srcs = files('../libqtest.c',
         'virtio-rng.c',
         'virtio-scsi.c',
         'virtio-serial.c',
+        'virtio-iommu.c',
 
         # qgraph machines:
         'aarch64-xlnx-zcu102-machine.c',
tests/qtest/libqos/virtio-iommu.c new file +126 -0

126 lines not on this page · raw message

tests/qtest/libqos/virtio-iommu.h new file +40 -0
new file mode 100644
index 0000000000..d753761958
@@ -0,0 +1,40 @@
+/*
+ * libqos driver virtio-iommu-pci framework
+ *
+ * Copyright (c) 2021 Red Hat, Inc.
+ *
+ * Authors:
+ *  Eric Auger <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at your
+ * option) any later version.  See the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef TESTS_LIBQOS_VIRTIO_IOMMU_H
+#define TESTS_LIBQOS_VIRTIO_IOMMU_H
+
+#include "qgraph.h"
+#include "virtio.h"
+#include "virtio-pci.h"
+
+typedef struct QVirtioIOMMU QVirtioIOMMU;
+typedef struct QVirtioIOMMUPCI QVirtioIOMMUPCI;
+typedef struct QVirtioIOMMUDevice QVirtioIOMMUDevice;
+
+struct QVirtioIOMMU {
+    QVirtioDevice *vdev;
+    QVirtQueue *vq;
+};
+
+struct QVirtioIOMMUPCI {
+    QVirtioPCIDevice pci_vdev;
+    QVirtioIOMMU iommu;
+};
+
+struct QVirtioIOMMUDevice {
+    QOSGraphObject obj;
+    QVirtioIOMMU iommu;
+};
+
+#endif
tests/qtest/meson.build +1 -0
index c9d8458062..982ffb3e38 100644
@@ -230,6 +230,7 @@ qos_test_ss.add(
   'virtio-rng-test.c',
   'virtio-scsi-test.c',
   'virtio-serial-test.c',
+  'virtio-iommu-test.c',
   'vmxnet3-test.c',
 )
 if have_virtfs
tests/qtest/virtio-iommu-test.c new file +326 -0

326 lines not on this page · raw message

Signature · 1 line
2.26.3
#1 lore raw
Quoted 7 lines · Eric Auger

Add the framework to test the virtio-iommu-pci device and tests exercising the attach/detach, map/unmap API.

Quoted 5 lines

---

v4 -> v5:
- remove printf and move a comment
- Added Jean-Philippe's T-b and R-b

Hi Eric,

I tried to add this patch to my queue, but unfortunately, it fails some of the gitlab CI pipelines, e.g.:

https://gitlab.com/thuth/qemu/-/jobs/1739091817#L311

...
Running test qtest-x86_64/qos-test
qemu-system-x86_64: -device virtio-iommu-pci,addr=04.0:
pc-i440fx-6.2 machine fails to create iommu-map device tree bindings
Check your machine implements a hotplug handler for the virtio-iommu-pci device
Check the guest is booted without FW or with -no-acpi Broken pipe
...

Could you please have a look?

Thanks,
Thomas

author
#2 lore raw

Hi Thomas,

Quoted 32 lines · Thomas Huth
Quoted 7 lines · Eric Auger

Add the framework to test the virtio-iommu-pci device and tests exercising the attach/detach, map/unmap API.

Quoted 5 lines

---

v4 -> v5:
- remove printf and move a comment
- Added Jean-Philippe's T-b and R-b

 Hi Eric,

I tried to add this patch to my queue, but unfortunately, it fails some of the gitlab CI pipelines, e.g.:

 https://gitlab.com/thuth/qemu/-/jobs/1739091817#L311

 ...
 Running test qtest-x86_64/qos-test
 qemu-system-x86_64: -device virtio-iommu-pci,addr=04.0:
 pc-i440fx-6.2 machine fails to create iommu-map device tree bindings
 Check your machine implements a hotplug handler for the virtio-iommu-pci device
 Check the guest is booted without FW or with -no-acpi Broken pipe
 ...

Quoted 1 line

Could you please have a look?

The test requires to be applied on top of Jean-Philippe's series [PATCH v6 0/7] virtio-iommu: Add ACPI support (x86 part) and especially 36efa250a4  hw/i386/pc: Allow instantiating a virtio-iommu device which allows the instantiation of the virtio-iommu on q35. The series was merged so the problem should be resolved now.

Thanks

Eric

Quoted 4 lines

 Thanks,
  Thomas

#3 lore raw
In reply to Eric Auger
Quoted 19 lines · Eric Auger

Add the framework to test the virtio-iommu-pci device and tests exercising the attach/detach, map/unmap API.

---

v4 -> v5:
- remove printf and move a comment
- Added Jean-Philippe's T-b and R-b

---
  tests/qtest/libqos/meson.build    |   1 +
  tests/qtest/libqos/virtio-iommu.c | 126 ++++++++++++
  tests/qtest/libqos/virtio-iommu.h |  40 ++++
  tests/qtest/meson.build           |   1 +
  tests/qtest/virtio-iommu-test.c   | 326 ++++++++++++++++++++++++++++++
  5 files changed, 494 insertions(+)
Quoted 3 lines

create mode 100644 tests/qtest/libqos/virtio-iommu.c create mode 100644 tests/qtest/libqos/virtio-iommu.h create mode 100644 tests/qtest/virtio-iommu-test.c

There's another failure on Travis-CI:

https://app.travis-ci.com/github/huth/qemu/jobs/546268575#L7240

ERROR:../tests/qtest/virtio-iommu-test.c:38:pci_config:
assertion failed (domain_range_end == 32): (536870912 == 32)

536870912 is 0x20000000, so this is likely an endianess issue?

Thomas

author
#4 lore raw

Hi Thomas,

Quoted 24 lines · Thomas Huth
Quoted 18 lines · Eric Auger

Add the framework to test the virtio-iommu-pci device and tests exercising the attach/detach, map/unmap API.

---

v4 -> v5:
- remove printf and move a comment
- Added Jean-Philippe's T-b and R-b
---
  tests/qtest/libqos/meson.build    |   1 + tests/qtest/libqos/virtio-iommu.c | 126 ++++++++++++ tests/qtest/libqos/virtio-iommu.h |  40 ++++ tests/qtest/meson.build           |   1 + tests/qtest/virtio-iommu-test.c   | 326 ++++++++++++++++++++++++++++++

Quoted 4 lines
  5 files changed, 494 insertions(+)

  create mode 100644 tests/qtest/libqos/virtio-iommu.c create mode 100644 tests/qtest/libqos/virtio-iommu.h create mode 100644 tests/qtest/virtio-iommu-test.c

Quoted 8 lines

There's another failure on Travis-CI:

 https://app.travis-ci.com/github/huth/qemu/jobs/546268575#L7240

 ERROR:../tests/qtest/virtio-iommu-test.c:38:pci_config:
 assertion failed (domain_range_end == 32): (536870912 == 32)

536870912 is 0x20000000, so this is likely an endianess issue?

Hum It seems so. Thank you for reporting the issue. I think the get_config() cb implementation in the virtio-iommu device is wrong and needs to be fixed.
I will send a fix along with the test.

Thanks!

Eric

Quoted 3 lines

 Thomas