All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: ehabkost@redhat.com
Subject: [Qemu-devel] [PULL 10/14] tests: qpci_unplug_acpi_device_test() should not rely on global_qtest
Date: Thu,  9 May 2019 10:19:26 +0200	[thread overview]
Message-ID: <20190509081930.19081-11-thuth@redhat.com> (raw)
In-Reply-To: <20190509081930.19081-1-thuth@redhat.com>

libqos functions should not use functions that require global_qtest to
be set, since such library functions could also be used by tests that
deal with multiple test states. Add a parameter to this function to
explicitly specify the test state.

Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190508143209.24350-1-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/e1000e-test.c     |  4 +++-
 tests/ivshmem-test.c    |  9 ++++++---
 tests/libqos/pci-pc.c   | 10 +++++-----
 tests/libqos/pci.h      |  2 +-
 tests/virtio-blk-test.c |  3 ++-
 tests/virtio-net-test.c |  4 +++-
 tests/virtio-rng-test.c |  5 ++++-
 7 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/tests/e1000e-test.c b/tests/e1000e-test.c
index 77ba8095bb..6a946c0484 100644
--- a/tests/e1000e-test.c
+++ b/tests/e1000e-test.c
@@ -231,8 +231,10 @@ 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 */
+
     qtest_qmp_device_add("e1000e", "e1000e_net", "{'addr': '0x06'}");
-    qpci_unplug_acpi_device_test("e1000e_net", 0x06);
+    qpci_unplug_acpi_device_test(qts, "e1000e_net", 0x06);
 }
 
 static void data_test_clear(void *sockets)
diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c
index 227561fbca..a467b8c03d 100644
--- a/tests/ivshmem-test.c
+++ b/tests/ivshmem-test.c
@@ -383,18 +383,21 @@ static void test_ivshmem_server(void)
 
 static void test_ivshmem_hotplug(void)
 {
+    QTestState *qts;
     const char *arch = qtest_get_arch();
 
-    qtest_start("-object memory-backend-ram,size=1M,id=mb1");
+    qts = qtest_init("-object memory-backend-ram,size=1M,id=mb1");
 
+    global_qtest = qts;  /* TODO: Get rid of global_qtest here */
     qtest_qmp_device_add("ivshmem-plain", "iv1",
                          "{'addr': %s, 'memdev': 'mb1'}",
                          stringify(PCI_SLOT_HP));
     if (strcmp(arch, "ppc64") != 0) {
-        qpci_unplug_acpi_device_test("iv1", PCI_SLOT_HP);
+        qpci_unplug_acpi_device_test(qts, "iv1", PCI_SLOT_HP);
     }
 
-    qtest_end();
+    qtest_quit(qts);
+    global_qtest = NULL;
 }
 
 static void test_ivshmem_memdev(void)
diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c
index 407d8aff78..634fedd049 100644
--- a/tests/libqos/pci-pc.c
+++ b/tests/libqos/pci-pc.c
@@ -176,19 +176,19 @@ void qpci_free_pc(QPCIBus *bus)
     g_free(s);
 }
 
-void qpci_unplug_acpi_device_test(const char *id, uint8_t slot)
+void qpci_unplug_acpi_device_test(QTestState *qts, const char *id, uint8_t slot)
 {
     QDict *response;
 
-    response = qmp("{'execute': 'device_del', 'arguments': {'id': %s}}",
-                   id);
+    response = qtest_qmp(qts, "{'execute': 'device_del',"
+                              " 'arguments': {'id': %s}}", id);
     g_assert(response);
     g_assert(!qdict_haskey(response, "error"));
     qobject_unref(response);
 
-    outb(ACPI_PCIHP_ADDR + PCI_EJ_BASE, 1 << slot);
+    qtest_outb(qts, ACPI_PCIHP_ADDR + PCI_EJ_BASE, 1 << slot);
 
-    qmp_eventwait("DEVICE_DELETED");
+    qtest_qmp_eventwait(qts, "DEVICE_DELETED");
 }
 
 static void qpci_pc_register_nodes(void)
diff --git a/tests/libqos/pci.h b/tests/libqos/pci.h
index 8e1d292a7d..a5389a5845 100644
--- a/tests/libqos/pci.h
+++ b/tests/libqos/pci.h
@@ -123,7 +123,7 @@ QPCIBar qpci_iomap(QPCIDevice *dev, int barno, uint64_t *sizeptr);
 void qpci_iounmap(QPCIDevice *dev, QPCIBar addr);
 QPCIBar qpci_legacy_iomap(QPCIDevice *dev, uint16_t addr);
 
