Skip to contentSkip to conversation

qtest: enable several tests for ppc64

PATCH Superseded Laurent Vivier 4 participants 16 messages Dec 12, 2016 – Dec 13, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover qtest: enable several tests for ppc64

This series enables some tests existing for i386 and which can also work on ppc64.

VGA tests and netfilter tests are trivial, but ivshmem test needs to enable the SPAPR PCI framework. We also fix a bug in qpci_map() for SPAPR, where the PCI base is not correctly set in the CPU address space.

Laurent Vivier (4):
qtest: add netfilter tests for ppc64
qtest: add display-vga-test to ppc64
libqos: fix spapr qpci_map()
qtest: add ivshmem-test for ppc64

 tests/Makefile.include   |  7 ++++++-
 tests/display-vga-test.c |  7 ++++++-
 tests/ivshmem-test.c     | 46 +++++++++++++++++++++++++++++-----------------
 tests/libqos/pci-spapr.c |  4 ++--
 4 files changed, 43 insertions(+), 21 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/4 qtest: add netfilter tests for ppc64

---
 tests/Makefile.include | 3 +++
 1 file changed, 3 insertions(+)
tests/Makefile.include +3 -0
index e98d3b6..be6209d 100644
@@ -283,6 +283,9 @@ gcov-files-ppc64-y += hw/usb/hcd-uhci.c
 check-qtest-ppc64-y += tests/usb-hcd-xhci-test$(EXESUF)
 gcov-files-ppc64-y += hw/usb/hcd-xhci.c
 check-qtest-ppc64-y += $(check-qtest-virtio-y)
+check-qtest-ppc64-y += tests/test-netfilter$(EXESUF)
+check-qtest-ppc64-y += tests/test-filter-mirror$(EXESUF)
+check-qtest-ppc64-y += tests/test-filter-redirector$(EXESUF)
 
 check-qtest-sh4-y = tests/endianness-test$(EXESUF)
 
Signature · 1 line
2.7.4
Reviewed-by on v1 1/4
#2 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/4] qtest: add netfilter tests for ppc64

Quoted 10 lines · Laurent Vivier
---
 tests/Makefile.include | 3 +++
 1 file changed, 3 insertions(+)
tests/Makefile.include +0 -0
index e98d3b6..be6209d 100644

tests/Makefile.include gcov-files-ppc64-y += hw/usb/hcd-uhci.c · line 290

Quoted 8 lines
tests/Makefile.include +3 -0
@@ -283,6 +283,9 @@ gcov-files-ppc64-y += hw/usb/hcd-uhci.c
 check-qtest-ppc64-y += tests/usb-hcd-xhci-test$(EXESUF)
 gcov-files-ppc64-y += hw/usb/hcd-xhci.c
 check-qtest-ppc64-y += $(check-qtest-virtio-y)
+check-qtest-ppc64-y += tests/test-netfilter$(EXESUF)
+check-qtest-ppc64-y += tests/test-filter-mirror$(EXESUF)
+check-qtest-ppc64-y += tests/test-filter-redirector$(EXESUF)
 
 check-qtest-sh4-y = tests/endianness-test$(EXESUF)
Reviewed-by Tested-by on v1 1/4
#3 lore raw

Re: [Qemu-devel] [PATCH 1/4] qtest: add netfilter tests for ppc64

In reply to Laurent Vivier
Quoted 10 lines · On Tue, 13 Dec 2016 00:28:33 +0100 Laurent Vivier <[email protected]> wrote:
---
 tests/Makefile.include | 3 +++
 1 file changed, 3 insertions(+)
tests/Makefile.include +0 -0
index e98d3b6..be6209d 100644

tests/Makefile.include gcov-files-ppc64-y += hw/usb/hcd-uhci.c · line 291

Quoted 9 lines
tests/Makefile.include +3 -0
@@ -283,6 +283,9 @@ gcov-files-ppc64-y += hw/usb/hcd-uhci.c
 check-qtest-ppc64-y += tests/usb-hcd-xhci-test$(EXESUF)
 gcov-files-ppc64-y += hw/usb/hcd-xhci.c
 check-qtest-ppc64-y += $(check-qtest-virtio-y)
+check-qtest-ppc64-y += tests/test-netfilter$(EXESUF)
+check-qtest-ppc64-y += tests/test-filter-mirror$(EXESUF)
+check-qtest-ppc64-y += tests/test-filter-redirector$(EXESUF)
 
 check-qtest-sh4-y = tests/endianness-test$(EXESUF)
 

And this what I get on x86, x86_64, pp64 and ppc64le hosts:

TEST: tests/test-netfilter... (pid=1433)

  /ppc64/netfilter/addremove_one:                                      OK
  /ppc64/netfilter/remove_netdev_one:                                  OK
  /ppc64/netfilter/addremove_multi:                                    OK
  /ppc64/netfilter/remove_netdev_multi:                                OK

PASS: tests/test-netfilter
TEST: tests/test-filter-mirror... (pid=1441)
/ppc64/netfilter/mirror: OK
PASS: tests/test-filter-mirror

so

#4 lore raw

PATCH 2/4 qtest: add display-vga-test to ppc64

In reply to Laurent Vivier

Only enable for ppc64 in the Makefile, but added code in the file to check cirrus card only on architectures supporting it (alpha, mips, i386, x86_64).

