From nobody Thu May 2 09:33:23 2024 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 1502951321229936.9376428602234; Wed, 16 Aug 2017 23:28:41 -0700 (PDT) Received: from localhost ([::1]:35054 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diEIK-0003vW-5I for importer@patchew.org; Thu, 17 Aug 2017 02:28:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diEFJ-0001i5-8m for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:25:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diEFI-0006OI-Cc for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:25:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36976) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1diEFI-0006Lp-3R for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:25:32 -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 D19749022D; Thu, 17 Aug 2017 06:25:30 +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 C544B5C882; Thu, 17 Aug 2017 06:25:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D19749022D Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.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:08 +0200 Message-Id: <1502951113-4246-2-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.26]); Thu, 17 Aug 2017 06:25:31 +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 1/6] tests: Run filter-redirector and -mirror test only on POSIX systems 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" This way we can get rid of the ugly #ifdefs in the code which makes it easier to extend later. Signed-off-by: Thomas Huth Reviewed-by: Cornelia Huck Reviewed-by: David Hildenbrand Reviewed-by: Zhang Chen Tested-by: Cleber Rosa --- tests/Makefile.include | 8 ++++---- tests/test-filter-mirror.c | 5 ----- tests/test-filter-redirector.c | 10 ---------- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 37c1bed..8d5991d 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -283,8 +283,8 @@ ifeq ($(CONFIG_VHOST_USER_NET_TEST_i386),) check-qtest-x86_64-$(CONFIG_VHOST_USER_NET_TEST_x86_64) +=3D tests/vhost-u= ser-test$(EXESUF) endif check-qtest-i386-$(CONFIG_SLIRP) +=3D tests/test-netfilter$(EXESUF) -check-qtest-i386-y +=3D tests/test-filter-mirror$(EXESUF) -check-qtest-i386-y +=3D tests/test-filter-redirector$(EXESUF) +check-qtest-i386-$(CONFIG_POSIX) +=3D tests/test-filter-mirror$(EXESUF) +check-qtest-i386-$(CONFIG_POSIX) +=3D tests/test-filter-redirector$(EXESUF) check-qtest-i386-y +=3D tests/postcopy-test$(EXESUF) check-qtest-i386-y +=3D tests/test-x86-cpuid-compat$(EXESUF) check-qtest-i386-y +=3D tests/numa-test$(EXESUF) @@ -325,8 +325,8 @@ check-qtest-ppc64-y +=3D tests/usb-hcd-xhci-test$(EXESU= F) gcov-files-ppc64-y +=3D hw/usb/hcd-xhci.c check-qtest-ppc64-y +=3D $(check-qtest-virtio-y) check-qtest-ppc64-$(CONFIG_SLIRP) +=3D tests/test-netfilter$(EXESUF) -check-qtest-ppc64-y +=3D tests/test-filter-mirror$(EXESUF) -check-qtest-ppc64-y +=3D tests/test-filter-redirector$(EXESUF) +check-qtest-ppc64-$(CONFIG_POSIX) +=3D tests/test-filter-mirror$(EXESUF) +check-qtest-ppc64-$(CONFIG_POSIX) +=3D tests/test-filter-redirector$(EXESU= F) check-qtest-ppc64-y +=3D tests/display-vga-test$(EXESUF) check-qtest-ppc64-y +=3D tests/numa-test$(EXESUF) check-qtest-ppc64-$(CONFIG_IVSHMEM) +=3D tests/ivshmem-test$(EXESUF) diff --git a/tests/test-filter-mirror.c b/tests/test-filter-mirror.c index 9f84402..a1d5865 100644 --- a/tests/test-filter-mirror.c +++ b/tests/test-filter-mirror.c @@ -17,9 +17,6 @@ =20 static void test_mirror(void) { -#ifndef _WIN32 -/* socketpair(PF_UNIX) which does not exist on windows */ - int send_sock[2], recv_sock; char *cmdline; uint32_t ret =3D 0, len =3D 0; @@ -74,8 +71,6 @@ static void test_mirror(void) g_free(recv_buf); close(recv_sock); unlink(sock_path); - -#endif } =20 int main(int argc, char **argv) diff --git a/tests/test-filter-redirector.c b/tests/test-filter-redirector.c index 0c4b8d5..69c663b 100644 --- a/tests/test-filter-redirector.c +++ b/tests/test-filter-redirector.c @@ -59,9 +59,6 @@ =20 static void test_redirector_tx(void) { -#ifndef _WIN32 -/* socketpair(PF_UNIX) which does not exist on windows */ - int backend_sock[2], recv_sock; char *cmdline; uint32_t ret =3D 0, len =3D 0; @@ -129,15 +126,10 @@ static void test_redirector_tx(void) unlink(sock_path0); unlink(sock_path1); qtest_end(); - -#endif } =20 static void test_redirector_rx(void) { -#ifndef _WIN32 -/* socketpair(PF_UNIX) which does not exist on windows */ - int backend_sock[2], send_sock; char *cmdline; uint32_t ret =3D 0, len =3D 0; @@ -203,8 +195,6 @@ static void test_redirector_rx(void) unlink(sock_path0); unlink(sock_path1); qtest_end(); - -#endif } =20 int main(int argc, char **argv) --=20 1.8.3.1 From nobody Thu May 2 09:33:23 2024 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 1502951390448825.8750916294847; Wed, 16 Aug 2017 23:29:50 -0700 (PDT) Received: from localhost ([::1]:35104 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diEJQ-0004eT-En for importer@patchew.org; Thu, 17 Aug 2017 02:29:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diEFR-0001n0-28 for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:25:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diEFN-0006Yr-S3 for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:25:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42250) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1diEFN-0006Xw-DZ for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:25:37 -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 44AC8C0860A9; Thu, 17 Aug 2017 06:25:36 +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 397AB5C882; Thu, 17 Aug 2017 06:25:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 44AC8C0860A9 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.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:09 +0200 Message-Id: <1502951113-4246-3-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.31]); Thu, 17 Aug 2017 06:25:36 +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 2/6] tests: Add network filter tests to the check-qtest-s390x list 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" With some small modifications, we can also use the the netfilter, the fiter-mirror and the filter-redirector tests on s390x. Signed-off-by: Thomas Huth Reviewed-by: Cleber Rosa Reviewed-by: Cornelia Huck Reviewed-by: Zhang Chen --- tests/Makefile.include | 3 +++ tests/test-filter-mirror.c | 9 +++++++-- tests/test-filter-redirector.c | 22 ++++++++++++++++------ tests/test-netfilter.c | 11 ++++++++++- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 8d5991d..0bb18b3 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -360,6 +360,9 @@ check-qtest-microblazeel-y =3D $(check-qtest-microblaze= -y) check-qtest-xtensaeb-y =3D $(check-qtest-xtensa-y) =20 check-qtest-s390x-y =3D tests/boot-serial-test$(EXESUF) +check-qtest-s390x-$(CONFIG_SLIRP) +=3D tests/test-netfilter$(EXESUF) +check-qtest-s390x-$(CONFIG_POSIX) +=3D tests/test-filter-mirror$(EXESUF) +check-qtest-s390x-$(CONFIG_POSIX) +=3D tests/test-filter-redirector$(EXESU= F) =20 check-qtest-generic-y +=3D tests/qom-test$(EXESUF) check-qtest-generic-y +=3D tests/test-hmp$(EXESUF) diff --git a/tests/test-filter-mirror.c b/tests/test-filter-mirror.c index a1d5865..d569d27 100644 --- a/tests/test-filter-mirror.c +++ b/tests/test-filter-mirror.c @@ -25,6 +25,11 @@ static void test_mirror(void) char *recv_buf; uint32_t size =3D sizeof(send_buf); size =3D htonl(size); + const char *devstr =3D "e1000"; + + if (g_str_equal(qtest_get_arch(), "s390x")) { + devstr =3D "virtio-net-ccw"; + } =20 ret =3D socketpair(PF_UNIX, SOCK_STREAM, 0, send_sock); g_assert_cmpint(ret, !=3D, -1); @@ -33,10 +38,10 @@ static void test_mirror(void) g_assert_cmpint(ret, !=3D, -1); =20 cmdline =3D g_strdup_printf("-netdev socket,id=3Dqtest-bn0,fd=3D%d " - "-device e1000,netdev=3Dqtest-bn0,id=3Dqtest-e0 " + "-device %s,netdev=3Dqtest-bn0,id=3Dqtest-e0 " "-chardev socket,id=3Dmirror0,path=3D%s,server,nowait " "-object filter-mirror,id=3Dqtest-f0,netdev=3Dqtest-bn0,q= ueue=3Dtx,outdev=3Dmirror0 " - , send_sock[1], sock_path); + , send_sock[1], devstr, sock_path); qtest_start(cmdline); g_free(cmdline); =20 diff --git a/tests/test-filter-redirector.c b/tests/test-filter-redirector.c index 69c663b..3afd411 100644 --- a/tests/test-filter-redirector.c +++ b/tests/test-filter-redirector.c @@ -57,6 +57,16 @@ #include "qemu/error-report.h" #include "qemu/main-loop.h" =20 +static const char *get_devstr(void) +{ + if (g_str_equal(qtest_get_arch(), "s390x")) { + return "virtio-net-ccw"; + } + + return "rtl8139"; +} + + static void test_redirector_tx(void) { int backend_sock[2], recv_sock; @@ -78,7 +88,7 @@ static void test_redirector_tx(void) g_assert_cmpint(ret, !=3D, -1); =20 cmdline =3D g_strdup_printf("-netdev socket,id=3Dqtest-bn0,fd=3D%d " - "-device rtl8139,netdev=3Dqtest-bn0,id=3Dqtest-e0 " + "-device %s,netdev=3Dqtest-bn0,id=3Dqtest-e0 " "-chardev socket,id=3Dredirector0,path=3D%s,server,nowait " "-chardev socket,id=3Dredirector1,path=3D%s,server,nowait " "-chardev socket,id=3Dredirector2,path=3D%s,nowait " @@ -87,8 +97,8 @@ static void test_redirector_tx(void) "-object filter-redirector,id=3Dqtest-f1,netdev=3Dqtest-bn= 0," "queue=3Dtx,indev=3Dredirector2 " "-object filter-redirector,id=3Dqtest-f2,netdev=3Dqtest-bn= 0," - "queue=3Dtx,outdev=3Dredirector1 " - , backend_sock[1], sock_path0, sock_path1, sock_path0); + "queue=3Dtx,outdev=3Dredirector1 ", backend_sock[1], get_d= evstr(), + sock_path0, sock_path1, sock_path0); qtest_start(cmdline); g_free(cmdline); =20 @@ -149,7 +159,7 @@ static void test_redirector_rx(void) g_assert_cmpint(ret, !=3D, -1); =20 cmdline =3D g_strdup_printf("-netdev socket,id=3Dqtest-bn0,fd=3D%d " - "-device rtl8139,netdev=3Dqtest-bn0,id=3Dqtest-e0 " + "-device %s,netdev=3Dqtest-bn0,id=3Dqtest-e0 " "-chardev socket,id=3Dredirector0,path=3D%s,server,nowait " "-chardev socket,id=3Dredirector1,path=3D%s,server,nowait " "-chardev socket,id=3Dredirector2,path=3D%s,nowait " @@ -158,8 +168,8 @@ static void test_redirector_rx(void) "-object filter-redirector,id=3Dqtest-f1,netdev=3Dqtest-bn= 0," "queue=3Drx,outdev=3Dredirector2 " "-object filter-redirector,id=3Dqtest-f2,netdev=3Dqtest-bn= 0," - "queue=3Drx,indev=3Dredirector1 " - , backend_sock[1], sock_path0, sock_path1, sock_path0); + "queue=3Drx,indev=3Dredirector1 ", backend_sock[1], get_de= vstr(), + sock_path0, sock_path1, sock_path0); qtest_start(cmdline); g_free(cmdline); =20 diff --git a/tests/test-netfilter.c b/tests/test-netfilter.c index 8b5a9b2..2506473 100644 --- a/tests/test-netfilter.c +++ b/tests/test-netfilter.c @@ -182,6 +182,12 @@ static void remove_netdev_with_multi_netfilter(void) int main(int argc, char **argv) { int ret; + char *args; + const char *devstr =3D "e1000"; + + if (g_str_equal(qtest_get_arch(), "s390x")) { + devstr =3D "virtio-net-ccw"; + } =20 g_test_init(&argc, &argv, NULL); qtest_add_func("/netfilter/addremove_one", add_one_netfilter); @@ -191,10 +197,13 @@ int main(int argc, char **argv) qtest_add_func("/netfilter/remove_netdev_multi", remove_netdev_with_multi_netfilter); =20 - qtest_start("-netdev user,id=3Dqtest-bn0 -device e1000,netdev=3Dqtest-= bn0"); + args =3D g_strdup_printf("-netdev user,id=3Dqtest-bn0 " + "-device %s,netdev=3Dqtest-bn0", devstr); + qtest_start(args); ret =3D g_test_run(); =20 qtest_end(); + g_free(args); =20 return ret; } --=20 1.8.3.1 From nobody Thu May 2 09:33:23 2024 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 1502951459443913.5267199651076; Wed, 16 Aug 2017 23:30:59 -0700 (PDT) Received: from localhost ([::1]:35139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diEKY-0005TK-8N for importer@patchew.org; Thu, 17 Aug 2017 02:30:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39972) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diEFb-0001t0-5V for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:25:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diEFY-00070b-0x for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:25:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60214) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1diEFX-0006yF-O6 for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:25:47 -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 98F652DE41E; Thu, 17 Aug 2017 06:25:46 +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 99AF85C882; Thu, 17 Aug 2017 06:25:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 98F652DE41E Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.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:10 +0200 Message-Id: <1502951113-4246-4-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.29]); Thu, 17 Aug 2017 06:25:46 +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 3/6] tests: Enable the drive_del test also on s390x 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" By using the "virtio-xxx" device name aliases instead of the "virtio-xxx-pci" names, we can use this test on s390x, too, to check that adding and deleting also works fine with the virtio-ccw bus. Signed-off-by: Thomas Huth Tested-by: Cleber Rosa --- tests/Makefile.include | 1 + tests/drive_del-test.c | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 0bb18b3..ff2a551 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -363,6 +363,7 @@ check-qtest-s390x-y =3D tests/boot-serial-test$(EXESUF) check-qtest-s390x-$(CONFIG_SLIRP) +=3D tests/test-netfilter$(EXESUF) check-qtest-s390x-$(CONFIG_POSIX) +=3D tests/test-filter-mirror$(EXESUF) check-qtest-s390x-$(CONFIG_POSIX) +=3D tests/test-filter-redirector$(EXESU= F) +check-qtest-s390x-y +=3D tests/drive_del-test$(EXESUF) =20 check-qtest-generic-y +=3D tests/qom-test$(EXESUF) check-qtest-generic-y +=3D tests/test-hmp$(EXESUF) diff --git a/tests/drive_del-test.c b/tests/drive_del-test.c index 2175139..efceb31 100644 --- a/tests/drive_del-test.c +++ b/tests/drive_del-test.c @@ -65,12 +65,12 @@ static void test_after_failed_device_add(void) =20 qtest_start("-drive if=3Dnone,id=3Ddrive0"); =20 - /* Make device_add fail. If this leaks the virtio-blk-pci device then= a + /* Make device_add fail. If this leaks the virtio-blk device then a * reference to drive0 will also be held (via qdev properties). */ response =3D qmp("{'execute': 'device_add'," " 'arguments': {" - " 'driver': 'virtio-blk-pci'," + " 'driver': 'virtio-blk'," " 'drive': 'drive0'" "}}"); g_assert(response); @@ -82,7 +82,7 @@ static void test_after_failed_device_add(void) drive_del(); =20 /* Try to re-add the drive. This fails with duplicate IDs if a leaked - * virtio-blk-pci exists that holds a reference to the old drive0. + * virtio-blk exists that holds a reference to the old drive0. */ drive_add(); =20 @@ -93,7 +93,7 @@ static void test_drive_del_device_del(void) { /* Start with a drive used by a device that unplugs instantaneously */ qtest_start("-drive if=3Dnone,id=3Ddrive0,file=3Dnull-co://,format=3Dr= aw" - " -device virtio-scsi-pci" + " -device virtio-scsi" " -device scsi-hd,drive=3Ddrive0,id=3Ddev0"); =20 /* @@ -114,9 +114,10 @@ int main(int argc, char **argv) =20 qtest_add_func("/drive_del/without-dev", test_drive_without_dev); =20 - /* TODO I guess any arch with PCI would do */ + /* TODO I guess any arch with a hot-pluggable virtio bus would do */ if (!strcmp(arch, "i386") || !strcmp(arch, "x86_64") || - !strcmp(arch, "ppc") || !strcmp(arch, "ppc64")) { + !strcmp(arch, "ppc") || !strcmp(arch, "ppc64") || + !strcmp(arch, "s390x")) { qtest_add_func("/drive_del/after_failed_device_add", test_after_failed_device_add); qtest_add_func("/blockdev/drive_del_device_del", --=20 1.8.3.1 From nobody Thu May 2 09:33:23 2024 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 1502951530779197.01874407528544; Wed, 16 Aug 2017 23:32:10 -0700 (PDT) Received: from localhost ([::1]:35161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diELh-00069k-04 for importer@patchew.org; Thu, 17 Aug 2017 02:32:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diEFf-0001ue-15 for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:25:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diEFd-00079K-Eo for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:25:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48867) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1diEFd-00078x-57 for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:25:53 -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 EFBC87975D; Thu, 17 Aug 2017 06:25:51 +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 017111754B; Thu, 17 Aug 2017 06:25:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EFBC87975D Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.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:11 +0200 Message-Id: <1502951113-4246-5-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.26]); Thu, 17 Aug 2017 06:25:52 +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 4/6] tests: Introduce generic device hot-plug/hot-unplug 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" A lot of tests provide code for adding and removing a device via the device_add and device_del QMP commands. Maintaining this code in so many places is cumbersome and error-prone (some of the code parts check the responses in an incorrect way, for example), so let's provide some proper generic qtest functions for adding and removing a device instead. Signed-off-by: Thomas Huth --- tests/libqos/pci.c | 19 ++------------- tests/libqos/usb.c | 30 +++++------------------ tests/libqtest.c | 60 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/libqtest.h | 19 +++++++++++++++ tests/usb-hcd-uhci-test.c | 26 ++------------------ tests/usb-hcd-xhci-test.c | 51 ++++----------------------------------- tests/virtio-scsi-test.c | 24 ++----------------- tests/virtio-serial-test.c | 25 +++---------------- 8 files changed, 98 insertions(+), 156 deletions(-) diff --git a/tests/libqos/pci.c b/tests/libqos/pci.c index 2dcdead..aada753 100644 --- a/tests/libqos/pci.c +++ b/tests/libqos/pci.c @@ -394,21 +394,6 @@ QPCIBar qpci_legacy_iomap(QPCIDevice *dev, uint16_t ad= dr) void qpci_plug_device_test(const char *driver, const char *id, uint8_t slot, const char *opts) { - QDict *response; - char *cmd; - - cmd =3D g_strdup_printf("{'execute': 'device_add'," - " 'arguments': {" - " 'driver': '%s'," - " 'addr': '%d'," - " %s%s" - " 'id': '%s'" - "}}", driver, slot, - opts ? opts : "", opts ? "," : "", - id); - response =3D qmp(cmd); - g_free(cmd); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); + qtest_hot_plug_device(driver, id, "'addr': '%d'%s%s", slot, + opts ? ", " : "", opts ? opts : ""); } diff --git a/tests/libqos/usb.c b/tests/libqos/usb.c index 0cdfaec..f8d0190 100644 --- a/tests/libqos/usb.c +++ b/tests/libqos/usb.c @@ -40,34 +40,16 @@ void uhci_port_test(struct qhc *hc, int port, uint16_t = expect) void usb_test_hotplug(const char *hcd_id, const int port, void (*port_check)(void)) { - QDict *response; - char *cmd; + char *id =3D g_strdup_printf("usbdev%d", port); =20 - cmd =3D g_strdup_printf("{'execute': 'device_add'," - " 'arguments': {" - " 'driver': 'usb-tablet'," - " 'port': '%d'," - " 'bus': '%s.0'," - " 'id': 'usbdev%d'" - "}}", port, hcd_id, port); - response =3D qmp(cmd); - g_free(cmd); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); + qtest_hot_plug_device("usb-tablet", id, "'port': '%d', 'bus': '%s.0'", + port, hcd_id); =20 if (port_check) { port_check(); } =20 - cmd =3D g_strdup_printf("{'execute': 'device_del'," - " 'arguments': {" - " 'id': 'usbdev%d'" - "}}", port); - response =3D qmp(cmd); - g_free(cmd); - g_assert(response); - g_assert(qdict_haskey(response, "event")); - g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); - QDECREF(response); + qtest_hot_unplug_device(id); + + g_free(id); } diff --git a/tests/libqtest.c b/tests/libqtest.c index b9a1f18..4339d97 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -987,3 +987,63 @@ void qtest_cb_for_every_machine(void (*cb)(const char = *machine)) qtest_end(); QDECREF(response); } + +/** + * Generic hot-plugging test via the device_add QMP command + */ +void qtest_hot_plug_device(const char *driver, const char *id, + const char *fmt, ...) +{ + QDict *response; + char *cmd, *opts =3D NULL; + va_list va; + + if (fmt) { + va_start(va, fmt); + opts =3D g_strdup_vprintf(fmt, va); + va_end(va); + } + + cmd =3D g_strdup_printf("{'execute': 'device_add'," + " 'arguments': { 'driver': '%s', 'id': '%s'%s%s = }}", + driver, id, opts ? ", " : "", opts ? opts : ""); + g_free(opts); + + response =3D qmp(cmd); + g_free(cmd); + g_assert(response); + while (qdict_haskey(response, "event")) { + /* We can get DEVICE_DELETED events in case something went wrong */ + g_assert_cmpstr(qdict_get_str(response, "event"), !=3D, "DEVICE_DE= LETED"); + QDECREF(response); + response =3D qmp(""); + g_assert(response); + } + g_assert(!qdict_haskey(response, "error")); + QDECREF(response); +} + +/** + * Generic hot-unplugging test via the device_del QMP command + */ +void qtest_hot_unplug_device(const char *id) +{ + QDict *response; + char *cmd; + + cmd =3D g_strdup_printf("{'execute': 'device_del'," + " 'arguments': { 'id': '%s' }}", id); + + response =3D qmp(cmd); + g_free(cmd); + g_assert(response); + while (qdict_haskey(response, "event")) { + /* We should get DEVICE_DELETED event first */ + g_assert_cmpstr(qdict_get_str(response, "event"), =3D=3D, "DEVICE_= DELETED"); + QDECREF(response); + response =3D qmp(""); + g_assert(response); + } + g_assert(!qdict_haskey(response, "error")); + QDECREF(response); +} diff --git a/tests/libqtest.h b/tests/libqtest.h index 3ae5709..9c1006f 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -927,4 +927,23 @@ QDict *qmp_fd(int fd, const char *fmt, ...); */ void qtest_cb_for_every_machine(void (*cb)(const char *machine)); =20 +/** + * qtest_hot_plug_device: + * @driver: Name of the device that should be added + * @id: Identification string + * @fmt: printf-like format string for further options to device_add + * + * Generic hot-plugging test via the device_add QMP command. + */ +void qtest_hot_plug_device(const char *driver, const char *id, + const char *fmt, ...) GCC_FMT_ATTR(3, 4); + +/** + * qtest_hot_unplug_device: + * @id: Identification string + * + * Generic hot-unplugging test via the device_del QMP command. + */ +void qtest_hot_unplug_device(const char *id); + #endif diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c index 5b500fe..7465bfd 100644 --- a/tests/usb-hcd-uhci-test.c +++ b/tests/usb-hcd-uhci-test.c @@ -48,31 +48,9 @@ static void test_uhci_hotplug(void) =20 static void test_usb_storage_hotplug(void) { - QDict *response; + qtest_hot_plug_device("usb-storage", "usbdev0", "'drive': 'drive0'"); =20 - response =3D qmp("{'execute': 'device_add'," - " 'arguments': {" - " 'driver': 'usb-storage'," - " 'drive': 'drive0'," - " 'id': 'usbdev0'" - "}}"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); - - response =3D qmp("{'execute': 'device_del'," - " 'arguments': {" - " 'id': 'usbdev0'" - "}}"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); - - response =3D qmp(""); - g_assert(response); - g_assert(qdict_haskey(response, "event")); - g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); - QDECREF(response); + qtest_hot_unplug_device("usbdev0"); } =20 int main(int argc, char **argv) diff --git a/tests/usb-hcd-xhci-test.c b/tests/usb-hcd-xhci-test.c index 031764d..d729395 100644 --- a/tests/usb-hcd-xhci-test.c +++ b/tests/usb-hcd-xhci-test.c @@ -23,59 +23,16 @@ static void test_xhci_hotplug(void) =20 static void test_usb_uas_hotplug(void) { - QDict *response; - - response =3D qmp("{'execute': 'device_add'," - " 'arguments': {" - " 'driver': 'usb-uas'," - " 'id': 'uas'" - "}}"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); - - response =3D qmp("{'execute': 'device_add'," - " 'arguments': {" - " 'driver': 'scsi-hd'," - " 'drive': 'drive0'," - " 'id': 'scsi-hd'" - "}}"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); + qtest_hot_plug_device("usb-uas", "uas", NULL); + qtest_hot_plug_device("scsi-hd", "scsihd", "'drive': 'drive0'"); =20 /* TODO: UAS HBA driver in libqos, to check that added disk is visible after BUS rescan */ =20 - response =3D qmp("{'execute': 'device_del'," - " 'arguments': {" - " 'id': 'scsi-hd'" - "}}"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); - - response =3D qmp(""); - g_assert(qdict_haskey(response, "event")); - g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); - QDECREF(response); - - - response =3D qmp("{'execute': 'device_del'," - " 'arguments': {" - " 'id': 'uas'" - "}}"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); - - response =3D qmp(""); - g_assert(response); - g_assert(qdict_haskey(response, "event")); - g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); - QDECREF(response); + qtest_hot_unplug_device("scsihd"); + qtest_hot_unplug_device("uas"); } =20 int main(int argc, char **argv) diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c index 87a3b6e..6e7ba6f 100644 --- a/tests/virtio-scsi-test.c +++ b/tests/virtio-scsi-test.c @@ -192,32 +192,12 @@ static void pci_nop(void) =20 static void hotplug(void) { - QDict *response; QOSState *qs; =20 qs =3D qvirtio_scsi_start( "-drive id=3Ddrv1,if=3Dnone,file=3Dnull-co://,format=3Draw"); - response =3D qmp("{\"execute\": \"device_add\"," - " \"arguments\": {" - " \"driver\": \"scsi-hd\"," - " \"id\": \"scsi-hd\"," - " \"drive\": \"drv1\"" - "}}"); - - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); - - response =3D qmp("{\"execute\": \"device_del\"," - " \"arguments\": {" - " \"id\": \"scsi-hd\"" - "}}"); - - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - g_assert(qdict_haskey(response, "event")); - g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); - QDECREF(response); + qtest_hot_plug_device("scsi-hd", "scsihd", "'drive': 'drv1'"); + qtest_hot_unplug_device("scsihd"); qvirtio_scsi_stop(qs); } =20 diff --git a/tests/virtio-serial-test.c b/tests/virtio-serial-test.c index b14d943..97f8f52 100644 --- a/tests/virtio-serial-test.c +++ b/tests/virtio-serial-test.c @@ -17,28 +17,9 @@ static void pci_nop(void) =20 static void hotplug(void) { - QDict *response; - - response =3D qmp("{\"execute\": \"device_add\"," - " \"arguments\": {" - " \"driver\": \"virtserialport\"," - " \"id\": \"hp-port\"" - "}}"); - - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); - - response =3D qmp("{\"execute\": \"device_del\"," - " \"arguments\": {" - " \"id\": \"hp-port\"" - "}}"); - - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - g_assert(qdict_haskey(response, "event")); - g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); - QDECREF(response); + qtest_hot_plug_device("virtserialport", "hp-port", NULL); + + qtest_hot_unplug_device("hp-port"); } =20 int main(int argc, char **argv) --=20 1.8.3.1 From nobody Thu May 2 09:33:23 2024 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 From nobody Thu May 2 09:33:23 2024 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 1502951272244695.2691990207888; Wed, 16 Aug 2017 23:27:52 -0700 (PDT) Received: from localhost ([::1]:35028 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diEHW-00039R-W4 for importer@patchew.org; Thu, 17 Aug 2017 02:27:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diEFx-000299-6s for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:26:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diEFu-0007F9-2J for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:26:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39690) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1diEFt-0007Ei-PG for qemu-devel@nongnu.org; Thu, 17 Aug 2017 02:26:09 -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 A27C66411B; Thu, 17 Aug 2017 06:26:08 +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 9FF2217514; Thu, 17 Aug 2017 06:25:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A27C66411B Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.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:13 +0200 Message-Id: <1502951113-4246-7-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.39]); Thu, 17 Aug 2017 06:26:08 +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 6/6] tests: Enable the simple virtio tests on s390x, too 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" Most of the simple virtio test can be used on virtio-ccw on s390x, too, by simply using the bus-independent alias names of the devices instead of the device names ending in "-pci". Hot-plugging can also be tested here - we just have to use the generic hot plug function instead of the PCI hot plug function in the qvirtio_plug_device_test() function. Signed-off-by: Thomas Huth --- tests/Makefile.include | 4 ++++ tests/libqos/virtio.c | 4 +++- tests/virtio-balloon-test.c | 6 +++--- tests/virtio-console-test.c | 12 ++++++------ tests/virtio-rng-test.c | 10 +++++----- tests/virtio-serial-test.c | 8 ++++---- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index e3acdff..ac24aa6 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -364,6 +364,10 @@ check-qtest-s390x-$(CONFIG_SLIRP) +=3D tests/test-netf= ilter$(EXESUF) check-qtest-s390x-$(CONFIG_POSIX) +=3D tests/test-filter-mirror$(EXESUF) check-qtest-s390x-$(CONFIG_POSIX) +=3D tests/test-filter-redirector$(EXESU= F) check-qtest-s390x-y +=3D tests/drive_del-test$(EXESUF) +check-qtest-s390x-y +=3D tests/virtio-balloon-test$(EXESUF) +check-qtest-s390x-y +=3D tests/virtio-console-test$(EXESUF) +check-qtest-s390x-y +=3D tests/virtio-rng-test$(EXESUF) +check-qtest-s390x-y +=3D tests/virtio-serial-test$(EXESUF) =20 check-qtest-generic-y +=3D tests/qom-test$(EXESUF) check-qtest-generic-y +=3D tests/test-hmp$(EXESUF) diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c index 87d2e65..5ff9ad6 100644 --- a/tests/libqos/virtio.c +++ b/tests/libqos/virtio.c @@ -349,6 +349,8 @@ void qvirtio_plug_device_test(const char *driver, const= char *id, 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 if (g_str_equal(arch, "s390x")) { + qtest_hot_plug_device(driver, id, opts ? "%s" : NULL, opts); } else { g_assert_not_reached(); } @@ -360,7 +362,7 @@ void qvirtio_unplug_device_test(const char *id, uint8_t= addr) =20 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")) { + } else if (g_str_equal(arch, "ppc64") || g_str_equal(arch, "s390x")) { qtest_hot_unplug_device(id); } else { g_assert_not_reached(); diff --git a/tests/virtio-balloon-test.c b/tests/virtio-balloon-test.c index 0d0046b..45c95dd 100644 --- a/tests/virtio-balloon-test.c +++ b/tests/virtio-balloon-test.c @@ -11,7 +11,7 @@ #include "libqtest.h" =20 /* Tests only initialization so far. TODO: Replace with functional tests */ -static void pci_nop(void) +static void balloon_nop(void) { } =20 @@ -20,9 +20,9 @@ int main(int argc, char **argv) int ret; =20 g_test_init(&argc, &argv, NULL); - qtest_add_func("/virtio/balloon/pci/nop", pci_nop); + qtest_add_func("/virtio/balloon/nop", balloon_nop); =20 - qtest_start("-device virtio-balloon-pci"); + qtest_start("-device virtio-balloon"); ret =3D g_test_run(); =20 qtest_end(); diff --git a/tests/virtio-console-test.c b/tests/virtio-console-test.c index 1c3de07..d15e182 100644 --- a/tests/virtio-console-test.c +++ b/tests/virtio-console-test.c @@ -11,16 +11,16 @@ #include "libqtest.h" =20 /* Tests only initialization so far. TODO: Replace with functional tests */ -static void console_pci_nop(void) +static void console_nop(void) { - qtest_start("-device virtio-serial-pci,id=3Dvser0 " + qtest_start("-device virtio-serial,id=3Dvser0 " "-device virtconsole,bus=3Dvser0.0"); qtest_end(); } =20 -static void serialport_pci_nop(void) +static void serialport_nop(void) { - qtest_start("-device virtio-serial-pci,id=3Dvser0 " + qtest_start("-device virtio-serial,id=3Dvser0 " "-device virtserialport,bus=3Dvser0.0"); qtest_end(); } @@ -28,8 +28,8 @@ static void serialport_pci_nop(void) int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); - qtest_add_func("/virtio/console/pci/nop", console_pci_nop); - qtest_add_func("/virtio/serialport/pci/nop", serialport_pci_nop); + qtest_add_func("/virtio/console/nop", console_nop); + qtest_add_func("/virtio/serialport/nop", serialport_nop); =20 return g_test_run(); } diff --git a/tests/virtio-rng-test.c b/tests/virtio-rng-test.c index 04c4279..b58352e 100644 --- a/tests/virtio-rng-test.c +++ b/tests/virtio-rng-test.c @@ -15,13 +15,13 @@ #define PCI_SLOT_HP 0x06 =20 /* Tests only initialization so far. TODO: Replace with functional tests */ -static void pci_nop(void) +static void rng_nop(void) { } =20 static void hotplug(void) { - qvirtio_plug_device_test("virtio-rng-pci", "rng1", PCI_SLOT_HP, NULL); + qvirtio_plug_device_test("virtio-rng", "rng1", PCI_SLOT_HP, NULL); =20 qvirtio_unplug_device_test("rng1", PCI_SLOT_HP); } @@ -31,10 +31,10 @@ int main(int argc, char **argv) int ret; =20 g_test_init(&argc, &argv, NULL); - qtest_add_func("/virtio/rng/pci/nop", pci_nop); - qtest_add_func("/virtio/rng/pci/hotplug", hotplug); + qtest_add_func("/virtio/rng/nop", rng_nop); + qtest_add_func("/virtio/rng/hotplug", hotplug); =20 - qtest_start("-device virtio-rng-pci"); + qtest_start("-device virtio-rng"); ret =3D g_test_run(); =20 qtest_end(); diff --git a/tests/virtio-serial-test.c b/tests/virtio-serial-test.c index 97f8f52..059f211 100644 --- a/tests/virtio-serial-test.c +++ b/tests/virtio-serial-test.c @@ -11,7 +11,7 @@ #include "libqtest.h" =20 /* Tests only initialization so far. TODO: Replace with functional tests */ -static void pci_nop(void) +static void virtioserial_nop(void) { } =20 @@ -27,10 +27,10 @@ int main(int argc, char **argv) int ret; =20 g_test_init(&argc, &argv, NULL); - qtest_add_func("/virtio/serial/pci/nop", pci_nop); - qtest_add_func("/virtio/serial/pci/hotplug", hotplug); + qtest_add_func("/virtio/serial/nop", virtioserial_nop); + qtest_add_func("/virtio/serial/hotplug", hotplug); =20 - qtest_start("-device virtio-serial-pci"); + qtest_start("-device virtio-serial"); ret =3D g_test_run(); =20 qtest_end(); --=20 1.8.3.1