[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 08/49] tests: enable virtio tests on SPAPR
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 08/49] tests: enable virtio tests on SPAPR |
Date: |
Wed, 26 Oct 2016 22:42:12 +1100 |
From: Laurent Vivier <address@hidden>
but disable MSI-X tests on SPAPR as we can't check the result
(the memory region used on PC is not readable on SPAPR).
Signed-off-by: Laurent Vivier <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
tests/Makefile.include | 3 ++-
tests/libqos/virtio-pci.c | 24 ++++++++++++++++++++++--
tests/virtio-9p-test.c | 12 +++++++++++-
tests/virtio-blk-test.c | 25 ++++++++++++++++++++-----
tests/virtio-net-test.c | 18 ++++++++++++++++--
tests/virtio-rng-test.c | 7 ++++++-
tests/virtio-scsi-test.c | 12 +++++++++++-
7 files changed, 88 insertions(+), 13 deletions(-)
diff --git a/tests/Makefile.include b/tests/Makefile.include
index cd058ef..1666647 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -282,6 +282,7 @@ check-qtest-ppc64-y += tests/usb-hcd-uhci-test$(EXESUF)
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-sh4-y = tests/endianness-test$(EXESUF)
@@ -613,7 +614,7 @@ libqos-pc-obj-y += tests/libqos/ahci.o
libqos-omap-obj-y = $(libqos-obj-y) tests/libqos/i2c-omap.o
libqos-imx-obj-y = $(libqos-obj-y) tests/libqos/i2c-imx.o
libqos-usb-obj-y = $(libqos-spapr-obj-y) $(libqos-pc-obj-y) tests/libqos/usb.o
-libqos-virtio-obj-y = $(libqos-pc-obj-y) tests/libqos/virtio.o
tests/libqos/virtio-pci.o tests/libqos/virtio-mmio.o
tests/libqos/malloc-generic.o
+libqos-virtio-obj-y = $(libqos-spapr-obj-y) $(libqos-pc-obj-y)
tests/libqos/virtio.o tests/libqos/virtio-pci.o tests/libqos/virtio-mmio.o
tests/libqos/malloc-generic.o
tests/device-introspect-test$(EXESUF): tests/device-introspect-test.o
tests/rtc-test$(EXESUF): tests/rtc-test.o
diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c
index 7aa29b1..7e60b3a 100644
--- a/tests/libqos/virtio-pci.c
+++ b/tests/libqos/virtio-pci.c
@@ -68,16 +68,36 @@ static uint8_t qvirtio_pci_config_readb(QVirtioDevice *d,
uint64_t addr)
return qpci_io_readb(dev->pdev, (void *)(uintptr_t)addr);
}
+/* PCI is always read in little-endian order
+ * but virtio ( < 1.0) is in guest order
+ * so with a big-endian guest the order has been reversed,
+ * reverse it again
+ * virtio-1.0 is always little-endian, like PCI, but this
+ * case will be managed inside qvirtio_is_big_endian()
+ */
+
static uint16_t qvirtio_pci_config_readw(QVirtioDevice *d, uint64_t addr)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
- return qpci_io_readw(dev->pdev, (void *)(uintptr_t)addr);
+ uint16_t value;
+
+ value = qpci_io_readw(dev->pdev, (void *)(uintptr_t)addr);
+ if (qvirtio_is_big_endian(d)) {
+ value = bswap16(value);
+ }
+ return value;
}
static uint32_t qvirtio_pci_config_readl(QVirtioDevice *d, uint64_t addr)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
- return qpci_io_readl(dev->pdev, (void *)(uintptr_t)addr);
+ uint32_t value;
+
+ value = qpci_io_readl(dev->pdev, (void *)(uintptr_t)addr);
+ if (qvirtio_is_big_endian(d)) {
+ value = bswap32(value);
+ }
+ return value;
}
static uint64_t qvirtio_pci_config_readq(QVirtioDevice *d, uint64_t addr)
diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c
index 851ec99..693920a 100644
--- a/tests/virtio-9p-test.c
+++ b/tests/virtio-9p-test.c
@@ -11,6 +11,7 @@
#include "libqtest.h"
#include "qemu-common.h"
#include "libqos/libqos-pc.h"
+#include "libqos/libqos-spapr.h"
#include "libqos/virtio.h"
#include "libqos/virtio-pci.h"
#include "standard-headers/linux/virtio_ids.h"
@@ -22,13 +23,22 @@ static char *test_share;
static QOSState *qvirtio_9p_start(void)
{
+ const char *arch = qtest_get_arch();
const char *cmd = "-fsdev local,id=fsdev0,security_model=none,path=%s "
"-device virtio-9p-pci,fsdev=fsdev0,mount_tag=%s";
test_share = g_strdup("/tmp/qtest.XXXXXX");
g_assert_nonnull(mkdtemp(test_share));
- return qtest_pc_boot(cmd, test_share, mount_tag);
+ if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+ return qtest_pc_boot(cmd, test_share, mount_tag);
+ }
+ if (strcmp(arch, "ppc64") == 0) {
+ return qtest_spapr_boot(cmd, test_share, mount_tag);
+ }
+
+ g_printerr("virtio-9p tests are only available on x86 or ppc64\n");
+ exit(EXIT_FAILURE);
}
static void qvirtio_9p_stop(QOSState *qs)
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index 2382eb5..f737c40 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -11,6 +11,7 @@
#include "qemu/osdep.h"
#include "libqtest.h"
#include "libqos/libqos-pc.h"
+#include "libqos/libqos-spapr.h"
#include "libqos/virtio.h"
#include "libqos/virtio-pci.h"
#include "libqos/virtio-mmio.h"
@@ -59,6 +60,7 @@ static char *drive_create(void)
static QOSState *pci_test_start(void)
{
QOSState *qs;
+ const char *arch = qtest_get_arch();
char *tmp_path;
const char *cmd = "-drive if=none,id=drive0,file=%s,format=raw "
"-drive if=none,id=drive1,file=/dev/null,format=raw "
@@ -67,7 +69,14 @@ static QOSState *pci_test_start(void)
tmp_path = drive_create();
- qs = qtest_pc_boot(cmd, tmp_path, PCI_SLOT, PCI_FN);
+ if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+ qs = qtest_pc_boot(cmd, tmp_path, PCI_SLOT, PCI_FN);
+ } else if (strcmp(arch, "ppc64") == 0) {
+ qs = qtest_spapr_boot(cmd, tmp_path, PCI_SLOT, PCI_FN);
+ } else {
+ g_printerr("virtio-blk tests are only available on x86 or ppc64\n");
+ exit(EXIT_FAILURE);
+ }
unlink(tmp_path);
g_free(tmp_path);
return qs;
@@ -659,6 +668,7 @@ static void pci_hotplug(void)
{
QVirtioPCIDevice *dev;
QOSState *qs;
+ const char *arch = qtest_get_arch();
qs = pci_test_start();
@@ -672,7 +682,9 @@ static void pci_hotplug(void)
g_free(dev);
/* unplug secondary disk */
- qpci_unplug_acpi_device_test("drv1", PCI_SLOT_HP);
+ if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+ qpci_unplug_acpi_device_test("drv1", PCI_SLOT_HP);
+ }
qtest_shutdown(qs);
}
@@ -720,12 +732,15 @@ int main(int argc, char **argv)
g_test_init(&argc, &argv, NULL);
- if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+ if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0 ||
+ strcmp(arch, "ppc64") == 0) {
qtest_add_func("/virtio/blk/pci/basic", pci_basic);
qtest_add_func("/virtio/blk/pci/indirect", pci_indirect);
qtest_add_func("/virtio/blk/pci/config", pci_config);
- qtest_add_func("/virtio/blk/pci/msix", pci_msix);
- qtest_add_func("/virtio/blk/pci/idx", pci_idx);
+ if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+ qtest_add_func("/virtio/blk/pci/msix", pci_msix);
+ qtest_add_func("/virtio/blk/pci/idx", pci_idx);
+ }
qtest_add_func("/virtio/blk/pci/hotplug", pci_hotplug);
} else if (strcmp(arch, "arm") == 0) {
qtest_add_func("/virtio/blk/mmio/basic", mmio_basic);
diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c
index 6bec784..8f94360 100644
--- a/tests/virtio-net-test.c
+++ b/tests/virtio-net-test.c
@@ -13,6 +13,7 @@
#include "qemu/sockets.h"
#include "qemu/iov.h"
#include "libqos/libqos-pc.h"
+#include "libqos/libqos-spapr.h"
#include "libqos/virtio.h"
#include "libqos/virtio-pci.h"
#include "qemu/bswap.h"
@@ -52,10 +53,18 @@ static QVirtioPCIDevice *virtio_net_pci_init(QPCIBus *bus,
int slot)
static QOSState *pci_test_start(int socket)
{
+ const char *arch = qtest_get_arch();
const char *cmd = "-netdev socket,fd=%d,id=hs0 -device "
"virtio-net-pci,netdev=hs0";
- return qtest_pc_boot(cmd, socket);
+ if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+ return qtest_pc_boot(cmd, socket);
+ }
+ if (strcmp(arch, "ppc64") == 0) {
+ return qtest_spapr_boot(cmd, socket);
+ }
+ g_printerr("virtio-net tests are only available on x86 or ppc64\n");
+ exit(EXIT_FAILURE);
}
static void driver_init(QVirtioDevice *dev)
@@ -232,10 +241,15 @@ static void pci_basic(gconstpointer data)
static void hotplug(void)
{
+ const char *arch = qtest_get_arch();
+
qtest_start("-device virtio-net-pci");
qpci_plug_device_test("virtio-net-pci", "net1", PCI_SLOT_HP, NULL);
- qpci_unplug_acpi_device_test("net1", PCI_SLOT_HP);
+
+ if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+ qpci_unplug_acpi_device_test("net1", PCI_SLOT_HP);
+ }
test_end();
}
diff --git a/tests/virtio-rng-test.c b/tests/virtio-rng-test.c
index e1b2640..dcecf77 100644
--- a/tests/virtio-rng-test.c
+++ b/tests/virtio-rng-test.c
@@ -20,8 +20,13 @@ static void pci_nop(void)
static void hotplug(void)
{
+ const char *arch = qtest_get_arch();
+
qpci_plug_device_test("virtio-rng-pci", "rng1", PCI_SLOT_HP, NULL);
- qpci_unplug_acpi_device_test("rng1", PCI_SLOT_HP);
+
+ if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+ qpci_unplug_acpi_device_test("rng1", PCI_SLOT_HP);
+ }
}
int main(int argc, char **argv)
diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c
index 7d697ab..60dc9ab 100644
--- a/tests/virtio-scsi-test.c
+++ b/tests/virtio-scsi-test.c
@@ -12,6 +12,7 @@
#include "libqtest.h"
#include "block/scsi.h"
#include "libqos/libqos-pc.h"
+#include "libqos/libqos-spapr.h"
#include "libqos/virtio.h"
#include "libqos/virtio-pci.h"
#include "standard-headers/linux/virtio_ids.h"
@@ -33,11 +34,20 @@ typedef struct {
static QOSState *qvirtio_scsi_start(const char *extra_opts)
{
+ const char *arch = qtest_get_arch();
const char *cmd = "-drive id=drv0,if=none,file=/dev/null,format=raw "
"-device virtio-scsi-pci,id=vs0 "
"-device scsi-hd,bus=vs0.0,drive=drv0 %s";
- return qtest_pc_boot(cmd, extra_opts ? : "");
+ if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+ return qtest_pc_boot(cmd, extra_opts ? : "");
+ }
+ if (strcmp(arch, "ppc64") == 0) {
+ return qtest_spapr_boot(cmd, extra_opts ? : "");
+ }
+
+ g_printerr("virtio-scsi tests are only available on x86 or ppc64\n");
+ exit(EXIT_FAILURE);
}
static void qvirtio_scsi_stop(QOSState *qs)
--
2.7.4
- [Qemu-ppc] [PULL 00/49] ppc-for-2.8 queue 20161026, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 04/49] tests: don't check if qtest_spapr_boot() returns NULL, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 02/49] ppc/xics: Add xics to the monitor "info pic" command, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 03/49] tests: fix memory leak in virtio-scsi-test, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 09/49] spapr_pci: advertise explicit numa IDs even when there's 1 node, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 19/49] ppc: fix MSR_ME handling for system reset interrupt, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 10/49] nvram: Introduce helper functions for CHRP "system" and "free space" partitions, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 06/49] tests: rename target_big_endian() as qvirtio_is_big_endian(), David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 08/49] tests: enable virtio tests on SPAPR,
David Gibson <=
- [Qemu-ppc] [PULL 21/49] ppc: Fix single step with gdb stub, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 11/49] sparc: Use the new common NVRAM functions for system and free space partition, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 14/49] target-ppc: implement vnegw/d instructions, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 20/49] pseries: Remove unused callbacks from sPAPR VIO bus state, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 12/49] nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch], David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 07/49] tests: use qtest_pc_boot()/qtest_shutdown() in virtio tests, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 18/49] ppc/xics: change the icp_ routines API to use an 'ICPState *' argument, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 35/49] pseries: Make spapr_create_fdt_skel() get information from machine state, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 05/49] tests: move QVirtioBus pointer into QVirtioDevice, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 24/49] ppc/pnv: add a PnvChip object, David Gibson, 2016/10/26