---
 tests/Makefile.include   | 1 +
 tests/display-vga-test.c | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
tests/Makefile.include +1 -0
index be6209d..b574964 100644
@@ -286,6 +286,7 @@ check-qtest-ppc64-y += $(check-qtest-virtio-y)
 check-qtest-ppc64-y += tests/test-netfilter$(EXESUF)
 check-qtest-ppc64-y += tests/test-filter-mirror$(EXESUF)
 check-qtest-ppc64-y += tests/test-filter-redirector$(EXESUF)
+check-qtest-ppc64-y += tests/display-vga-test$(EXESUF)
 
 check-qtest-sh4-y = tests/endianness-test$(EXESUF)
 
tests/display-vga-test.c +6 -1
index 9146021..2d7d24e 100644
@@ -50,9 +50,14 @@ static void pci_virtio_vga(void)
 
 int main(int argc, char **argv)
 {
+    const char *arch = qtest_get_arch();
+
     g_test_init(&argc, &argv, NULL);
 
-    qtest_add_func("/display/pci/cirrus", pci_cirrus);
+    if (strcmp(arch, "alpha") == 0 || strcmp(arch, "i386") == 0 ||
+        strcmp(arch, "mips") == 0 || strcmp(arch, "x86_64") == 0) {
+        qtest_add_func("/display/pci/cirrus", pci_cirrus);
+    }
     qtest_add_func("/display/pci/stdvga", pci_stdvga);
     qtest_add_func("/display/pci/secondary", pci_secondary);
     qtest_add_func("/display/pci/multihead", pci_multihead);
Signature · 1 line
2.7.4
Reviewed-by on v1 2/4
#5 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH 2/4] qtest: add display-vga-test to ppc64

Quoted 32 lines · Laurent Vivier

Only enable for ppc64 in the Makefile, but added code in the file to check cirrus card only on architectures supporting it (alpha, mips, i386, x86_64).

---
 tests/Makefile.include   | 1 +
 tests/display-vga-test.c | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
tests/Makefile.include +1 -0
index be6209d..b574964 100644
@@ -286,6 +286,7 @@ check-qtest-ppc64-y += $(check-qtest-virtio-y)
 check-qtest-ppc64-y += tests/test-netfilter$(EXESUF)
 check-qtest-ppc64-y += tests/test-filter-mirror$(EXESUF)
 check-qtest-ppc64-y += tests/test-filter-redirector$(EXESUF)
+check-qtest-ppc64-y += tests/display-vga-test$(EXESUF)
 
 check-qtest-sh4-y = tests/endianness-test$(EXESUF)
 
tests/display-vga-test.c +2 -0
index 9146021..2d7d24e 100644
@@ -50,9 +50,14 @@ static void pci_virtio_vga(void)
 
 int main(int argc, char **argv)
 {
+    const char *arch = qtest_get_arch();
+

tests/display-vga-test.c static void pci_virtio_vga(void) · line 63

Quoted 10 lines
tests/display-vga-test.c +4 -1
     g_test_init(&argc, &argv, NULL);
 
-    qtest_add_func("/display/pci/cirrus", pci_cirrus);
+    if (strcmp(arch, "alpha") == 0 || strcmp(arch, "i386") == 0 ||
+        strcmp(arch, "mips") == 0 || strcmp(arch, "x86_64") == 0) {
+        qtest_add_func("/display/pci/cirrus", pci_cirrus);
+    }
     qtest_add_func("/display/pci/stdvga", pci_stdvga);
     qtest_add_func("/display/pci/secondary", pci_secondary);
     qtest_add_func("/display/pci/multihead", pci_multihead);

Alternatively, I think you could also check the result of
qtest_hmp(global_qtest, "info qdm")
to see whether cirrus-vga is available ... but not sure, whether that's really nicer, so:

#6 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH 2/4] qtest: add display-vga-test to ppc64

Quoted 35 lines · Thomas Huth
Quoted 34 lines · Laurent Vivier

Only enable for ppc64 in the Makefile, but added code in the file to check cirrus card only on architectures supporting it (alpha, mips, i386, x86_64).

---
 tests/Makefile.include   | 1 +
 tests/display-vga-test.c | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
tests/Makefile.include +1 -0
index be6209d..b574964 100644
@@ -286,6 +286,7 @@ check-qtest-ppc64-y += $(check-qtest-virtio-y)
 check-qtest-ppc64-y += tests/test-netfilter$(EXESUF)
 check-qtest-ppc64-y += tests/test-filter-mirror$(EXESUF)
 check-qtest-ppc64-y += tests/test-filter-redirector$(EXESUF)
+check-qtest-ppc64-y += tests/display-vga-test$(EXESUF)
 
 check-qtest-sh4-y = tests/endianness-test$(EXESUF)
 
tests/display-vga-test.c +2 -0
index 9146021..2d7d24e 100644
@@ -50,9 +50,14 @@ static void pci_virtio_vga(void)
 
 int main(int argc, char **argv)
 {
+    const char *arch = qtest_get_arch();
+
     g_test_init(&argc, &argv, NULL);
 
Quoted 13 lines

tests/display-vga-test.c static void pci_virtio_vga(void) · line 63

Quoted 8 lines
tests/display-vga-test.c +4 -1
-    qtest_add_func("/display/pci/cirrus", pci_cirrus);
+    if (strcmp(arch, "alpha") == 0 || strcmp(arch, "i386") == 0 ||
+        strcmp(arch, "mips") == 0 || strcmp(arch, "x86_64") == 0) {
+        qtest_add_func("/display/pci/cirrus", pci_cirrus);
+    }
     qtest_add_func("/display/pci/stdvga", pci_stdvga);
     qtest_add_func("/display/pci/secondary", pci_secondary);
     qtest_add_func("/display/pci/multihead", pci_multihead);

Alternatively, I think you could also check the result of
qtest_hmp(global_qtest, "info qdm")
to see whether cirrus-vga is available ... but not sure, whether that's really nicer, so:

I think it's too complicated for a so simple test (it only starts the machine with "-device XXX")

Quoted 1 line

Thanks,
Laurent

Reviewed-by Tested-by on v1 2/4
#7 lore raw

Re: [Qemu-devel] [PATCH 2/4] qtest: add display-vga-test to ppc64

In reply to Laurent Vivier
Quoted 32 lines · On Tue, 13 Dec 2016 00:28:34 +0100 Laurent Vivier <[email protected]> wrote:

Only enable for ppc64 in the Makefile, but added code in the file to check cirrus card only on architectures supporting it (alpha, mips, i386, x86_64).

---
 tests/Makefile.include   | 1 +
 tests/display-vga-test.c | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
tests/Makefile.include +1 -0
index be6209d..b574964 100644
@@ -286,6 +286,7 @@ check-qtest-ppc64-y += $(check-qtest-virtio-y)
 check-qtest-ppc64-y += tests/test-netfilter$(EXESUF)
 check-qtest-ppc64-y += tests/test-filter-mirror$(EXESUF)
 check-qtest-ppc64-y += tests/test-filter-redirector$(EXESUF)
+check-qtest-ppc64-y += tests/display-vga-test$(EXESUF)
 
 check-qtest-sh4-y = tests/endianness-test$(EXESUF)
 
tests/display-vga-test.c +2 -0
index 9146021..2d7d24e 100644
@@ -50,9 +50,14 @@ static void pci_virtio_vga(void)
 
 int main(int argc, char **argv)
 {
+    const char *arch = qtest_get_arch();
+

tests/display-vga-test.c static void pci_virtio_vga(void) · line 63

Quoted 10 lines
tests/display-vga-test.c +4 -1
     g_test_init(&argc, &argv, NULL);
 
-    qtest_add_func("/display/pci/cirrus", pci_cirrus);
+    if (strcmp(arch, "alpha") == 0 || strcmp(arch, "i386") == 0 ||
+        strcmp(arch, "mips") == 0 || strcmp(arch, "x86_64") == 0) {
+        qtest_add_func("/display/pci/cirrus", pci_cirrus);
+    }
     qtest_add_func("/display/pci/stdvga", pci_stdvga);
     qtest_add_func("/display/pci/secondary", pci_secondary);
     qtest_add_func("/display/pci/multihead", pci_multihead);

TEST: tests/display-vga-test... (pid=1462)

  /ppc64/display/pci/stdvga:                                           OK
  /ppc64/display/pci/secondary:                                        OK
  /ppc64/display/pci/multihead:                                        OK
  /ppc64/display/pci/virtio-gpu:                                       OK

PASS: tests/display-vga-test

#8 lore raw

PATCH 3/4 libqos: fix spapr qpci_map()

In reply to Laurent Vivier
---
 tests/libqos/pci-spapr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/libqos/pci-spapr.c +2 -2
index 1e5d015..2043f1e 100644
@@ -193,8 +193,8 @@ QPCIBus *qpci_init_spapr(QGuestAllocator *alloc)
     ret->pio.size = SPAPR_PCI_IO_WIN_SIZE;
 
     /* 32-bit portion of the MMIO window is at PCI address 2..4 GiB */
-    ret->mmio32_cpu_base = SPAPR_PCI_BASE + SPAPR_PCI_MMIO32_WIN_SIZE;
-    ret->mmio32.pci_base = 0x80000000; /* 2 GiB */
+    ret->mmio32_cpu_base = SPAPR_PCI_BASE;
+    ret->mmio32.pci_base = SPAPR_PCI_MMIO32_WIN_SIZE;
     ret->mmio32.size = SPAPR_PCI_MMIO32_WIN_SIZE;
 
     ret->bus.pio_alloc_ptr = 0xc000;
Signature · 1 line
2.7.4
#9 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH 3/4] libqos: fix spapr qpci_map()

A short patch description would be nice here.

Quoted 10 lines · Laurent Vivier
---
 tests/libqos/pci-spapr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/libqos/pci-spapr.c +0 -0
index 1e5d015..2043f1e 100644

tests/libqos/pci-spapr.c QPCIBus *qpci_init_spapr(QGuestAllocator *alloc) · line 198

Quoted 8 lines
tests/libqos/pci-spapr.c +2 -2
@@ -193,8 +193,8 @@ QPCIBus *qpci_init_spapr(QGuestAllocator *alloc)
     ret->pio.size = SPAPR_PCI_IO_WIN_SIZE;
 
     /* 32-bit portion of the MMIO window is at PCI address 2..4 GiB */
-    ret->mmio32_cpu_base = SPAPR_PCI_BASE + SPAPR_PCI_MMIO32_WIN_SIZE;
-    ret->mmio32.pci_base = 0x80000000; /* 2 GiB */
+    ret->mmio32_cpu_base = SPAPR_PCI_BASE;
+    ret->mmio32.pci_base = SPAPR_PCI_MMIO32_WIN_SIZE;
     ret->mmio32.size = SPAPR_PCI_MMIO32_WIN_SIZE;

Not sure whether it is really right to use SPAPR_PCI_MMIO32_WIN_SIZE for the pci_base? I mean, the WIN_SIZE could also be 1G for example, but the base could still be at 2G ? IMHO it's better to keep the old value for pci_base here.

Thomas

#10 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH 3/4] libqos: fix spapr qpci_map()

Quoted 15 lines · Thomas Huth

A short patch description would be nice here.

Quoted 12 lines · Laurent Vivier
---
 tests/libqos/pci-spapr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/libqos/pci-spapr.c +0 -0
index 1e5d015..2043f1e 100644
@@ -193,8 +193,8 @@ QPCIBus *qpci_init_spapr(QGuestAllocator *alloc)
     ret->pio.size = SPAPR_PCI_IO_WIN_SIZE;
 
Quoted 11 lines

tests/libqos/pci-spapr.c QPCIBus *qpci_init_spapr(QGuestAllocator *alloc) · line 198

Quoted 6 lines
tests/libqos/pci-spapr.c +2 -2
     /* 32-bit portion of the MMIO window is at PCI address 2..4 GiB */
-    ret->mmio32_cpu_base = SPAPR_PCI_BASE + SPAPR_PCI_MMIO32_WIN_SIZE;
-    ret->mmio32.pci_base = 0x80000000; /* 2 GiB */
+    ret->mmio32_cpu_base = SPAPR_PCI_BASE;
+    ret->mmio32.pci_base = SPAPR_PCI_MMIO32_WIN_SIZE;
     ret->mmio32.size = SPAPR_PCI_MMIO32_WIN_SIZE;

Not sure whether it is really right to use SPAPR_PCI_MMIO32_WIN_SIZE for the pci_base? I mean, the WIN_SIZE could also be 1G for example, but the base could still be at 2G ? IMHO it's better to keep the old value for pci_base here.

in hw/ppc/spapr.c, we have:

    *mmio32 = SPAPR_PCI_BASE + (index + 1) * SPAPR_PCI_MEM32_WIN_SIZE;

So I think it's logic to have the PCI base at SPAPR_PCI_MMIO32_WIN_SIZE.

Thanks for your review,
Laurent

#11 lore raw

PATCH 4/4 qtest: add ivshmem-test for ppc64

In reply to Laurent Vivier
---
 tests/Makefile.include |  3 ++-
 tests/ivshmem-test.c   | 46 +++++++++++++++++++++++++++++-----------------
 2 files changed, 31 insertions(+), 18 deletions(-)
tests/Makefile.include +2 -1
index b574964..09fe5b6 100644
@@ -287,6 +287,7 @@ check-qtest-ppc64-y += tests/test-netfilter$(EXESUF)
 check-qtest-ppc64-y += tests/test-filter-mirror$(EXESUF)
 check-qtest-ppc64-y += tests/test-filter-redirector$(EXESUF)
 check-qtest-ppc64-y += tests/display-vga-test$(EXESUF)
+check-qtest-ppc64-y += tests/ivshmem-test$(EXESUF)
 
 check-qtest-sh4-y = tests/endianness-test$(EXESUF)
 
@@ -690,7 +691,7 @@ tests/test-netfilter$(EXESUF): tests/test-netfilter.o $(qtest-obj-y)
 tests/test-filter-mirror$(EXESUF): tests/test-filter-mirror.o $(qtest-obj-y)
 tests/test-filter-redirector$(EXESUF): tests/test-filter-redirector.o $(qtest-obj-y)
 tests/test-x86-cpuid-compat$(EXESUF): tests/test-x86-cpuid-compat.o $(qtest-obj-y)
-tests/ivshmem-test$(EXESUF): tests/ivshmem-test.o contrib/ivshmem-server/ivshmem-server.o $(libqos-pc-obj-y)
+tests/ivshmem-test$(EXESUF): tests/ivshmem-test.o contrib/ivshmem-server/ivshmem-server.o $(libqos-pc-obj-y) $(libqos-spapr-obj-y)
 tests/vhost-user-bridge$(EXESUF): tests/vhost-user-bridge.o
 tests/test-uuid$(EXESUF): tests/test-uuid.o $(test-util-obj-y)
 tests/test-arm-mptimer$(EXESUF): tests/test-arm-mptimer.o
tests/ivshmem-test.c +29 -17

132 lines not on this page · raw message

Signature · 1 line
2.7.4
#12 lore raw

Re: [Qemu-devel] [PATCH 4/4] qtest: add ivshmem-test for ppc64

Quoted 102 lines · Laurent Vivier
---
 tests/Makefile.include |  3 ++-
 tests/ivshmem-test.c   | 46 +++++++++++++++++++++++++++++-----------------
 2 files changed, 31 insertions(+), 18 deletions(-)
tests/Makefile.include +2 -1
index b574964..09fe5b6 100644
@@ -287,6 +287,7 @@ check-qtest-ppc64-y += tests/test-netfilter$(EXESUF)
 check-qtest-ppc64-y += tests/test-filter-mirror$(EXESUF)
 check-qtest-ppc64-y += tests/test-filter-redirector$(EXESUF)
 check-qtest-ppc64-y += tests/display-vga-test$(EXESUF)
+check-qtest-ppc64-y += tests/ivshmem-test$(EXESUF)
 
 check-qtest-sh4-y = tests/endianness-test$(EXESUF)
 
@@ -690,7 +691,7 @@ tests/test-netfilter$(EXESUF): tests/test-netfilter.o $(qtest-obj-y)
 tests/test-filter-mirror$(EXESUF): tests/test-filter-mirror.o $(qtest-obj-y)
 tests/test-filter-redirector$(EXESUF): tests/test-filter-redirector.o $(qtest-obj-y)
 tests/test-x86-cpuid-compat$(EXESUF): tests/test-x86-cpuid-compat.o $(qtest-obj-y)
-tests/ivshmem-test$(EXESUF): tests/ivshmem-test.o contrib/ivshmem-server/ivshmem-server.o $(libqos-pc-obj-y)
+tests/ivshmem-test$(EXESUF): tests/ivshmem-test.o contrib/ivshmem-server/ivshmem-server.o $(libqos-pc-obj-y) $(libqos-spapr-obj-y)
 tests/vhost-user-bridge$(EXESUF): tests/vhost-user-bridge.o
 tests/test-uuid$(EXESUF): tests/test-uuid.o $(test-util-obj-y)
 tests/test-arm-mptimer$(EXESUF): tests/test-arm-mptimer.o
tests/ivshmem-test.c +9 -9
index 04a5c5d..5c6dc38 100644
@@ -11,8 +11,9 @@
 #include "qemu/osdep.h"
 #include <glib/gstdio.h>
 #include "contrib/ivshmem-server/ivshmem-server.h"
-#include "libqos/pci-pc.h"
 #include "libqtest.h"
+#include "libqos/libqos-pc.h"
+#include "libqos/libqos-spapr.h"
 #include "qemu-common.h"
 
 #define TMPSHMSIZE (1 << 20)
@@ -40,9 +41,8 @@ static QPCIDevice *get_device(QPCIBus *pcibus)
 }
 
 typedef struct _IVState {
-    QTestState *qtest;
+    QOSState *qs;
     QPCIBar reg_bar, mem_bar;
-    QPCIBus *pcibus;
     QPCIDevice *dev;
 } IVState;
 
@@ -74,7 +74,7 @@ static inline unsigned in_reg(IVState *s, enum Reg reg)
     QTestState *qtest = global_qtest;
     unsigned res;
 
-    global_qtest = s->qtest;
+    global_qtest = s->qs->qts;
     res = qpci_io_readl(s->dev, s->reg_bar, reg);
     g_test_message("*%s -> %x\n", name, res);
     global_qtest = qtest;
@@ -87,7 +87,7 @@ static inline void out_reg(IVState *s, enum Reg reg, unsigned v)
     const char *name = reg2str(reg);
     QTestState *qtest = global_qtest;
 
-    global_qtest = s->qtest;
+    global_qtest = s->qs->qts;
     g_test_message("%x -> *%s\n", v, name);
     qpci_io_writel(s->dev, s->reg_bar, reg, v);
     global_qtest = qtest;
@@ -97,7 +97,7 @@ static inline void read_mem(IVState *s, uint64_t off, void *buf, size_t len)
 {
     QTestState *qtest = global_qtest;
 
-    global_qtest = s->qtest;
+    global_qtest = s->qs->qts;
     qpci_memread(s->dev, s->mem_bar, off, buf, len);
     global_qtest = qtest;
 }
@@ -107,7 +107,7 @@ static inline void write_mem(IVState *s, uint64_t off,
 {
     QTestState *qtest = global_qtest;
 
-    global_qtest = s->qtest;
+    global_qtest = s->qs->qts;
     qpci_memwrite(s->dev, s->mem_bar, off, buf, len);
     global_qtest = qtest;
 }
@@ -115,17 +115,23 @@ static inline void write_mem(IVState *s, uint64_t off,
 static void cleanup_vm(IVState *s)
 {
     g_free(s->dev);
-    qpci_free_pc(s->pcibus);
-    qtest_quit(s->qtest);
+    qtest_shutdown(s->qs);
 }
 
 static void setup_vm_cmd(IVState *s, const char *cmd, bool msix)
 {
     uint64_t barsize;
+    const char *arch = qtest_get_arch();

tests/ivshmem-test.c static inline void write_mem(IVState *s, uint64_t off, · line 131

Quoted 10 lines
tests/ivshmem-test.c +6 -3
 
-    s->qtest = qtest_start(cmd);
-    s->pcibus = qpci_init_pc(NULL);
-    s->dev = get_device(s->pcibus);
+    if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+        s->qs = qtest_pc_boot(cmd);
+    } else if (strcmp(arch, "ppc64") == 0) {
+        s->qs = qtest_spapr_boot(cmd);
+    } else {
+        g_printerr("vshmem-test tests are only available on x86 or ppc64\n");

Typo: s/vshmem/ivshmem

To get here, you need to build and run this manually, as make check only builds and runs this for targets that work. But the check doesn't hurt, and documents expectations.

Quoted 25 lines
tests/ivshmem-test.c +5 -2
+        exit(EXIT_FAILURE);
+    }
+    s->dev = get_device(s->qs->pcibus);
 
     s->reg_bar = qpci_iomap(s->dev, 0, &barsize);
     g_assert_cmpuint(barsize, ==, 256);
@@ -347,7 +353,7 @@ static void test_ivshmem_server(bool msi)
     g_assert_cmpint(vm1, !=, vm2);
 
     /* check number of MSI-X vectors */
-    global_qtest = s1->qtest;
+    global_qtest = s1->qs->qts;
     if (msi) {
         ret = qpci_msix_table_size(s1->dev);
         g_assert_cmpuint(ret, ==, nvectors);
@@ -370,7 +376,7 @@ static void test_ivshmem_server(bool msi)
     g_assert_cmpuint(ret, !=, 0);
 
     /* ping vm1 -> vm2 on vector 1 */
-    global_qtest = s2->qtest;
+    global_qtest = s2->qs->qts;
     if (msi) {
         ret = qpci_msix_pending(s2->dev, 1);
         g_assert_cmpuint(ret, ==, 0);

tests/ivshmem-test.c static void test_ivshmem_server_irq(void) · line 424

Quoted 7 lines
tests/ivshmem-test.c +1 -0
@@ -412,6 +418,7 @@ static void test_ivshmem_server_irq(void)
 
 static void test_ivshmem_hotplug(void)
 {
+    const char *arch = qtest_get_arch();
     gchar *opts;
 
     qtest_start("");

Unlike the other tests, this one doesn't refuse to run on unexpected targets. Intentional?

tests/ivshmem-test.c static void test_ivshmem_hotplug(void) · line 431

Quoted 8 lines
tests/ivshmem-test.c +3 -1
@@ -419,7 +426,9 @@ static void test_ivshmem_hotplug(void)
     opts = g_strdup_printf("'shm': '%s', 'size': '1M'", tmpshm);
 
     qpci_plug_device_test("ivshmem", "iv1", PCI_SLOT_HP, opts);
-    qpci_unplug_acpi_device_test("iv1", PCI_SLOT_HP);
+    if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+        qpci_unplug_acpi_device_test("iv1", PCI_SLOT_HP);
+    }

Disables unplug test for ppc64.

Quoted 14 lines
tests/ivshmem-test.c +1 -0
     qtest_end();
     g_free(opts);
@@ -491,6 +500,7 @@ static gchar *mktempshm(int size, int *fd)
 int main(int argc, char **argv)
 {
     int ret, fd;
+    const char *arch = qtest_get_arch();
     gchar dir[] = "/tmp/ivshmem-test.XXXXXX";
 
 #if !GLIB_CHECK_VERSION(2, 31, 0)
@@ -521,8 +531,10 @@ int main(int argc, char **argv)
     qtest_add_func("/ivshmem/memdev", test_ivshmem_memdev);
     if (g_test_slow()) {

tests/ivshmem-test.c int main(int argc, char **argv) · line 540

Quoted 10 lines
tests/ivshmem-test.c +4 -2
         qtest_add_func("/ivshmem/pair", test_ivshmem_pair);
-        qtest_add_func("/ivshmem/server-msi", test_ivshmem_server_msi);
-        qtest_add_func("/ivshmem/server-irq", test_ivshmem_server_irq);
+        if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+            qtest_add_func("/ivshmem/server-msi", test_ivshmem_server_msi);
+            qtest_add_func("/ivshmem/server-irq", test_ivshmem_server_irq);
+        }
     }
 
     ret = g_test_run();

The commit message should explain things in a bit more detail: the test works only for x86, and is only compiled and executed for x86. The patch converts it to libqos, adds ppc64, and makes the test fail for targets that don't work. It also disables the unplug part of test /ivshmem/hotplug for ppc64; please explain why.

Please make the conversion to libqos a separate patch, for easier review.

#13 lore raw

Re: [Qemu-devel] [PATCH 4/4] qtest: add ivshmem-test for ppc64

Quoted 152 lines · Markus Armbruster
Quoted 102 lines · Laurent Vivier
---
 tests/Makefile.include |  3 ++-
 tests/ivshmem-test.c   | 46 +++++++++++++++++++++++++++++-----------------
 2 files changed, 31 insertions(+), 18 deletions(-)
tests/Makefile.include +2 -1
index b574964..09fe5b6 100644
@@ -287,6 +287,7 @@ check-qtest-ppc64-y += tests/test-netfilter$(EXESUF)
 check-qtest-ppc64-y += tests/test-filter-mirror$(EXESUF)
 check-qtest-ppc64-y += tests/test-filter-redirector$(EXESUF)
 check-qtest-ppc64-y += tests/display-vga-test$(EXESUF)
+check-qtest-ppc64-y += tests/ivshmem-test$(EXESUF)
 
 check-qtest-sh4-y = tests/endianness-test$(EXESUF)
 
@@ -690,7 +691,7 @@ tests/test-netfilter$(EXESUF): tests/test-netfilter.o $(qtest-obj-y)
 tests/test-filter-mirror$(EXESUF): tests/test-filter-mirror.o $(qtest-obj-y)
 tests/test-filter-redirector$(EXESUF): tests/test-filter-redirector.o $(qtest-obj-y)
 tests/test-x86-cpuid-compat$(EXESUF): tests/test-x86-cpuid-compat.o $(qtest-obj-y)
-tests/ivshmem-test$(EXESUF): tests/ivshmem-test.o contrib/ivshmem-server/ivshmem-server.o $(libqos-pc-obj-y)
+tests/ivshmem-test$(EXESUF): tests/ivshmem-test.o contrib/ivshmem-server/ivshmem-server.o $(libqos-pc-obj-y) $(libqos-spapr-obj-y)
 tests/vhost-user-bridge$(EXESUF): tests/vhost-user-bridge.o
 tests/test-uuid$(EXESUF): tests/test-uuid.o $(test-util-obj-y)
 tests/test-arm-mptimer$(EXESUF): tests/test-arm-mptimer.o
tests/ivshmem-test.c +9 -9
index 04a5c5d..5c6dc38 100644
@@ -11,8 +11,9 @@
 #include "qemu/osdep.h"
 #include <glib/gstdio.h>
 #include "contrib/ivshmem-server/ivshmem-server.h"
-#include "libqos/pci-pc.h"
 #include "libqtest.h"
+#include "libqos/libqos-pc.h"
+#include "libqos/libqos-spapr.h"
 #include "qemu-common.h"
 
 #define TMPSHMSIZE (1 << 20)
@@ -40,9 +41,8 @@ static QPCIDevice *get_device(QPCIBus *pcibus)
 }
 
 typedef struct _IVState {
-    QTestState *qtest;
+    QOSState *qs;
     QPCIBar reg_bar, mem_bar;
-    QPCIBus *pcibus;
     QPCIDevice *dev;
 } IVState;
 
@@ -74,7 +74,7 @@ static inline unsigned in_reg(IVState *s, enum Reg reg)
     QTestState *qtest = global_qtest;
     unsigned res;
 
-    global_qtest = s->qtest;
+    global_qtest = s->qs->qts;
     res = qpci_io_readl(s->dev, s->reg_bar, reg);
     g_test_message("*%s -> %x\n", name, res);
     global_qtest = qtest;
@@ -87,7 +87,7 @@ static inline void out_reg(IVState *s, enum Reg reg, unsigned v)
     const char *name = reg2str(reg);
     QTestState *qtest = global_qtest;
 
-    global_qtest = s->qtest;
+    global_qtest = s->qs->qts;
     g_test_message("%x -> *%s\n", v, name);
     qpci_io_writel(s->dev, s->reg_bar, reg, v);
     global_qtest = qtest;
@@ -97,7 +97,7 @@ static inline void read_mem(IVState *s, uint64_t off, void *buf, size_t len)
 {
     QTestState *qtest = global_qtest;
 
-    global_qtest = s->qtest;
+    global_qtest = s->qs->qts;
     qpci_memread(s->dev, s->mem_bar, off, buf, len);
     global_qtest = qtest;
 }
@@ -107,7 +107,7 @@ static inline void write_mem(IVState *s, uint64_t off,
 {
     QTestState *qtest = global_qtest;
 
-    global_qtest = s->qtest;
+    global_qtest = s->qs->qts;
     qpci_memwrite(s->dev, s->mem_bar, off, buf, len);
     global_qtest = qtest;
 }
@@ -115,17 +115,23 @@ static inline void write_mem(IVState *s, uint64_t off,
 static void cleanup_vm(IVState *s)
 {
     g_free(s->dev);
-    qpci_free_pc(s->pcibus);
-    qtest_quit(s->qtest);
+    qtest_shutdown(s->qs);
 }
 
 static void setup_vm_cmd(IVState *s, const char *cmd, bool msix)
 {
     uint64_t barsize;
+    const char *arch = qtest_get_arch();

tests/ivshmem-test.c static inline void write_mem(IVState *s, uint64_t off, · line 131

Quoted 10 lines
tests/ivshmem-test.c +6 -3
 
-    s->qtest = qtest_start(cmd);
-    s->pcibus = qpci_init_pc(NULL);
-    s->dev = get_device(s->pcibus);
+    if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+        s->qs = qtest_pc_boot(cmd);
+    } else if (strcmp(arch, "ppc64") == 0) {
+        s->qs = qtest_spapr_boot(cmd);
+    } else {
+        g_printerr("vshmem-test tests are only available on x86 or ppc64\n");

Typo: s/vshmem/ivshmem

To get here, you need to build and run this manually, as make check only builds and runs this for targets that work. But the check doesn't hurt, and documents expectations.

Quoted 31 lines
tests/ivshmem-test.c +6 -2
+        exit(EXIT_FAILURE);
+    }
+    s->dev = get_device(s->qs->pcibus);
 
     s->reg_bar = qpci_iomap(s->dev, 0, &barsize);
     g_assert_cmpuint(barsize, ==, 256);
@@ -347,7 +353,7 @@ static void test_ivshmem_server(bool msi)
     g_assert_cmpint(vm1, !=, vm2);
 
     /* check number of MSI-X vectors */
-    global_qtest = s1->qtest;
+    global_qtest = s1->qs->qts;
     if (msi) {
         ret = qpci_msix_table_size(s1->dev);
         g_assert_cmpuint(ret, ==, nvectors);
@@ -370,7 +376,7 @@ static void test_ivshmem_server(bool msi)
     g_assert_cmpuint(ret, !=, 0);
 
     /* ping vm1 -> vm2 on vector 1 */
-    global_qtest = s2->qtest;
+    global_qtest = s2->qs->qts;
     if (msi) {
         ret = qpci_msix_pending(s2->dev, 1);
         g_assert_cmpuint(ret, ==, 0);
@@ -412,6 +418,7 @@ static void test_ivshmem_server_irq(void)
 
 static void test_ivshmem_hotplug(void)
 {
+    const char *arch = qtest_get_arch();
     gchar *opts;
 
Quoted 4 lines

tests/ivshmem-test.c static void test_ivshmem_server_irq(void) · line 424

Quoted 1 line
tests/ivshmem-test.c +0 -0
     qtest_start("");

Unlike the other tests, this one doesn't refuse to run on unexpected targets. Intentional?

Yes, because there is no dependencies on libqos PCI implementation, so it should always work.

Quoted 42 lines

tests/ivshmem-test.c static void test_ivshmem_hotplug(void) · line 431

Quoted 8 lines
tests/ivshmem-test.c +3 -1
@@ -419,7 +426,9 @@ static void test_ivshmem_hotplug(void)
     opts = g_strdup_printf("'shm': '%s', 'size': '1M'", tmpshm);
 
     qpci_plug_device_test("ivshmem", "iv1", PCI_SLOT_HP, opts);
-    qpci_unplug_acpi_device_test("iv1", PCI_SLOT_HP);
+    if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+        qpci_unplug_acpi_device_test("iv1", PCI_SLOT_HP);
+    }

Disables unplug test for ppc64.

Quoted 14 lines
tests/ivshmem-test.c +1 -0
     qtest_end();
     g_free(opts);
@@ -491,6 +500,7 @@ static gchar *mktempshm(int size, int *fd)
 int main(int argc, char **argv)
 {
     int ret, fd;
+    const char *arch = qtest_get_arch();
     gchar dir[] = "/tmp/ivshmem-test.XXXXXX";
 
 #if !GLIB_CHECK_VERSION(2, 31, 0)
@@ -521,8 +531,10 @@ int main(int argc, char **argv)
     qtest_add_func("/ivshmem/memdev", test_ivshmem_memdev);
     if (g_test_slow()) {

tests/ivshmem-test.c int main(int argc, char **argv) · line 540

Quoted 10 lines
tests/ivshmem-test.c +4 -2
         qtest_add_func("/ivshmem/pair", test_ivshmem_pair);
-        qtest_add_func("/ivshmem/server-msi", test_ivshmem_server_msi);
-        qtest_add_func("/ivshmem/server-irq", test_ivshmem_server_irq);
+        if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+            qtest_add_func("/ivshmem/server-msi", test_ivshmem_server_msi);
+            qtest_add_func("/ivshmem/server-irq", test_ivshmem_server_irq);
+        }
     }
 
     ret = g_test_run();

The commit message should explain things in a bit more detail: the test works only for x86, and is only compiled and executed for x86. The patch converts it to libqos, adds ppc64, and makes the test fail for targets that don't work. It also disables the unplug part of test /ivshmem/hotplug for ppc64; please explain why.

Quoted 3 lines

Please make the conversion to libqos a separate patch, for easier review.

Thank you for the review.

I'm going to change this patch according to your comments.

Laurent

#14 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH 4/4] qtest: add ivshmem-test for ppc64

Quoted 4 lines · Laurent Vivier
Quoted 1 line · Markus Armbruster

Laurent Vivier <[email protected]> writes:

...

Quoted 10 lines
Quoted 10 lines

tests/ivshmem-test.c static void test_ivshmem_hotplug(void) · line 431

Quoted 8 lines
tests/ivshmem-test.c +3 -1
@@ -419,7 +426,9 @@ static void test_ivshmem_hotplug(void)
     opts = g_strdup_printf("'shm': '%s', 'size': '1M'", tmpshm);
 
     qpci_plug_device_test("ivshmem", "iv1", PCI_SLOT_HP, opts);
-    qpci_unplug_acpi_device_test("iv1", PCI_SLOT_HP);
+    if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+        qpci_unplug_acpi_device_test("iv1", PCI_SLOT_HP);
+    }

Disables unplug test for ppc64.

We don't have acpi on POWER ... but PCI unplug should be possible without ACPI, too, shouldn't it? So maybe you could add a PCI unplug function for ppc64, too?

Thomas

#15 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH 4/4] qtest: add ivshmem-test for ppc64

Quoted 17 lines · Thomas Huth
Quoted 4 lines · Laurent Vivier
Quoted 1 line · Markus Armbruster

Laurent Vivier <[email protected]> writes:

...

Quoted 10 lines
Quoted 10 lines

tests/ivshmem-test.c static void test_ivshmem_hotplug(void) · line 431

Quoted 8 lines
tests/ivshmem-test.c +3 -1
@@ -419,7 +426,9 @@ static void test_ivshmem_hotplug(void)
     opts = g_strdup_printf("'shm': '%s', 'size': '1M'", tmpshm);
 
     qpci_plug_device_test("ivshmem", "iv1", PCI_SLOT_HP, opts);
-    qpci_unplug_acpi_device_test("iv1", PCI_SLOT_HP);
+    if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+        qpci_unplug_acpi_device_test("iv1", PCI_SLOT_HP);
+    }

Disables unplug test for ppc64.

Quoted 3 lines

We don't have acpi on POWER ... but PCI unplug should be possible without ACPI, too, shouldn't it? So maybe you could add a PCI unplug function for ppc64, too?

Good idea, I will check if we can implement this.

Thanks,
Laurent