{"id":808269,"url":"http://patchwork.ozlabs.org/api/1.2/patches/808269/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1504190408-11143-1-git-send-email-thuth@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.2/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1504190408-11143-1-git-send-email-thuth@redhat.com>","list_archive_url":null,"date":"2017-08-31T14:40:08","name":"[v2] tests: Enable the drive_del test also on s390x","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"2b70da458c65f144cf039a11a6eaad744817694d","submitter":{"id":66152,"url":"http://patchwork.ozlabs.org/api/1.2/people/66152/?format=json","name":"Thomas Huth","email":"thuth@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1504190408-11143-1-git-send-email-thuth@redhat.com/mbox/","series":[{"id":842,"url":"http://patchwork.ozlabs.org/api/1.2/series/842/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=842","date":"2017-08-31T14:40:08","name":"[v2] tests: Enable the drive_del test also on s390x","version":2,"mbox":"http://patchwork.ozlabs.org/series/842/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/808269/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/808269/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=thuth@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjlRr1f9pz9s7G\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 00:41:12 +1000 (AEST)","from localhost ([::1]:56129 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dnQec-0004IN-9I\n\tfor incoming@patchwork.ozlabs.org; Thu, 31 Aug 2017 10:41:10 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:48558)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <thuth@redhat.com>) id 1dnQdw-0004AC-09\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:40:32 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <thuth@redhat.com>) id 1dnQdp-0005X6-Sr\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:40:28 -0400","from mx1.redhat.com ([209.132.183.28]:51906)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <thuth@redhat.com>) id 1dnQdp-0005Wv-Jw\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:40:21 -0400","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 7361161474;\n\tThu, 31 Aug 2017 14:40:20 +0000 (UTC)","from thh440s.redhat.com (ovpn-116-27.ams2.redhat.com\n\t[10.36.116.27])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id BE9457771A;\n\tThu, 31 Aug 2017 14:40:09 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 7361161474","From":"Thomas Huth <thuth@redhat.com>","To":"qemu-devel@nongnu.org, Cornelia Huck <cohuck@redhat.com>,\n\tChristian Borntraeger <borntraeger@de.ibm.com>","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\n\t(mx1.redhat.com [10.5.110.39]);\n\tThu, 31 Aug 2017 14:40:20 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"[Qemu-devel] [PATCH v2] tests: Enable the drive_del test also on\n\ts390x","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Halil Pasic <pasic@linux.vnet.ibm.com>,\n\tStefan Hajnoczi <stefanha@redhat.com>,\n\tDavid Hildenbrand <david@redhat.com>,\n\tFarhan Ali <alifm@linux.vnet.ibm.com>,\n\tPierre Morel <pmorel@linux.vnet.ibm.com>,\n\tClaudio Imbrenda <imbrenda@linux.vnet.ibm.com>,\n\tMichael S Tsirkin <mst@redhat.com>,\n\tJason J Herne <jjherne@linux.vnet.ibm.com>,\n\tCleber Rosa <crosa@redhat.com>, \n\tDong Jia Shi <bjsdjshi@linux.vnet.ibm.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"We can use the drive_del test on s390x, too, to check that adding and\ndeleting also works fine with the virtio-ccw bus. But we have to make\nsure that we use the devices with the \"-ccw\" suffix instead of the\n\"-pci\" suffix for the virtio-ccw transport on s390x. Introduce a helper\nfunction called qvirtio_get_dev_type() that returns the correct string\nfor the current architecture.\n\nSigned-off-by: Thomas Huth <thuth@redhat.com>\n---\n I'm just sending a patch for this test now to get some feedback whether\n I'm on the right track now. If this approach with qvirtio_get_dev_type()\n gets accepted, I'll continue converting the other virtio tests, too.\n\n tests/Makefile.include |  3 ++-\n tests/drive_del-test.c | 25 ++++++++++++++++---------\n tests/libqos/virtio.c  | 17 +++++++++++++++++\n tests/libqos/virtio.h  |  3 +++\n 4 files changed, 38 insertions(+), 10 deletions(-)","diff":"diff --git a/tests/Makefile.include b/tests/Makefile.include\nindex f08b741..391c7a7 100644\n--- a/tests/Makefile.include\n+++ b/tests/Makefile.include\n@@ -364,6 +364,7 @@ check-qtest-s390x-$(CONFIG_SLIRP) += tests/pxe-test$(EXESUF)\n check-qtest-s390x-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)\n check-qtest-s390x-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)\n check-qtest-s390x-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF)\n+check-qtest-s390x-y += tests/drive_del-test$(EXESUF)\n \n check-qtest-generic-y += tests/qom-test$(EXESUF)\n check-qtest-generic-y += tests/test-hmp$(EXESUF)\n@@ -762,7 +763,7 @@ tests/display-vga-test$(EXESUF): tests/display-vga-test.o\n tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o\n tests/qom-test$(EXESUF): tests/qom-test.o\n tests/test-hmp$(EXESUF): tests/test-hmp.o\n-tests/drive_del-test$(EXESUF): tests/drive_del-test.o $(libqos-pc-obj-y)\n+tests/drive_del-test$(EXESUF): tests/drive_del-test.o $(libqos-virtio-obj-y)\n tests/qdev-monitor-test$(EXESUF): tests/qdev-monitor-test.o $(libqos-pc-obj-y)\n tests/nvme-test$(EXESUF): tests/nvme-test.o\n tests/pvpanic-test$(EXESUF): tests/pvpanic-test.o\ndiff --git a/tests/drive_del-test.c b/tests/drive_del-test.c\nindex 2175139..c9ac997 100644\n--- a/tests/drive_del-test.c\n+++ b/tests/drive_del-test.c\n@@ -12,6 +12,7 @@\n \n #include \"qemu/osdep.h\"\n #include \"libqtest.h\"\n+#include \"libqos/virtio.h\"\n \n static void drive_add(void)\n {\n@@ -65,14 +66,14 @@ static void test_after_failed_device_add(void)\n \n     qtest_start(\"-drive if=none,id=drive0\");\n \n-    /* Make device_add fail.  If this leaks the virtio-blk-pci device then a\n+    /* Make device_add fail. If this leaks the virtio-blk device then a\n      * reference to drive0 will also be held (via qdev properties).\n      */\n     response = qmp(\"{'execute': 'device_add',\"\n                    \" 'arguments': {\"\n-                   \"   'driver': 'virtio-blk-pci',\"\n+                   \"   'driver': 'virtio-blk-%s',\"\n                    \"   'drive': 'drive0'\"\n-                   \"}}\");\n+                   \"}}\", qvirtio_get_dev_type());\n     g_assert(response);\n     error = qdict_get_qdict(response, \"error\");\n     g_assert_cmpstr(qdict_get_try_str(error, \"class\"), ==, \"GenericError\");\n@@ -82,7 +83,7 @@ static void test_after_failed_device_add(void)\n     drive_del();\n \n     /* Try to re-add the drive.  This fails with duplicate IDs if a leaked\n-     * virtio-blk-pci exists that holds a reference to the old drive0.\n+     * virtio-blk device exists that holds a reference to the old drive0.\n      */\n     drive_add();\n \n@@ -91,10 +92,14 @@ static void test_after_failed_device_add(void)\n \n static void test_drive_del_device_del(void)\n {\n+    char *args;\n+\n     /* Start with a drive used by a device that unplugs instantaneously */\n-    qtest_start(\"-drive if=none,id=drive0,file=null-co://,format=raw\"\n-                \" -device virtio-scsi-pci\"\n-                \" -device scsi-hd,drive=drive0,id=dev0\");\n+    args = g_strdup_printf(\"-drive if=none,id=drive0,file=null-co://,format=raw\"\n+                           \" -device virtio-scsi-%s\"\n+                           \" -device scsi-hd,drive=drive0,id=dev0\",\n+                           qvirtio_get_dev_type());\n+    qtest_start(args);\n \n     /*\n      * Delete the drive, and then the device\n@@ -104,6 +109,7 @@ static void test_drive_del_device_del(void)\n     device_del();\n \n     qtest_end();\n+    g_free(args);\n }\n \n int main(int argc, char **argv)\n@@ -114,9 +120,10 @@ int main(int argc, char **argv)\n \n     qtest_add_func(\"/drive_del/without-dev\", test_drive_without_dev);\n \n-    /* TODO I guess any arch with PCI would do */\n+    /* TODO I guess any arch with a hot-pluggable virtio bus would do */\n     if (!strcmp(arch, \"i386\") || !strcmp(arch, \"x86_64\") ||\n-        !strcmp(arch, \"ppc\") || !strcmp(arch, \"ppc64\")) {\n+        !strcmp(arch, \"ppc\") || !strcmp(arch, \"ppc64\") ||\n+        !strcmp(arch, \"s390x\")) {\n         qtest_add_func(\"/drive_del/after_failed_device_add\",\n                        test_after_failed_device_add);\n         qtest_add_func(\"/blockdev/drive_del_device_del\",\ndiff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c\nindex 9880a69..0879a62 100644\n--- a/tests/libqos/virtio.c\n+++ b/tests/libqos/virtio.c\n@@ -339,3 +339,20 @@ void qvirtqueue_set_used_event(QVirtQueue *vq, uint16_t idx)\n     /* vq->avail->used_event */\n     writew(vq->avail + 4 + (2 * vq->size), idx);\n }\n+\n+/*\n+ * qvirtio_get_dev_type:\n+ * Returns: the preferred virtio bus/device type for the current architecture.\n+ */\n+const char *qvirtio_get_dev_type(void)\n+{\n+    const char *arch = qtest_get_arch();\n+\n+    if (g_str_equal(arch, \"arm\") || g_str_equal(arch, \"aarch64\")) {\n+        return \"device\";  /* for virtio-mmio */\n+    } else if (g_str_equal(arch, \"s390x\")) {\n+        return \"ccw\";\n+    } else {\n+        return \"pci\";\n+    }\n+}\ndiff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h\nindex 8fbcd18..0a04740 100644\n--- a/tests/libqos/virtio.h\n+++ b/tests/libqos/virtio.h\n@@ -143,4 +143,7 @@ void qvirtqueue_kick(QVirtioDevice *d, QVirtQueue *vq, uint32_t free_head);\n bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *desc_idx);\n \n void qvirtqueue_set_used_event(QVirtQueue *vq, uint16_t idx);\n+\n+const char *qvirtio_get_dev_type(void);\n+\n #endif\n","prefixes":["v2"]}