All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, Cornelia Huck <cohuck@redhat.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David Hildenbrand <david@redhat.com>,
	Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>,
	Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>,
	Eric Farman <farman@linux.vnet.ibm.com>,
	Fan Zhang <zhangfan@linux.vnet.ibm.com>,
	Farhan Ali <alifm@linux.vnet.ibm.com>,
	Fei Li <sherrylf@linux.vnet.ibm.com>,
	Halil Pasic <pasic@linux.vnet.ibm.com>,
	Janosch Frank <frankja@linux.vnet.ibm.com>,
	Jason J Herne <jjherne@linux.vnet.ibm.com>,
	Jing Liu <liujbjl@linux.vnet.ibm.com>,
	Pierre Morel <pmorel@linux.vnet.ibm.com>,
	QingFeng Hao <haoqf@linux.vnet.ibm.com>,
	Xiao Feng Ren <renxiaof@linux.vnet.ibm.com>,
	Yang Chen <bjcyang@linux.vnet.ibm.com>,
	Yi Min Zhao <zyimin@linux.vnet.ibm.com>,
	Marc Mari <markmb@redhat.com>, Cleber Rosa <crosa@redhat.com>,
	Michael S Tsirkin <mst@redhat.com>
Subject: [Qemu-devel] [PATCH 5/6] tests: Add qvirtio_(un)plug_device_test wrapper functions
Date: Thu, 17 Aug 2017 08:25:12 +0200	[thread overview]
Message-ID: <1502951113-4246-6-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1502951113-4246-1-git-send-email-thuth@redhat.com>

To support hot-plugging tests with virtio-ccw later, the current
tests should become independent from PCI specific functions. Thus
let's add some proper wrapper function for virtio device hot-plugging
and -unplugging first.
It also seems like device unplugging works fine on ppc64 when using
the generic qtest_hot_unplug_device() function, so hot-unplugging
is now tested on ppc64, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/Makefile.include  |  4 ++--
 tests/libqos/virtio.c   | 27 +++++++++++++++++++++++++++
 tests/libqos/virtio.h   |  5 +++++
 tests/virtio-net-test.c |  8 ++------
 tests/virtio-rng-test.c |  9 +++------
 5 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index ff2a551..e3acdff 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -751,8 +751,8 @@ tests/wdt_ib700-test$(EXESUF): tests/wdt_ib700-test.o
 tests/tco-test$(EXESUF): tests/tco-test.o $(libqos-pc-obj-y)
 tests/virtio-balloon-test$(EXESUF): tests/virtio-balloon-test.o
 tests/virtio-blk-test$(EXESUF): tests/virtio-blk-test.o $(libqos-virtio-obj-y)
-tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o $(libqos-pc-obj-y) $(libqos-virtio-obj-y)
-tests/virtio-rng-test$(EXESUF): tests/virtio-rng-test.o $(libqos-pc-obj-y)
+tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o $(libqos-virtio-obj-y)
+tests/virtio-rng-test$(EXESUF): tests/virtio-rng-test.o $(libqos-virtio-obj-y)
 tests/virtio-scsi-test$(EXESUF): tests/virtio-scsi-test.o $(libqos-virtio-obj-y)
 tests/virtio-9p-test$(EXESUF): tests/virtio-9p-test.o $(libqos-virtio-obj-y)
 tests/virtio-serial-test$(EXESUF): tests/virtio-serial-test.o
diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c
index 9880a69..87d2e65 100644
--- a/tests/libqos/virtio.c
+++ b/tests/libqos/virtio.c
@@ -10,6 +10,7 @@
 #include "qemu/osdep.h"
 #include "libqtest.h"
 #include "libqos/virtio.h"
+#include "libqos/pci.h"
 #include "standard-headers/linux/virtio_config.h"
 #include "standard-headers/linux/virtio_ring.h"
 
@@ -339,3 +340,29 @@ void qvirtqueue_set_used_event(QVirtQueue *vq, uint16_t idx)
     /* vq->avail->used_event */
     writew(vq->avail + 4 + (2 * vq->size), idx);
 }
+
+void qvirtio_plug_device_test(const char *driver, const char *id,
+                              uint8_t addr, const char *opts)
+{
+    const char *arch = qtest_get_arch();
+
+    if (g_str_equal(arch, "i386") || g_str_equal(arch, "x86_64") ||
+        g_str_equal(arch, "ppc64")) {
+        qpci_plug_device_test(driver, id, addr, opts);
+    } else {
+        g_assert_not_reached();
+    }
+}
+
+void qvirtio_unplug_device_test(const char *id, uint8_t addr)
+{
+    const char *arch = qtest_get_arch();
+
+    if (g_str_equal(arch, "i386") || g_str_equal(arch, "x86_64")) {
+        qpci_unplug_acpi_device_test(id, addr);
+    } else if (g_str_equal(arch, "ppc64")) {
+        qtest_hot_unplug_device(id);
+    } else {
+        g_assert_not_reached();
+    }
+}
diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h
index 8fbcd18..03e33d6 100644
--- a/tests/libqos/virtio.h
+++ b/tests/libqos/virtio.h
@@ -143,4 +143,9 @@ void qvirtqueue_kick(QVirtioDevice *d, QVirtQueue *vq, uint32_t free_head);
 bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *desc_idx);
 
 void qvirtqueue_set_used_event(QVirtQueue *vq, uint16_t idx);
