From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: thuth@redhat.com, lviver@redhat.com,
Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
Subject: [Qemu-devel] [PULL 49/57] qos-test: nvme test node
Date: Thu, 7 Mar 2019 18:29:56 +0100 [thread overview]
Message-ID: <1551979804-6060-50-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1551979804-6060-1-git-send-email-pbonzini@redhat.com>
From: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
Convert tests/nvme-test to a driver node; the code to discover the PCI
device is replaced by generic qgraph code, therefore we're not placing it in tests/libqos.
Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
tests/Makefile.include | 3 +-
tests/nvme-test.c | 78 +++++++++++++++++++++++++++-----------------------
2 files changed, 43 insertions(+), 38 deletions(-)
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 0d06490..46f8c34 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -155,7 +155,6 @@ check-qtest-pci-y += tests/e1000-test$(EXESUF)
check-qtest-pci-$(CONFIG_RTL8139_PCI) += tests/rtl8139-test$(EXESUF)
check-qtest-pci-$(CONFIG_PCNET_PCI) += tests/pcnet-test$(EXESUF)
check-qtest-pci-$(CONFIG_EEPRO100_PCI) += tests/eepro100-test$(EXESUF)
-check-qtest-pci-$(CONFIG_NVME_PCI) += tests/nvme-test$(EXESUF)
check-qtest-pci-$(CONFIG_ES1370) += tests/es1370-test$(EXESUF)
check-qtest-pci-$(CONFIG_VGA) += tests/display-vga-test$(EXESUF)
check-qtest-pci-$(CONFIG_HDA) += tests/intel-hda-test$(EXESUF)
@@ -753,6 +752,7 @@ qos-test-obj-y += tests/ac97-test.o
qos-test-obj-y += tests/e1000e-test.o
qos-test-obj-y += tests/ipoctal232-test.o
qos-test-obj-y += tests/ne2000-test.o
+qos-test-obj-y += tests/nvme-test.o
qos-test-obj-y += tests/pci-test.o
qos-test-obj-y += tests/sdhci-test.o
qos-test-obj-$(CONFIG_VHOST_NET_USER) += tests/vhost-user-test.o $(chardev-obj-y) $(test-io-obj-y)
@@ -814,7 +814,6 @@ tests/test-hmp$(EXESUF): tests/test-hmp.o
tests/machine-none-test$(EXESUF): tests/machine-none-test.o
tests/device-plug-test$(EXESUF): tests/device-plug-test.o
tests/drive_del-test$(EXESUF): tests/drive_del-test.o
-tests/nvme-test$(EXESUF): tests/nvme-test.o $(libqos-pc-obj-y)
tests/pvpanic-test$(EXESUF): tests/pvpanic-test.o
tests/i82801b11-test$(EXESUF): tests/i82801b11-test.o
tests/es1370-test$(EXESUF): tests/es1370-test.o
diff --git a/tests/nvme-test.c b/tests/nvme-test.c
index 2700ba8..b48d3a2 100644
--- a/tests/nvme-test.c
+++ b/tests/nvme-test.c
@@ -10,49 +10,47 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
#include "libqtest.h"
-#include "libqos/libqos-pc.h"
+#include "libqos/qgraph.h"
+#include "libqos/pci.h"
-static QOSState *qnvme_start(const char *extra_opts)
+typedef struct QNvme QNvme;
+
+struct QNvme {
+ QOSGraphObject obj;
+ QPCIDevice dev;
+};
+
+static void *nvme_get_driver(void *obj, const char *interface)
{
- QOSState *qs;
- const char *arch = qtest_get_arch();
- const char *cmd = "-drive id=drv0,if=none,file=null-co://,format=raw "
- "-device nvme,addr=0x4.0,serial=foo,drive=drv0 %s";
-
- if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
- qs = qtest_pc_boot(cmd, extra_opts ? : "");
- global_qtest = qs->qts;
- return qs;
+ QNvme *nvme = obj;
+
+ if (!g_strcmp0(interface, "pci-device")) {
+ return &nvme->dev;
}
- g_printerr("nvme tests are only available on x86\n");
- exit(EXIT_FAILURE);
+ fprintf(stderr, "%s not present in nvme\n", interface);
+ g_assert_not_reached();
}
-static void qnvme_stop(QOSState *qs)
+static void *nvme_create(void *pci_bus, QGuestAllocator *alloc, void *addr)
{
- qtest_shutdown(qs);
-}
+ QNvme *nvme = g_new0(QNvme, 1);
+ QPCIBus *bus = pci_bus;
-static void nop(void)
-{
- QOSState *qs;
+ qpci_device_init(&nvme->dev, bus, addr);
+ nvme->obj.get_driver = nvme_get_driver;
- qs = qnvme_start(NULL);
- qnvme_stop(qs);
+ return &nvme->obj;
}
-static void nvmetest_cmb_test(void)
+/* This used to cause a NULL pointer dereference. */
+static void nvmetest_oob_cmb_test(void *obj, void *data, QGuestAllocator *alloc)
{
const int cmb_bar_size = 2 * MiB;
- QOSState *qs;
- QPCIDevice *pdev;
+ QNvme *nvme = obj;
+ QPCIDevice *pdev = &nvme->dev;
QPCIBar bar;
- qs = qnvme_start("-global nvme.cmb_size_mb=2");
- pdev = qpci_device_find(qs->pcibus, QPCI_DEVFN(4,0));
- g_assert(pdev != NULL);
-
qpci_device_enable(pdev);
bar = qpci_iomap(pdev, 2, NULL);
@@ -65,16 +63,24 @@ static void nvmetest_cmb_test(void)
g_assert_cmpint(qpci_io_readb(pdev, bar, cmb_bar_size - 1), ==, 0x11);
g_assert_cmpint(qpci_io_readw(pdev, bar, cmb_bar_size - 1), !=, 0x2211);
g_assert_cmpint(qpci_io_readl(pdev, bar, cmb_bar_size - 1), !=, 0x44332211);
- g_free(pdev);
-
- qnvme_stop(qs);
}
-int main(int argc, char **argv)
+static void nvme_register_nodes(void)
{
- g_test_init(&argc, &argv, NULL);
- qtest_add_func("/nvme/nop", nop);
- qtest_add_func("/nvme/cmb_test", nvmetest_cmb_test);
+ QOSGraphEdgeOptions opts = {
+ .extra_device_opts = "addr=04.0,drive=drv0,serial=foo",
+ .before_cmd_line = "-drive id=drv0,if=none,file=null-co://,format=raw",
+ };
+
+ add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) });
- return g_test_run();
+ qos_node_create_driver("nvme", nvme_create);
+ qos_node_consumes("nvme", "pci-bus", &opts);
+ qos_node_produces("nvme", "pci-device");
+
+ qos_add_test("oob-cmb-access", "nvme", nvmetest_oob_cmb_test, &(QOSGraphTestOptions) {
+ .edge.extra_device_opts = "cmb_size_mb=2"
+ });
}
+
+libqos_init(nvme_register_nodes);
--
1.8.3.1
next prev parent reply other threads:[~2019-03-07 17:31 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-07 17:29 [Qemu-devel] [PULL 00/57] qgraph merge Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 01/57] chardev-socket: do not blindly reset handlers when switching GMainContext Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 02/57] tests/libqos: introduce virtio_start_device Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 03/57] tests/libqos: rename qpci_init_pc and qpci_init_spapr functions Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 04/57] tests/libqos: embed allocators instead of malloc-ing them separately Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 05/57] tests: qgraph API for the qtest driver framework Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 06/57] tests/libqos: pci-pc driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 07/57] tests/libqos: x86_64/pc machine node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 08/57] tests/libqos: sdhci driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 09/57] tests/libqos: arm/raspi2 machine node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 10/57] tests/libqos: arm/smdkc210 " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 11/57] tests/libqos: arm/sabrelite " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 12/57] tests/libqos: arm/xilinx-zynq-a9 " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 13/57] tests/libqos: aarch64/xlnx-zcu102 " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 14/57] qos-test: sdhci test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 15/57] tests/qgraph: add generic PCI testcases Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 16/57] tests/libqos: pci-spapr driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 17/57] tests/qgraph: ppc64/pseries machine node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 18/57] tests/libqos: has_buggy_msi flag Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 19/57] tests/libqos: e1000e driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 20/57] qos-test: e1000e test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 21/57] tests/libqos: virtio-pci driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 22/57] tests/libqos: remove global_qtest from virtio endianness checks Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 23/57] tests/libqos: virtio-mmio driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 24/57] tests/libqos: arm/virt machine node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 25/57] tests/qgraph: add generic virtio testcases Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 26/57] tests/libqos: virtio-serial driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 27/57] qos-test: virtio-console and virtio-serial test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 28/57] tests/libqos: virtio-9p driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 29/57] qos-test: virtio-9p test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 30/57] tests/libqos: virtio-balloon driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 31/57] tests/qgraph: remove virtio-balloon-test Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 32/57] tests/libqos: virtio-rng driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 33/57] qos-test: virtio-rng test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 34/57] tests/libqos: virtio-blk driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 35/57] qos-test: virtio-blk test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 36/57] tests/libqos: virtio-net driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 37/57] qos-test: virtio-net test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 38/57] tests/libqos: support multiqueue for virtio-net Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 39/57] vhost-user-test: always use 256 MiB of guest memory Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 40/57] qos-test: vhost-user test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 41/57] tests/libqos: virtio-scsi driver and interface nodes Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 42/57] qos-test: virtio-scsi test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 43/57] tests/libqos: remove pre-qgraph QVirtioPCIDevice API Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 44/57] tests: move virtio entirely to qos-test Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 45/57] qos-test: ac97 test node Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 46/57] qos-test: tpci200 " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 47/57] qos-test: ipoctal232 " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 48/57] qos-test: ne2k_pci " Paolo Bonzini
2019-03-07 17:29 ` Paolo Bonzini [this message]
2019-03-07 17:29 ` [Qemu-devel] [PULL 50/57] qos-test: pcnet " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 51/57] qos-test: spapr-phb " Paolo Bonzini
2019-03-07 17:29 ` [Qemu-devel] [PULL 52/57] qos-test: usb-hcd-ohci " Paolo Bonzini
2019-03-07 17:30 ` [Qemu-devel] [PULL 53/57] qos-test: vmxnet3 " Paolo Bonzini
2019-03-07 17:30 ` [Qemu-devel] [PULL 54/57] qos-test: es1370 " Paolo Bonzini
2019-03-07 17:30 ` [Qemu-devel] [PULL 55/57] qos-test: eepro100 " Paolo Bonzini
2019-03-07 17:30 ` [Qemu-devel] [PULL 56/57] qos-test: e1000 " Paolo Bonzini
2019-03-07 17:30 ` [Qemu-devel] [PULL 57/57] qos-test: megasas " Paolo Bonzini
2019-03-08 15:16 ` [Qemu-devel] [PULL 00/57] qgraph merge Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1551979804-6060-50-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=e.emanuelegiuseppe@gmail.com \
--cc=lviver@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).