-void qpci_unplug_acpi_device_test(const char *id, uint8_t slot);
+void qpci_unplug_acpi_device_test(QTestState *qs, const char *id, uint8_t slot);
 
 void add_qpci_address(QOSGraphEdgeOptions *opts, QPCIAddress *addr);
 #endif
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index b65365934b..fe1168a90a 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -679,6 +679,7 @@ static void pci_hotplug(void *obj, void *data, QGuestAllocator *t_alloc)
 {
     QVirtioPCIDevice *dev1 = obj;
     QVirtioPCIDevice *dev;
+    QTestState *qts = dev1->pdev->bus->qts;
 
     /* plug secondary disk */
     qtest_qmp_device_add("virtio-blk-pci", "drv1",
@@ -693,7 +694,7 @@ static void pci_hotplug(void *obj, void *data, QGuestAllocator *t_alloc)
     qos_object_destroy((QOSGraphObject *)dev);
 
     /* unplug secondary disk */
-    qpci_unplug_acpi_device_test("drv1", PCI_SLOT_HP);
+    qpci_unplug_acpi_device_test(qts, "drv1", PCI_SLOT_HP);
 }
 
 /*
diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c
index 0d956f36fe..163126cf07 100644
--- a/tests/virtio-net-test.c
+++ b/tests/virtio-net-test.c
@@ -162,13 +162,15 @@ static void stop_cont_test(void *obj, void *data, QGuestAllocator *t_alloc)
 
 static void hotplug(void *obj, void *data, QGuestAllocator *t_alloc)
 {
+    QVirtioPCIDevice *dev = obj;
+    QTestState *qts = dev->pdev->bus->qts;
     const char *arch = qtest_get_arch();
 
     qtest_qmp_device_add("virtio-net-pci", "net1",
                          "{'addr': %s}", stringify(PCI_SLOT_HP));
 
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
-        qpci_unplug_acpi_device_test("net1", PCI_SLOT_HP);
+        qpci_unplug_acpi_device_test(qts, "net1", PCI_SLOT_HP);
     }
 }
 
diff --git a/tests/virtio-rng-test.c b/tests/virtio-rng-test.c
index 5309c7c8ab..fcb22481bd 100644
--- a/tests/virtio-rng-test.c
+++ b/tests/virtio-rng-test.c
@@ -16,13 +16,16 @@
 
 static void rng_hotplug(void *obj, void *data, QGuestAllocator *alloc)
 {
+    QVirtioPCIDevice *dev = obj;
+    QTestState *qts = dev->pdev->bus->qts;
+
     const char *arch = qtest_get_arch();
 
     qtest_qmp_device_add("virtio-rng-pci", "rng1",
                          "{'addr': %s}", stringify(PCI_SLOT_HP));
 
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
-        qpci_unplug_acpi_device_test("rng1", PCI_SLOT_HP);
+        qpci_unplug_acpi_device_test(qts, "rng1", PCI_SLOT_HP);
     }
 }
 
-- 
2.21.0



  parent reply	other threads:[~2019-05-09  8:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-09  8:19 [Qemu-devel] [PULL 00/14] qtests, copyright statement clarifications and misc patches Thomas Huth
2019-05-09  8:19 ` [Qemu-devel] [PULL 01/14] tests: Force Python I/O encoding for check-qapi-schema Thomas Huth
2019-05-09  8:19 ` [Qemu-devel] [PULL 02/14] tests/tco: Make test independent of global_qtest Thomas Huth
2019-05-09  8:19 ` [Qemu-devel] [PULL 03/14] tests/megasas: " Thomas Huth
2019-05-09  8:19 ` [Qemu-devel] [PULL 04/14] tests/qmp-cmd-test: Use qtest_init() instead of qtest_start() Thomas Huth
2019-05-09  8:19 ` [Qemu-devel] [PULL 05/14] tests/test-hmp: " Thomas Huth
2019-05-09  8:19 ` [Qemu-devel] [PULL 06/14] tests/ide-test: Make test independent of global_qtest Thomas Huth
2019-05-09  8:19 ` [Qemu-devel] [PULL 07/14] tests/tpm-tests: Use g_test_skip() to mark skipped tests Thomas Huth
2019-05-09  8:19 ` [Qemu-devel] [PULL 08/14] tests/Makefile: Remove unused test-obj-y variable Thomas Huth
2019-05-09  8:19 ` [Qemu-devel] [PULL 09/14] tests/drive_del-test: Use qtest_init() instead of qtest_start() Thomas Huth
2019-05-09  8:19 ` Thomas Huth [this message]
2019-05-09  8:19 ` [Qemu-devel] [PULL 11/14] hw/i2c/smbus_ich9: Fix the confusing contributions-after-2012 statement Thomas Huth
2019-05-09  8:19 ` [Qemu-devel] [PULL 12/14] target/openrisc: Fix LGPL information in the file headers Thomas Huth
2019-05-09  8:19 ` [Qemu-devel] [PULL 13/14] target/sh4: " Thomas Huth
2019-05-09  8:19 ` [Qemu-devel] [PULL 14/14] include/exec/poison: Mark TARGET_FMT_lu as poisoned, too Thomas Huth
2019-05-09 15:30 ` [Qemu-devel] [PULL 00/14] qtests, copyright statement clarifications and misc patches 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=20190509081930.19081-11-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.