From nobody Tue Nov 4 08:13:49 2025 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 1504190513493668.6103423420685; Thu, 31 Aug 2017 07:41:53 -0700 (PDT) Received: from localhost ([::1]:56131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnQfH-00053n-2l for importer@patchew.org; Thu, 31 Aug 2017 10:41:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnQdw-0004AC-09 for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:40:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnQdp-0005X6-Sr for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:40:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51906) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dnQdp-0005Wv-Jw for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:40:21 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7361161474; Thu, 31 Aug 2017 14:40:20 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-27.ams2.redhat.com [10.36.116.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE9457771A; Thu, 31 Aug 2017 14:40:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7361161474 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, 31 Aug 2017 16:40:08 +0200 Message-Id: <1504190408-11143-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 31 Aug 2017 14:40:20 +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 v2] 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: Halil Pasic , Stefan Hajnoczi , David Hildenbrand , Farhan Ali , Pierre Morel , Claudio Imbrenda , Michael S Tsirkin , Jason J Herne , Cleber Rosa , Dong Jia Shi 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" We can use the drive_del test on s390x, too, to check that adding and deleting also works fine with the virtio-ccw bus. But we have to make sure that we use the devices with the "-ccw" suffix instead of the "-pci" suffix for the virtio-ccw transport on s390x. Introduce a helper function called qvirtio_get_dev_type() that returns the correct string for the current architecture. Signed-off-by: Thomas Huth Reviewed-by: David Hildenbrand --- I'm just sending a patch for this test now to get some feedback whether I'm on the right track now. If this approach with qvirtio_get_dev_type() gets accepted, I'll continue converting the other virtio tests, too. tests/Makefile.include | 3 ++- tests/drive_del-test.c | 25 ++++++++++++++++--------- tests/libqos/virtio.c | 17 +++++++++++++++++ tests/libqos/virtio.h | 3 +++ 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index f08b741..391c7a7 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -364,6 +364,7 @@ check-qtest-s390x-$(CONFIG_SLIRP) +=3D tests/pxe-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) @@ -762,7 +763,7 @@ tests/display-vga-test$(EXESUF): tests/display-vga-test= .o tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o tests/qom-test$(EXESUF): tests/qom-test.o tests/test-hmp$(EXESUF): tests/test-hmp.o -tests/drive_del-test$(EXESUF): tests/drive_del-test.o $(libqos-pc-obj-y) +tests/drive_del-test$(EXESUF): tests/drive_del-test.o $(libqos-virtio-obj-= y) tests/qdev-monitor-test$(EXESUF): tests/qdev-monitor-test.o $(libqos-pc-ob= j-y) tests/nvme-test$(EXESUF): tests/nvme-test.o tests/pvpanic-test$(EXESUF): tests/pvpanic-test.o diff --git a/tests/drive_del-test.c b/tests/drive_del-test.c index 2175139..c9ac997 100644 --- a/tests/drive_del-test.c +++ b/tests/drive_del-test.c @@ -12,6 +12,7 @@ =20 #include "qemu/osdep.h" #include "libqtest.h" +#include "libqos/virtio.h" =20 static void drive_add(void) { @@ -65,14 +66,14 @@ 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-%s'," " 'drive': 'drive0'" - "}}"); + "}}", qvirtio_get_dev_type()); g_assert(response); error =3D qdict_get_qdict(response, "error"); g_assert_cmpstr(qdict_get_try_str(error, "class"), =3D=3D, "GenericErr= or"); @@ -82,7 +83,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 device exists that holds a reference to the old drive0. */ drive_add(); =20 @@ -91,10 +92,14 @@ static void test_after_failed_device_add(void) =20 static void test_drive_del_device_del(void) { + char *args; + /* 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 scsi-hd,drive=3Ddrive0,id=3Ddev0"); + args =3D g_strdup_printf("-drive if=3Dnone,id=3Ddrive0,file=3Dnull-co:= //,format=3Draw" + " -device virtio-scsi-%s" + " -device scsi-hd,drive=3Ddrive0,id=3Ddev0", + qvirtio_get_dev_type()); + qtest_start(args); =20 /* * Delete the drive, and then the device @@ -104,6 +109,7 @@ static void test_drive_del_device_del(void) device_del(); =20 qtest_end(); + g_free(args); } =20 int main(int argc, char **argv) @@ -114,9 +120,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", diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c index 9880a69..0879a62 100644 --- a/tests/libqos/virtio.c +++ b/tests/libqos/virtio.c @@ -339,3 +339,20 @@ void qvirtqueue_set_used_event(QVirtQueue *vq, uint16_= t idx) /* vq->avail->used_event */ writew(vq->avail + 4 + (2 * vq->size), idx); } + +/* + * qvirtio_get_dev_type: + * Returns: the preferred virtio bus/device type for the current architect= ure. + */ +const char *qvirtio_get_dev_type(void) +{ + const char *arch =3D qtest_get_arch(); + + if (g_str_equal(arch, "arm") || g_str_equal(arch, "aarch64")) { + return "device"; /* for virtio-mmio */ + } else if (g_str_equal(arch, "s390x")) { + return "ccw"; + } else { + return "pci"; + } +} diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h index 8fbcd18..0a04740 100644 --- a/tests/libqos/virtio.h +++ b/tests/libqos/virtio.h @@ -143,4 +143,7 @@ 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); + +const char *qvirtio_get_dev_type(void); + #endif --=20 1.8.3.1