+
+void qvirtio_plug_device_test(const char *driver, const char *id,
+                              uint8_t addr, const char *opts);
+void qvirtio_unplug_device_test(const char *id, uint8_t addr);
+
 #endif
diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c
index 635b942..49e733d 100644
--- a/tests/virtio-net-test.c
+++ b/tests/virtio-net-test.c
@@ -241,15 +241,11 @@ 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);
+    qvirtio_plug_device_test("virtio-net", "net1", PCI_SLOT_HP, NULL);
 
-    if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
-        qpci_unplug_acpi_device_test("net1", PCI_SLOT_HP);
-    }
+    qvirtio_unplug_device_test("net1", PCI_SLOT_HP);
 
     test_end();
 }
diff --git a/tests/virtio-rng-test.c b/tests/virtio-rng-test.c
index dcecf77..04c4279 100644
--- a/tests/virtio-rng-test.c
+++ b/tests/virtio-rng-test.c
@@ -10,6 +10,7 @@
 #include "qemu/osdep.h"
 #include "libqtest.h"
 #include "libqos/pci.h"
+#include "libqos/virtio.h"
 
 #define PCI_SLOT_HP             0x06
 
@@ -20,13 +21,9 @@ static void pci_nop(void)
 
 static void hotplug(void)
 {
-    const char *arch = qtest_get_arch();
+    qvirtio_plug_device_test("virtio-rng-pci", "rng1", PCI_SLOT_HP, NULL);
 
-    qpci_plug_device_test("virtio-rng-pci", "rng1", PCI_SLOT_HP, NULL);
-
-    if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
-        qpci_unplug_acpi_device_test("rng1", PCI_SLOT_HP);
-    }
+    qvirtio_unplug_device_test("rng1", PCI_SLOT_HP);
 }
 
 int main(int argc, char **argv)
-- 
1.8.3.1

  parent reply	other threads:[~2017-08-17  6:26 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-17  6:25 [Qemu-devel] [PATCH for-2.11 0/6] Enable more qtests for s390x Thomas Huth
2017-08-17  6:25 ` [Qemu-devel] [PATCH 1/6] tests: Run filter-redirector and -mirror test only on POSIX systems Thomas Huth
2017-08-17  8:25   ` Cornelia Huck
2017-08-17  9:41   ` David Hildenbrand
2017-08-17 10:09   ` Zhang Chen
2017-08-30 19:35   ` Cleber Rosa
2017-08-17  6:25 ` [Qemu-devel] [PATCH 2/6] tests: Add network filter tests to the check-qtest-s390x list Thomas Huth
2017-08-17  8:41   ` Cornelia Huck
2017-08-17 14:02     ` Thomas Huth
2017-08-18  1:49       ` Zhang Chen
2017-08-18  7:54       ` Cornelia Huck
2017-08-18  8:47         ` Thomas Huth
2017-08-30 20:05         ` Cleber Rosa
2017-08-30 20:03     ` Cleber Rosa
2017-08-17  6:25 ` [Qemu-devel] [PATCH 3/6] tests: Enable the drive_del test also on s390x Thomas Huth
2017-08-17  8:53   ` Cornelia Huck
2017-08-17  9:46     ` David Hildenbrand
2017-08-17 13:54       ` Thomas Huth
2017-08-17 14:01         ` Cornelia Huck
2017-08-30 21:41   ` Cleber Rosa
2017-09-04 13:49     ` Cornelia Huck
2017-08-17  6:25 ` [Qemu-devel] [PATCH 4/6] tests: Introduce generic device hot-plug/hot-unplug functions Thomas Huth
2017-08-17  9:00   ` Cornelia Huck
2017-08-17  9:53   ` David Hildenbrand
2017-08-17 10:57     ` Thomas Huth
2017-08-17 11:16       ` David Hildenbrand
2017-08-17  6:25 ` Thomas Huth [this message]
2017-08-17  9:04   ` [Qemu-devel] [PATCH 5/6] tests: Add qvirtio_(un)plug_device_test wrapper functions Cornelia Huck
2017-08-17  6:25 ` [Qemu-devel] [PATCH 6/6] tests: Enable the simple virtio tests on s390x, too Thomas Huth
2017-08-17  9:07   ` Cornelia Huck
2017-08-17  9:11 ` [Qemu-devel] [PATCH for-2.11 0/6] Enable more qtests for s390x Cornelia Huck
2017-08-18 13:40   ` Cornelia Huck

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=1502951113-4246-6-git-send-email-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=alifm@linux.vnet.ibm.com \
    --cc=bjcyang@linux.vnet.ibm.com \
    --cc=bjsdjshi@linux.vnet.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=crosa@redhat.com \
    --cc=david@redhat.com \
    --cc=farman@linux.vnet.ibm.com \
    --cc=frankja@linux.vnet.ibm.com \
    --cc=haoqf@linux.vnet.ibm.com \
    --cc=imbrenda@linux.vnet.ibm.com \
    --cc=jjherne@linux.vnet.ibm.com \
    --cc=liujbjl@linux.vnet.ibm.com \
    --cc=markmb@redhat.com \
    --cc=mst@redhat.com \
    --cc=pasic@linux.vnet.ibm.com \
    --cc=pmorel@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=renxiaof@linux.vnet.ibm.com \
    --cc=sherrylf@linux.vnet.ibm.com \
    --cc=zhangfan@linux.vnet.ibm.com \
    --cc=zyimin@linux.vnet.ibm.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 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.