From nobody Sun Feb 8 17:47:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502951258421260.08761185412345; Wed, 16 Aug 2017 23:27:38 -0700 (PDT) Received: from localhost ([::1]:35025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diEHJ-0002wj-6I for importer@patchew.org; Thu, 17 Aug 2017 02:27:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diEFl-0001zf-PV for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:26:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diEFi-0007Ac-Kt for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:26:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58956) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1diEFi-0007AE-Bw for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:25:58 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 45946478A; Thu, 17 Aug 2017 06:25:57 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50C3B5C899; Thu, 17 Aug 2017 06:25:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 45946478A Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=thuth@redhat.com From: Thomas Huth To: qemu-devel@nongnu.org, Cornelia Huck , Christian Borntraeger Date: Thu, 17 Aug 2017 08:25:12 +0200 Message-Id: <1502951113-4246-6-git-send-email-thuth@redhat.com> In-Reply-To: <1502951113-4246-1-git-send-email-thuth@redhat.com> References: <1502951113-4246-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 17 Aug 2017 06:25:57 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 5/6] tests: Add qvirtio_(un)plug_device_test wrapper functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Farman , Janosch Frank , Halil Pasic , Yi Min Zhao , Jason J Herne , David Hildenbrand , Pierre Morel , Farhan Ali , Jing Liu , Fan Zhang , Claudio Imbrenda , QingFeng Hao , Michael S Tsirkin , Xiao Feng Ren , Fei Li , Cleber Rosa , Dong Jia Shi , Yang Chen , Marc Mari Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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-ob= j-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-ob= j-y) +tests/virtio-rng-test$(EXESUF): tests/virtio-rng-test.o $(libqos-virtio-ob= j-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" =20 @@ -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 =3D 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 =3D 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); =20 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) =20 static void hotplug(void) { - const char *arch =3D qtest_get_arch(); - qtest_start("-device virtio-net-pci"); =20 - qpci_plug_device_test("virtio-net-pci", "net1", PCI_SLOT_HP, NULL); + qvirtio_plug_device_test("virtio-net", "net1", PCI_SLOT_HP, NULL); =20 - if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { - qpci_unplug_acpi_device_test("net1", PCI_SLOT_HP); - } + qvirtio_unplug_device_test("net1", PCI_SLOT_HP); =20 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" =20 #define PCI_SLOT_HP 0x06 =20 @@ -20,13 +21,9 @@ static void pci_nop(void) =20 static void hotplug(void) { - const char *arch =3D qtest_get_arch(); + qvirtio_plug_device_test("virtio-rng-pci", "rng1", PCI_SLOT_HP, NULL); =20 - qpci_plug_device_test("virtio-rng-pci", "rng1", PCI_SLOT_HP, NULL); - - if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { - qpci_unplug_acpi_device_test("rng1", PCI_SLOT_HP); - } + qvirtio_unplug_device_test("rng1", PCI_SLOT_HP); } =20 int main(int argc, char **argv) --=20 1.8.3.1