From nobody Sun Feb 8 15:51:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565892097; cv=none; d=zoho.com; s=zohoarc; b=W1hWSIw9A4iLbqQHlxAZGCjJYYMITpePApKtQtuqbExdAeqdYSDpMSrEchAgBQfwvFGMM+gHi6Ixz4to2Ign+KW3wNeG3LdkUmBayhmc0CQQIiT52TA1dgD6qqHr2fPxH0Wx+KyP8GkLrf3T6XJbKYMum5BnEYkWnP6+i13nqBM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565892097; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+6WWZoDK1MgWi+BIVixgKPUZ1vYbpbfjad9e7GK5ADI=; b=E4ppLD1EZjFRZySMEeauc1GSPGbI2zs/d8w3Ijb4dTku2C1JTGfhw5wBV4355kv194oC+tll7wrGvLHlZZdTP6qiq6e1P0bCDhzqhuWKnarS5exLh7+j00zynGCT4a0UqdySQi9QutC7ULeTHGvI5dgQsAiIvzCPFic/S8vZdXg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565892097147717.290769388147; Thu, 15 Aug 2019 11:01:37 -0700 (PDT) Received: from localhost ([::1]:45738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyK45-0001PP-C1 for importer@patchew.org; Thu, 15 Aug 2019 14:01:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60977) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyK2B-00087S-HQ for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hyK29-0001BP-B4 for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33788) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hyK29-00019J-5j for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:33 -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 74C0181DF7; Thu, 15 Aug 2019 17:59:32 +0000 (UTC) Received: from thuth.com (ovpn-116-65.ams2.redhat.com [10.36.116.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id A63F217CF8; Thu, 15 Aug 2019 17:59:30 +0000 (UTC) From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 15 Aug 2019 19:59:14 +0200 Message-Id: <20190815175922.3475-2-thuth@redhat.com> In-Reply-To: <20190815175922.3475-1-thuth@redhat.com> References: <20190815175922.3475-1-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.25]); Thu, 15 Aug 2019 17:59:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/9] qtest: Rename qtest.c:qtest_init() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Oleinik, Alexander" Both the qtest client, libqtest.c, and server, qtest.c, used the same name for initialization functions which can cause confusion. Signed-off-by: Alexander Oleinik Message-Id: <20190805031240.6024-1-alxndr@bu.edu> Reviewed-by: John Snow Reviewed-by: Stefan Hajnoczi Signed-off-by: Thomas Huth --- include/sysemu/qtest.h | 2 +- qtest.c | 3 +-- vl.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/sysemu/qtest.h b/include/sysemu/qtest.h index cd114b8d80..5ed09c80b1 100644 --- a/include/sysemu/qtest.h +++ b/include/sysemu/qtest.h @@ -24,6 +24,6 @@ static inline bool qtest_enabled(void) =20 bool qtest_driver(void); =20 -void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **e= rrp); +void qtest_server_init(const char *qtest_chrdev, const char *qtest_log, Er= ror **errp); =20 #endif diff --git a/qtest.c b/qtest.c index 15e27e911f..c9681dbdf3 100644 --- a/qtest.c +++ b/qtest.c @@ -748,8 +748,7 @@ static void qtest_event(void *opaque, int event) break; } } - -void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **e= rrp) +void qtest_server_init(const char *qtest_chrdev, const char *qtest_log, Er= ror **errp) { Chardev *chr; =20 diff --git a/vl.c b/vl.c index b426b32134..130a389712 100644 --- a/vl.c +++ b/vl.c @@ -4197,7 +4197,7 @@ int main(int argc, char **argv, char **envp) migration_object_init(); =20 if (qtest_chrdev) { - qtest_init(qtest_chrdev, qtest_log, &error_fatal); + qtest_server_init(qtest_chrdev, qtest_log, &error_fatal); } =20 machine_opts =3D qemu_get_machine_opts(); --=20 2.18.1 From nobody Sun Feb 8 15:51:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565892100; cv=none; d=zoho.com; s=zohoarc; b=dxKP3f6VJ3KsgfCHUGgzKvkhJwSQuFIm6OZmchFqKgDL0Gq8fCx2UZmQBaosfzs7ciVdmz2Qo12U9uHacqhow2R6mIqkjfXdaIFuXRg3DKDaf09gCueOWXJjrDcjlCOdXc8w6yY9CN53D7Iv2WOG6u0zdSqoShftNIpLD1p6aSI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565892100; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=VHXUp+c8cnOGIw+4qfuQnzNtWXN0iyLjZnjpxQEbxxQ=; b=JQ1J94HrSo+q9kh8UEqblSc+M1ybAWYW6Suc/YqYKkm0uvWR8G+IjmdJzSgIxFgyVK4TeKJTfrdbLTv+MO3Wq26rSMN62AUrUr5EbEasd45upd3KX84cMEKv/GRE3vm4y/z1niCmnZ5kPQS23nmBQRRV+spycS/P5tkZeJ0tcBU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565892100120423.9583668669445; Thu, 15 Aug 2019 11:01:40 -0700 (PDT) Received: from localhost ([::1]:45740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyK47-0001UP-En for importer@patchew.org; Thu, 15 Aug 2019 14:01:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60990) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyK2D-00087e-Pc for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hyK2B-0001Hr-LM for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52450) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hyK2B-0001G0-GT for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:35 -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 D1C742A09B2; Thu, 15 Aug 2019 17:59:34 +0000 (UTC) Received: from thuth.com (ovpn-116-65.ams2.redhat.com [10.36.116.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2105E17CF8; Thu, 15 Aug 2019 17:59:32 +0000 (UTC) From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 15 Aug 2019 19:59:15 +0200 Message-Id: <20190815175922.3475-3-thuth@redhat.com> In-Reply-To: <20190815175922.3475-1-thuth@redhat.com> References: <20190815175922.3475-1-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.38]); Thu, 15 Aug 2019 17:59:34 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/9] libqos: Account for the ctrl queue in virtio-net X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Oleinik, Alexander" The number of queues is 2n+1, where n =3D=3D 1 when multiqueue is disabled Signed-off-by: Alexander Oleinik Message-Id: <20190805032400.8054-1-alxndr@bu.edu> [thuth: fixed "intefaces" typo] Signed-off-by: Thomas Huth --- tests/libqos/virtio-net.c | 1 + tests/libqos/virtio-net.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/libqos/virtio-net.c b/tests/libqos/virtio-net.c index 66405b646e..6567beb553 100644 --- a/tests/libqos/virtio-net.c +++ b/tests/libqos/virtio-net.c @@ -53,6 +53,7 @@ static void virtio_net_setup(QVirtioNet *interface) } else { interface->n_queues =3D 2; } + interface->n_queues++; /* Account for the ctrl queue */ =20 interface->queues =3D g_new(QVirtQueue *, interface->n_queues); for (i =3D 0; i < interface->n_queues; i++) { diff --git a/tests/libqos/virtio-net.h b/tests/libqos/virtio-net.h index a5697d7326..855c67d00f 100644 --- a/tests/libqos/virtio-net.h +++ b/tests/libqos/virtio-net.h @@ -29,7 +29,7 @@ typedef struct QVirtioNetDevice QVirtioNetDevice; =20 struct QVirtioNet { QVirtioDevice *vdev; - int n_queues; + int n_queues; /* total number of virtqueues (rx, tx, ctrl) */ QVirtQueue **queues; }; =20 --=20 2.18.1 From nobody Sun Feb 8 15:51:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565892328; cv=none; d=zoho.com; s=zohoarc; b=EZHOVNa5bcqph8Da1pmJI10gbARQbpTxfAK46mK5J3hytHEIri3iF+Qtki1fXfgyXjyo5S3kJK0FpVQKLGd4ndJ+2c+JME04aWkpDvu9EMSCptJFUBp4FlD15vW1JZ8ORzwJstn1TKhYEliSTo/igRqXXE6IqxWEBJSrNlrKLak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565892328; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=6YC59k3DqeESb9zx0btHvfC3omErcO++inszM8z8ywU=; b=m+6yDrjyR6BJpLMhvPFGQpvDhMbNQgoyTBuBM1LH20Nj4Zs+zSAPapXlwZPvPLEiHv7kyF2h91RI+PlfbDkgL5hb1W0vla/IdAm1TMP9kGlPrltl1z0AmZBDOu48Lns7Dj/XIBeU3HaaJ3rYZTIRtmUf9eSkEDu0zjTPpOTzL+0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565892328532567.4703033083755; Thu, 15 Aug 2019 11:05:28 -0700 (PDT) Received: from localhost ([::1]:45760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyK7n-00048e-Sn for importer@patchew.org; Thu, 15 Aug 2019 14:05:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32770) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyK2G-0008C2-Tl for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hyK2D-0001OT-VO for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43426) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hyK2D-0001Mf-NA for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:37 -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 0E661300C72E; Thu, 15 Aug 2019 17:59:37 +0000 (UTC) Received: from thuth.com (ovpn-116-65.ams2.redhat.com [10.36.116.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4438083BF0; Thu, 15 Aug 2019 17:59:35 +0000 (UTC) From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 15 Aug 2019 19:59:16 +0200 Message-Id: <20190815175922.3475-4-thuth@redhat.com> In-Reply-To: <20190815175922.3475-1-thuth@redhat.com> References: <20190815175922.3475-1-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.45]); Thu, 15 Aug 2019 17:59:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/9] tests: Set read-zeroes on for null-co driver X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Andrey Shinkevich This patch is to reduce the number of Valgrind report messages about using uninitialized memory with the null-co driver. It helps to filter real memory issues and is the same work done for the iotests with the commit ID a6862418fec4072. Suggested-by: Kevin Wolf Signed-off-by: Andrey Shinkevich Message-Id: <1564404360-733987-1-git-send-email-andrey.shinkevich@virtuozzo= .com> Signed-off-by: Thomas Huth --- tests/drive_del-test.c | 3 ++- tests/libqos/virtio-scsi.c | 3 ++- tests/megasas-test.c | 3 ++- tests/nvme-test.c | 3 ++- tests/qmp-test.c | 2 +- tests/test-blockjob-txn.c | 5 ++++- tests/test-blockjob.c | 5 ++++- tests/usb-hcd-uhci-test.c | 3 ++- tests/usb-hcd-xhci-test.c | 3 ++- tests/virtio-blk-test.c | 6 ++++-- tests/virtio-ccw-test.c | 9 ++++++--- tests/virtio-scsi-test.c | 6 ++++-- 12 files changed, 35 insertions(+), 16 deletions(-) diff --git a/tests/drive_del-test.c b/tests/drive_del-test.c index b56b223fc2..5f8839b232 100644 --- a/tests/drive_del-test.c +++ b/tests/drive_del-test.c @@ -121,7 +121,8 @@ static void test_drive_del_device_del(void) QTestState *qts; =20 /* Start with a drive used by a device that unplugs instantaneously */ - qts =3D qtest_initf("-drive if=3Dnone,id=3Ddrive0,file=3Dnull-co://,fo= rmat=3Draw" + qts =3D qtest_initf("-drive if=3Dnone,id=3Ddrive0,file=3Dnull-co://," + "file.read-zeroes=3Don,format=3Draw" " -device virtio-scsi-%s" " -device scsi-hd,drive=3Ddrive0,id=3Ddev0", qvirtio_get_dev_type()); diff --git a/tests/libqos/virtio-scsi.c b/tests/libqos/virtio-scsi.c index 94842ec3fa..de739bec5f 100644 --- a/tests/libqos/virtio-scsi.c +++ b/tests/libqos/virtio-scsi.c @@ -95,7 +95,8 @@ static void virtio_scsi_register_nodes(void) }; =20 QOSGraphEdgeOptions opts =3D { - .before_cmd_line =3D "-drive id=3Ddrv0,if=3Dnone,file=3Dnull-co://= ,format=3Draw", + .before_cmd_line =3D "-drive id=3Ddrv0,if=3Dnone,file=3Dnull-co://= ," + "file.read-zeroes=3Don,format=3Draw", .after_cmd_line =3D "-device scsi-hd,bus=3Dvs0.0,drive=3Ddrv0", }; =20 diff --git a/tests/megasas-test.c b/tests/megasas-test.c index c3e4ab6595..d6796b9bd7 100644 --- a/tests/megasas-test.c +++ b/tests/megasas-test.c @@ -75,7 +75,8 @@ static void megasas_register_nodes(void) { QOSGraphEdgeOptions opts =3D { .extra_device_opts =3D "addr=3D04.0,id=3Dscsi0", - .before_cmd_line =3D "-drive id=3Ddrv0,if=3Dnone,file=3Dnull-co://= ,format=3Draw", + .before_cmd_line =3D "-drive id=3Ddrv0,if=3Dnone,file=3Dnull-co://= ," + "file.read-zeroes=3Don,format=3Draw", .after_cmd_line =3D "-device scsi-hd,bus=3Dscsi0.0,drive=3Ddrv0", }; =20 diff --git a/tests/nvme-test.c b/tests/nvme-test.c index 505299324b..ff0442150c 100644 --- a/tests/nvme-test.c +++ b/tests/nvme-test.c @@ -70,7 +70,8 @@ static void nvme_register_nodes(void) { QOSGraphEdgeOptions opts =3D { .extra_device_opts =3D "addr=3D04.0,drive=3Ddrv0,serial=3Dfoo", - .before_cmd_line =3D "-drive id=3Ddrv0,if=3Dnone,file=3Dnull-co://= ,format=3Draw", + .before_cmd_line =3D "-drive id=3Ddrv0,if=3Dnone,file=3Dnull-co://= ," + "file.read-zeroes=3Don,format=3Draw", }; =20 add_qpci_address(&opts, &(QPCIAddress) { .devfn =3D QPCI_DEVFN(4, 0) }= ); diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 48a4fa791a..1b0eb69832 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -187,7 +187,7 @@ static void send_cmd_that_blocks(QTestState *s, const c= har *id) " 'arguments': {" " 'driver': 'blkdebug', 'node-name': %s," " 'config': %s," - " 'image': { 'driver': 'null-co' } } }", + " 'image': { 'driver': 'null-co', 'read-zeroes': true }= } }", id, id, fifo_name); } =20 diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c index 86606f92b3..7da9216d5b 100644 --- a/tests/test-blockjob-txn.c +++ b/tests/test-blockjob-txn.c @@ -15,6 +15,7 @@ #include "qemu/main-loop.h" #include "block/blockjob_int.h" #include "sysemu/block-backend.h" +#include "qapi/qmp/qdict.h" =20 typedef struct { BlockJob common; @@ -96,7 +97,9 @@ static BlockJob *test_block_job_start(unsigned int iterat= ions, =20 data =3D g_new0(TestBlockJobCBData, 1); =20 - bs =3D bdrv_open("null-co://", NULL, NULL, 0, &error_abort); + QDict *opt =3D qdict_new(); + qdict_put_str(opt, "file.read-zeroes", "on"); + bs =3D bdrv_open("null-co://", NULL, opt, 0, &error_abort); g_assert_nonnull(bs); =20 snprintf(job_id, sizeof(job_id), "job%u", counter++); diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c index b33f899873..68a0819495 100644 --- a/tests/test-blockjob.c +++ b/tests/test-blockjob.c @@ -15,6 +15,7 @@ #include "qemu/main-loop.h" #include "block/blockjob_int.h" #include "sysemu/block-backend.h" +#include "qapi/qmp/qdict.h" =20 static const BlockJobDriver test_block_job_driver =3D { .job_driver =3D { @@ -71,7 +72,9 @@ static BlockBackend *create_blk(const char *name) BlockBackend *blk =3D blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL); BlockDriverState *bs; =20 - bs =3D bdrv_open("null-co://", NULL, NULL, 0, &error_abort); + QDict *opt =3D qdict_new(); + qdict_put_str(opt, "file.read-zeroes", "on"); + bs =3D bdrv_open("null-co://", NULL, opt, 0, &error_abort); g_assert_nonnull(bs); =20 blk_insert_bs(blk, bs, &error_abort); diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c index a119d6d5c8..6d355c29da 100644 --- a/tests/usb-hcd-uhci-test.c +++ b/tests/usb-hcd-uhci-test.c @@ -57,7 +57,8 @@ int main(int argc, char **argv) { const char *arch =3D qtest_get_arch(); const char *cmd =3D "-device piix3-usb-uhci,id=3Duhci,addr=3D1d.0" - " -drive id=3Ddrive0,if=3Dnone,file=3Dnull-co://,for= mat=3Draw" + " -drive id=3Ddrive0,if=3Dnone,file=3Dnull-co://," + "file.read-zeroes=3Don,format=3Draw" " -device usb-tablet,bus=3Duhci.0,port=3D1"; int ret; =20 diff --git a/tests/usb-hcd-xhci-test.c b/tests/usb-hcd-xhci-test.c index 9eb24b00e4..b15a51123f 100644 --- a/tests/usb-hcd-xhci-test.c +++ b/tests/usb-hcd-xhci-test.c @@ -56,7 +56,8 @@ int main(int argc, char **argv) qtest_add_func("/xhci/pci/hotplug/usb-ccid", test_usb_ccid_hotplug); =20 qtest_start("-device nec-usb-xhci,id=3Dxhci" - " -drive id=3Ddrive0,if=3Dnone,file=3Dnull-co://,format=3D= raw"); + " -drive id=3Ddrive0,if=3Dnone,file=3Dnull-co://," + "file.read-zeroes=3Don,format=3Draw"); ret =3D g_test_run(); qtest_end(); =20 diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index 1b02714bc7..1589ab0866 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -753,8 +753,10 @@ static void *virtio_blk_test_setup(GString *cmd_line, = void *arg) char *tmp_path =3D drive_create(); =20 g_string_append_printf(cmd_line, - " -drive if=3Dnone,id=3Ddrive0,file=3D%s,format= =3Draw,auto-read-only=3Doff " - "-drive if=3Dnone,id=3Ddrive1,file=3Dnull-co://= ,format=3Draw ", + " -drive if=3Dnone,id=3Ddrive0,file=3D%s," + "format=3Draw,auto-read-only=3Doff " + "-drive if=3Dnone,id=3Ddrive1,file=3Dnull-co://= ," + "file.read-zeroes=3Don,format=3Draw ", tmp_path); =20 return arg; diff --git a/tests/virtio-ccw-test.c b/tests/virtio-ccw-test.c index 48c714d84c..6be4e6aaf6 100644 --- a/tests/virtio-ccw-test.c +++ b/tests/virtio-ccw-test.c @@ -53,7 +53,8 @@ static void virtio_serial_hotplug(void) =20 static void virtio_blk_nop(void) { - global_qtest =3D qtest_initf("-drive if=3Dnone,id=3Ddrv0,file=3Dnull-c= o://,format=3Draw " + global_qtest =3D qtest_initf("-drive if=3Dnone,id=3Ddrv0,file=3Dnull-c= o://," + "file.read-zeroes=3Don,format=3Draw " "-device virtio-blk-ccw,drive=3Ddrv0"); qtest_end(); } @@ -78,8 +79,10 @@ static void virtio_scsi_nop(void) =20 static void virtio_scsi_hotplug(void) { - global_qtest =3D qtest_initf("-drive if=3Dnone,id=3Ddrv0,file=3Dnull-c= o://,format=3Draw " - "-drive if=3Dnone,id=3Ddrv1,file=3Dnull-co= ://,format=3Draw " + global_qtest =3D qtest_initf("-drive if=3Dnone,id=3Ddrv0,file=3Dnull-c= o://," + "file.read-zeroes=3Don,format=3Draw " + "-drive if=3Dnone,id=3Ddrv1,file=3Dnull-co= ://," + "file.read-zeroes=3Don,format=3Draw " "-device virtio-scsi-ccw " "-device scsi-hd,drive=3Ddrv0"); qtest_qmp_device_add("scsi-hd", "scsihd", "{'drive': 'drv1'}"); diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c index 1ad9f75d74..ae6698ddb4 100644 --- a/tests/virtio-scsi-test.c +++ b/tests/virtio-scsi-test.c @@ -239,7 +239,8 @@ fail: static void *virtio_scsi_hotplug_setup(GString *cmd_line, void *arg) { g_string_append(cmd_line, - " -drive id=3Ddrv1,if=3Dnone,file=3Dnull-co://,format= =3Draw"); + " -drive id=3Ddrv1,if=3Dnone,file=3Dnull-co://," + "file.read-zeroes=3Don,format=3Draw"); return arg; } =20 @@ -247,6 +248,7 @@ static void *virtio_scsi_setup(GString *cmd_line, void = *arg) { g_string_append(cmd_line, " -drive file=3Dblkdebug::null-co://," + "file.image.read-zeroes=3Don," "if=3Dnone,id=3Ddr1,format=3Draw,file.align=3D4k " "-device scsi-hd,drive=3Ddr1,lun=3D0,scsi-id=3D1"); return arg; @@ -256,7 +258,7 @@ static void *virtio_scsi_setup_iothread(GString *cmd_li= ne, void *arg) { g_string_append(cmd_line, " -object iothread,id=3Dthread0" - " -blockdev driver=3Dnull-co,node-name=3Dnull0" + " -blockdev driver=3Dnull-co,read-zeroes=3Don,node-nam= e=3Dnull0" " -device scsi-hd,drive=3Dnull0"); return arg; } --=20 2.18.1 From nobody Sun Feb 8 15:51:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565892339; cv=none; d=zoho.com; s=zohoarc; b=IJuqMYV1ds2ldE6jl+gU65WUpHqOOA0P+68eydCKZWbPeMNJNMIm6+XXVNsEQqPpoqLnrnA2XyHVYPwjls41pJIE08NRxtBxxo5igZZ0dLAxg+Sy8fMkva3JRzHLutgzjjFLoS4sbZO3STG1yFdDnC72YK82u7CLpAGqMvaU59c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565892339; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+kRHWAg/6fcKzBUA+2CAk3MFunv85DVacLEta/YVFCk=; b=OrVdlWJfyV7hsYd5+yx4yHWo9aIVuRfLB5wAxSZLfV+yS06gyDqIU/M/8a+Hi0iZJEOVWUvGJ1SOnrsLZX+ltf0F5W1sv9V+RyxxKUE9FcSAg6RncYBDoS0NR+00rzO0bRHCro6XmkcmDynNXyn0FCzEl36RbIc7qv+fUY7jJ5k= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565892339142238.0120983487409; Thu, 15 Aug 2019 11:05:39 -0700 (PDT) Received: from localhost ([::1]:45764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyK81-0004Dl-LG for importer@patchew.org; Thu, 15 Aug 2019 14:05:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32791) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyK2L-0008N5-SA for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hyK2G-0001VU-QG for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52276) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hyK2G-0001Tt-G2 for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:40 -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 CA3633007F3A; Thu, 15 Aug 2019 17:59:39 +0000 (UTC) Received: from thuth.com (ovpn-116-65.ams2.redhat.com [10.36.116.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C56C17ADA; Thu, 15 Aug 2019 17:59:37 +0000 (UTC) From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 15 Aug 2019 19:59:17 +0200 Message-Id: <20190815175922.3475-5-thuth@redhat.com> In-Reply-To: <20190815175922.3475-1-thuth@redhat.com> References: <20190815175922.3475-1-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.48]); Thu, 15 Aug 2019 17:59:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/9] tests/libqos: Make generic virtio code independent from global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The libqos library functions should never depend on global_qtest, since these functions might be used in tests that track multiple test states. Pass around a pointer to the QTestState instead. Message-Id: <20190814195920.32023-1-thuth@redhat.com> Signed-off-by: Thomas Huth --- tests/libqos/virtio.c | 81 +++++++++++---------- tests/libqos/virtio.h | 30 ++++---- tests/virtio-9p-test.c | 16 +++-- tests/virtio-blk-test.c | 151 ++++++++++++++++++++------------------- tests/virtio-net-test.c | 33 +++++---- tests/virtio-scsi-test.c | 13 ++-- 6 files changed, 176 insertions(+), 148 deletions(-) diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c index b4c01dc0c1..91ce06954b 100644 --- a/tests/libqos/virtio.c +++ b/tests/libqos/virtio.c @@ -101,7 +101,7 @@ void qvirtio_wait_queue_isr(QVirtioDevice *d, * The virtqueue interrupt must not be raised, making this useful for test= ing * event_index functionality. */ -uint8_t qvirtio_wait_status_byte_no_isr(QVirtioDevice *d, +uint8_t qvirtio_wait_status_byte_no_isr(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq, uint64_t addr, gint64 timeout_us) @@ -126,7 +126,7 @@ uint8_t qvirtio_wait_status_byte_no_isr(QVirtioDevice *= d, * * This function waits for the next completed request on the used ring. */ -void qvirtio_wait_used_elem(QVirtioDevice *d, +void qvirtio_wait_used_elem(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq, uint32_t desc_idx, uint32_t *len, @@ -140,7 +140,7 @@ void qvirtio_wait_used_elem(QVirtioDevice *d, clock_step(100); =20 if (d->bus->get_queue_isr_status(d, vq) && - qvirtqueue_get_buf(vq, &got_desc_idx, len)) { + qvirtqueue_get_buf(qts, vq, &got_desc_idx, len)) { g_assert_cmpint(got_desc_idx, =3D=3D, desc_idx); return; } @@ -193,8 +193,9 @@ void qvring_init(QTestState *qts, const QGuestAllocator= *alloc, QVirtQueue *vq, 0); } =20 -QVRingIndirectDesc *qvring_indirect_desc_setup(QVirtioDevice *d, - QGuestAllocator *alloc, uint16_t e= lem) +QVRingIndirectDesc *qvring_indirect_desc_setup(QTestState *qs, QVirtioDevi= ce *d, + QGuestAllocator *alloc, + uint16_t elem) { int i; QVRingIndirectDesc *indirect =3D g_malloc(sizeof(*indirect)); @@ -205,41 +206,41 @@ QVRingIndirectDesc *qvring_indirect_desc_setup(QVirti= oDevice *d, =20 for (i =3D 0; i < elem - 1; ++i) { /* indirect->desc[i].addr */ - writeq(indirect->desc + (16 * i), 0); + qtest_writeq(qs, indirect->desc + (16 * i), 0); /* indirect->desc[i].flags */ - writew(indirect->desc + (16 * i) + 12, VRING_DESC_F_NEXT); + qtest_writew(qs, indirect->desc + (16 * i) + 12, VRING_DESC_F_NEXT= ); /* indirect->desc[i].next */ - writew(indirect->desc + (16 * i) + 14, i + 1); + qtest_writew(qs, indirect->desc + (16 * i) + 14, i + 1); } =20 return indirect; } =20 -void qvring_indirect_desc_add(QVRingIndirectDesc *indirect, uint64_t data, - uint32_t len, bool wri= te) +void qvring_indirect_desc_add(QTestState *qts, QVRingIndirectDesc *indirec= t, + uint64_t data, uint32_t len, bool write) { uint16_t flags; =20 g_assert_cmpint(indirect->index, <, indirect->elem); =20 - flags =3D readw(indirect->desc + (16 * indirect->index) + 12); + flags =3D qtest_readw(qts, indirect->desc + (16 * indirect->index) + 1= 2); =20 if (write) { flags |=3D VRING_DESC_F_WRITE; } =20 /* indirect->desc[indirect->index].addr */ - writeq(indirect->desc + (16 * indirect->index), data); + qtest_writeq(qts, indirect->desc + (16 * indirect->index), data); /* indirect->desc[indirect->index].len */ - writel(indirect->desc + (16 * indirect->index) + 8, len); + qtest_writel(qts, indirect->desc + (16 * indirect->index) + 8, len); /* indirect->desc[indirect->index].flags */ - writew(indirect->desc + (16 * indirect->index) + 12, flags); + qtest_writew(qts, indirect->desc + (16 * indirect->index) + 12, flags); =20 indirect->index++; } =20 -uint32_t qvirtqueue_add(QVirtQueue *vq, uint64_t data, uint32_t len, bool = write, - bool n= ext) +uint32_t qvirtqueue_add(QTestState *qts, QVirtQueue *vq, uint64_t data, + uint32_t len, bool write, bool next) { uint16_t flags =3D 0; vq->num_free--; @@ -253,16 +254,17 @@ uint32_t qvirtqueue_add(QVirtQueue *vq, uint64_t data= , uint32_t len, bool write, } =20 /* vq->desc[vq->free_head].addr */ - writeq(vq->desc + (16 * vq->free_head), data); + qtest_writeq(qts, vq->desc + (16 * vq->free_head), data); /* vq->desc[vq->free_head].len */ - writel(vq->desc + (16 * vq->free_head) + 8, len); + qtest_writel(qts, vq->desc + (16 * vq->free_head) + 8, len); /* vq->desc[vq->free_head].flags */ - writew(vq->desc + (16 * vq->free_head) + 12, flags); + qtest_writew(qts, vq->desc + (16 * vq->free_head) + 12, flags); =20 return vq->free_head++; /* Return and increase, in this order */ } =20 -uint32_t qvirtqueue_add_indirect(QVirtQueue *vq, QVRingIndirectDesc *indir= ect) +uint32_t qvirtqueue_add_indirect(QTestState *qts, QVirtQueue *vq, + QVRingIndirectDesc *indirect) { g_assert(vq->indirect); g_assert_cmpint(vq->size, >=3D, indirect->elem); @@ -271,34 +273,36 @@ uint32_t qvirtqueue_add_indirect(QVirtQueue *vq, QVRi= ngIndirectDesc *indirect) vq->num_free--; =20 /* vq->desc[vq->free_head].addr */ - writeq(vq->desc + (16 * vq->free_head), indirect->desc); + qtest_writeq(qts, vq->desc + (16 * vq->free_head), indirect->desc); /* vq->desc[vq->free_head].len */ - writel(vq->desc + (16 * vq->free_head) + 8, + qtest_writel(qts, vq->desc + (16 * vq->free_head) + 8, sizeof(struct vring_desc) * indirect->elem); /* vq->desc[vq->free_head].flags */ - writew(vq->desc + (16 * vq->free_head) + 12, VRING_DESC_F_INDIRECT); + qtest_writew(qts, vq->desc + (16 * vq->free_head) + 12, + VRING_DESC_F_INDIRECT); =20 return vq->free_head++; /* Return and increase, in this order */ } =20 -void qvirtqueue_kick(QVirtioDevice *d, QVirtQueue *vq, uint32_t free_head) +void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq, + uint32_t free_head) { /* vq->avail->idx */ - uint16_t idx =3D readw(vq->avail + 2); + uint16_t idx =3D qtest_readw(qts, vq->avail + 2); /* vq->used->flags */ uint16_t flags; /* vq->used->avail_event */ uint16_t avail_event; =20 /* vq->avail->ring[idx % vq->size] */ - writew(vq->avail + 4 + (2 * (idx % vq->size)), free_head); + qtest_writew(qts, vq->avail + 4 + (2 * (idx % vq->size)), free_head); /* vq->avail->idx */ - writew(vq->avail + 2, idx + 1); + qtest_writew(qts, vq->avail + 2, idx + 1); =20 /* Must read after idx is updated */ - flags =3D readw(vq->avail); - avail_event =3D readw(vq->used + 4 + - sizeof(struct vring_used_elem) * vq->size); + flags =3D qtest_readw(qts, vq->avail); + avail_event =3D qtest_readw(qts, vq->used + 4 + + sizeof(struct vring_used_elem) * vq->si= ze); =20 /* < 1 because we add elements to avail queue one by one */ if ((flags & VRING_USED_F_NO_NOTIFY) =3D=3D 0 && @@ -317,12 +321,13 @@ void qvirtqueue_kick(QVirtioDevice *d, QVirtQueue *vq= , uint32_t free_head) * * Returns: true if an element was ready, false otherwise */ -bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *desc_idx, uint32_t *len) +bool qvirtqueue_get_buf(QTestState *qts, QVirtQueue *vq, uint32_t *desc_id= x, + uint32_t *len) { uint16_t idx; - uint64_t elem_addr; + uint64_t elem_addr, addr; =20 - idx =3D readw(vq->used + offsetof(struct vring_used, idx)); + idx =3D qtest_readw(qts, vq->used + offsetof(struct vring_used, idx)); if (idx =3D=3D vq->last_used_idx) { return false; } @@ -333,23 +338,25 @@ bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *des= c_idx, uint32_t *len) sizeof(struct vring_used_elem); =20 if (desc_idx) { - *desc_idx =3D readl(elem_addr + offsetof(struct vring_used_elem, i= d)); + addr =3D elem_addr + offsetof(struct vring_used_elem, id); + *desc_idx =3D qtest_readl(qts, addr); } =20 if (len) { - *len =3D readw(elem_addr + offsetof(struct vring_used_elem, len)); + addr =3D elem_addr + offsetof(struct vring_used_elem, len); + *len =3D qtest_readw(qts, addr); } =20 vq->last_used_idx++; return true; } =20 -void qvirtqueue_set_used_event(QVirtQueue *vq, uint16_t idx) +void qvirtqueue_set_used_event(QTestState *qts, QVirtQueue *vq, uint16_t i= dx) { g_assert(vq->event); =20 /* vq->avail->used_event */ - writew(vq->avail + 4 + (2 * vq->size), idx); + qtest_writew(qts, vq->avail + 4 + (2 * vq->size), idx); } =20 void qvirtio_start_device(QVirtioDevice *vdev) diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h index 7b97f5e567..037176dbd8 100644 --- a/tests/libqos/virtio.h +++ b/tests/libqos/virtio.h @@ -114,11 +114,11 @@ void qvirtio_set_driver_ok(QVirtioDevice *d); =20 void qvirtio_wait_queue_isr(QVirtioDevice *d, QVirtQueue *vq, gint64 timeout_us); -uint8_t qvirtio_wait_status_byte_no_isr(QVirtioDevice *d, +uint8_t qvirtio_wait_status_byte_no_isr(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq, uint64_t addr, gint64 timeout_us); -void qvirtio_wait_used_elem(QVirtioDevice *d, +void qvirtio_wait_used_elem(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq, uint32_t desc_idx, uint32_t *len, @@ -131,17 +131,21 @@ void qvirtqueue_cleanup(const QVirtioBus *bus, QVirtQ= ueue *vq, =20 void qvring_init(QTestState *qts, const QGuestAllocator *alloc, QVirtQueue= *vq, uint64_t addr); -QVRingIndirectDesc *qvring_indirect_desc_setup(QVirtioDevice *d, - QGuestAllocator *alloc, uint16_t e= lem); -void qvring_indirect_desc_add(QVRingIndirectDesc *indirect, uint64_t data, - uint32_t len, bool wri= te); -uint32_t qvirtqueue_add(QVirtQueue *vq, uint64_t data, uint32_t len, bool = write, - bool n= ext); -uint32_t qvirtqueue_add_indirect(QVirtQueue *vq, QVRingIndirectDesc *indir= ect); -void qvirtqueue_kick(QVirtioDevice *d, QVirtQueue *vq, uint32_t free_head); -bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *desc_idx, uint32_t *len); - -void qvirtqueue_set_used_event(QVirtQueue *vq, uint16_t idx); +QVRingIndirectDesc *qvring_indirect_desc_setup(QTestState *qs, QVirtioDevi= ce *d, + QGuestAllocator *alloc, + uint16_t elem); +void qvring_indirect_desc_add(QTestState *qts, QVRingIndirectDesc *indirec= t, + uint64_t data, uint32_t len, bool write); +uint32_t qvirtqueue_add(QTestState *qts, QVirtQueue *vq, uint64_t data, + uint32_t len, bool write, bool next); +uint32_t qvirtqueue_add_indirect(QTestState *qts, QVirtQueue *vq, + QVRingIndirectDesc *indirect); +void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq, + uint32_t free_head); +bool qvirtqueue_get_buf(QTestState *qts, QVirtQueue *vq, uint32_t *desc_id= x, + uint32_t *len); + +void qvirtqueue_set_used_event(QTestState *qts, QVirtQueue *vq, uint16_t i= dx); =20 void qvirtio_start_device(QVirtioDevice *vdev); =20 diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c index ac49bca991..30e6cf3e63 100644 --- a/tests/virtio-9p-test.c +++ b/tests/virtio-9p-test.c @@ -39,6 +39,7 @@ static void pci_config(void *obj, void *data, QGuestAlloc= ator *t_alloc) #define P9_MAX_SIZE 4096 /* Max size of a T-message or R-message */ =20 typedef struct { + QTestState *qts; QVirtio9P *v9p; uint16_t tag; uint64_t t_msg; @@ -52,7 +53,7 @@ typedef struct { =20 static void v9fs_memwrite(P9Req *req, const void *addr, size_t len) { - memwrite(req->t_msg + req->t_off, addr, len); + qtest_memwrite(req->qts, req->t_msg + req->t_off, addr, len); req->t_off +=3D len; } =20 @@ -63,7 +64,7 @@ static void v9fs_memskip(P9Req *req, size_t len) =20 static void v9fs_memread(P9Req *req, void *addr, size_t len) { - memread(req->r_msg + req->r_off, addr, len); + qtest_memread(req->qts, req->r_msg + req->r_off, addr, len); req->r_off +=3D len; } =20 @@ -158,6 +159,7 @@ static P9Req *v9fs_req_init(QVirtio9P *v9p, uint32_t si= ze, uint8_t id, =20 g_assert_cmpint(total_size, <=3D, P9_MAX_SIZE); =20 + req->qts =3D global_qtest; req->v9p =3D v9p; req->t_size =3D total_size; req->t_msg =3D guest_alloc(alloc, req->t_size); @@ -171,10 +173,10 @@ static void v9fs_req_send(P9Req *req) QVirtio9P *v9p =3D req->v9p; =20 req->r_msg =3D guest_alloc(alloc, P9_MAX_SIZE); - req->free_head =3D qvirtqueue_add(v9p->vq, req->t_msg, req->t_size, fa= lse, - true); - qvirtqueue_add(v9p->vq, req->r_msg, P9_MAX_SIZE, true, false); - qvirtqueue_kick(v9p->vdev, v9p->vq, req->free_head); + req->free_head =3D qvirtqueue_add(req->qts, v9p->vq, req->t_msg, req->= t_size, + false, true); + qvirtqueue_add(req->qts, v9p->vq, req->r_msg, P9_MAX_SIZE, true, false= ); + qvirtqueue_kick(req->qts, v9p->vdev, v9p->vq, req->free_head); req->t_off =3D 0; } =20 @@ -195,7 +197,7 @@ static void v9fs_req_wait_for_reply(P9Req *req, uint32_= t *len) { QVirtio9P *v9p =3D req->v9p; =20 - qvirtio_wait_used_elem(v9p->vdev, v9p->vq, req->free_head, len, + qvirtio_wait_used_elem(req->qts, v9p->vdev, v9p->vq, req->free_head, l= en, QVIRTIO_9P_TIMEOUT_US); } =20 diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index 1589ab0866..882b08ae29 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -123,6 +123,7 @@ static void test_basic(QVirtioDevice *dev, QGuestAlloca= tor *alloc, uint32_t free_head; uint8_t status; char *data; + QTestState *qts =3D global_qtest; =20 capacity =3D qvirtio_config_readq(dev, 0); =20 @@ -149,13 +150,14 @@ static void test_basic(QVirtioDevice *dev, QGuestAllo= cator *alloc, =20 g_free(req.data); =20 - free_head =3D qvirtqueue_add(vq, req_addr, 16, false, true); - qvirtqueue_add(vq, req_addr + 16, 512, false, true); - qvirtqueue_add(vq, req_addr + 528, 1, true, false); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); =20 - qvirtqueue_kick(dev, vq, free_head); + qvirtqueue_kick(qts, dev, vq, free_head); =20 - qvirtio_wait_used_elem(dev, vq, free_head, NULL, QVIRTIO_BLK_TIMEOUT_U= S); + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); status =3D readb(req_addr + 528); g_assert_cmpint(status, =3D=3D, 0); =20 @@ -171,13 +173,14 @@ static void test_basic(QVirtioDevice *dev, QGuestAllo= cator *alloc, =20 g_free(req.data); =20 - free_head =3D qvirtqueue_add(vq, req_addr, 16, false, true); - qvirtqueue_add(vq, req_addr + 16, 512, true, true); - qvirtqueue_add(vq, req_addr + 528, 1, true, false); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, true, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); =20 - qvirtqueue_kick(dev, vq, free_head); + qvirtqueue_kick(qts, dev, vq, free_head); =20 - qvirtio_wait_used_elem(dev, vq, free_head, NULL, QVIRTIO_BLK_TIMEOUT_U= S); + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); status =3D readb(req_addr + 528); g_assert_cmpint(status, =3D=3D, 0); =20 @@ -206,13 +209,14 @@ static void test_basic(QVirtioDevice *dev, QGuestAllo= cator *alloc, =20 req_addr =3D virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr)); =20 - free_head =3D qvirtqueue_add(vq, req_addr, 16, false, true); - qvirtqueue_add(vq, req_addr + 16, sizeof(dwz_hdr), false, true); - qvirtqueue_add(vq, req_addr + 16 + sizeof(dwz_hdr), 1, true, false= ); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, sizeof(dwz_hdr), false, tru= e); + qvirtqueue_add(qts, vq, req_addr + 16 + sizeof(dwz_hdr), 1, true, + false); =20 - qvirtqueue_kick(dev, vq, free_head); + qvirtqueue_kick(qts, dev, vq, free_head); =20 - qvirtio_wait_used_elem(dev, vq, free_head, NULL, + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, QVIRTIO_BLK_TIMEOUT_US); status =3D readb(req_addr + 16 + sizeof(dwz_hdr)); g_assert_cmpint(status, =3D=3D, 0); @@ -229,13 +233,13 @@ static void test_basic(QVirtioDevice *dev, QGuestAllo= cator *alloc, =20 g_free(req.data); =20 - free_head =3D qvirtqueue_add(vq, req_addr, 16, false, true); - qvirtqueue_add(vq, req_addr + 16, 512, true, true); - qvirtqueue_add(vq, req_addr + 528, 1, true, false); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, true, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); =20 - qvirtqueue_kick(dev, vq, free_head); + qvirtqueue_kick(qts, dev, vq, free_head); =20 - qvirtio_wait_used_elem(dev, vq, free_head, NULL, + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, QVIRTIO_BLK_TIMEOUT_US); status =3D readb(req_addr + 528); g_assert_cmpint(status, =3D=3D, 0); @@ -263,13 +267,13 @@ static void test_basic(QVirtioDevice *dev, QGuestAllo= cator *alloc, =20 req_addr =3D virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr)); =20 - free_head =3D qvirtqueue_add(vq, req_addr, 16, false, true); - qvirtqueue_add(vq, req_addr + 16, sizeof(dwz_hdr), false, true); - qvirtqueue_add(vq, req_addr + 16 + sizeof(dwz_hdr), 1, true, false= ); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, sizeof(dwz_hdr), false, tru= e); + qvirtqueue_add(qts, vq, req_addr + 16 + sizeof(dwz_hdr), 1, true, = false); =20 - qvirtqueue_kick(dev, vq, free_head); + qvirtqueue_kick(qts, dev, vq, free_head); =20 - qvirtio_wait_used_elem(dev, vq, free_head, NULL, + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, QVIRTIO_BLK_TIMEOUT_US); status =3D readb(req_addr + 16 + sizeof(dwz_hdr)); g_assert_cmpint(status, =3D=3D, 0); @@ -290,11 +294,11 @@ static void test_basic(QVirtioDevice *dev, QGuestAllo= cator *alloc, =20 g_free(req.data); =20 - free_head =3D qvirtqueue_add(vq, req_addr, 528, false, true); - qvirtqueue_add(vq, req_addr + 528, 1, true, false); - qvirtqueue_kick(dev, vq, free_head); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 528, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + qvirtqueue_kick(qts, dev, vq, free_head); =20 - qvirtio_wait_used_elem(dev, vq, free_head, NULL, + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, QVIRTIO_BLK_TIMEOUT_US); status =3D readb(req_addr + 528); g_assert_cmpint(status, =3D=3D, 0); @@ -311,12 +315,12 @@ static void test_basic(QVirtioDevice *dev, QGuestAllo= cator *alloc, =20 g_free(req.data); =20 - free_head =3D qvirtqueue_add(vq, req_addr, 16, false, true); - qvirtqueue_add(vq, req_addr + 16, 513, true, false); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 513, true, false); =20 - qvirtqueue_kick(dev, vq, free_head); + qvirtqueue_kick(qts, dev, vq, free_head); =20 - qvirtio_wait_used_elem(dev, vq, free_head, NULL, + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, QVIRTIO_BLK_TIMEOUT_US); status =3D readb(req_addr + 528); g_assert_cmpint(status, =3D=3D, 0); @@ -353,6 +357,7 @@ static void indirect(void *obj, void *u_data, QGuestAll= ocator *t_alloc) uint32_t free_head; uint8_t status; char *data; + QTestState *qts =3D global_qtest; =20 capacity =3D qvirtio_config_readq(dev, 0); g_assert_cmpint(capacity, =3D=3D, TEST_IMAGE_SIZE / 512); @@ -378,13 +383,13 @@ static void indirect(void *obj, void *u_data, QGuestA= llocator *t_alloc) =20 g_free(req.data); =20 - indirect =3D qvring_indirect_desc_setup(dev, t_alloc, 2); - qvring_indirect_desc_add(indirect, req_addr, 528, false); - qvring_indirect_desc_add(indirect, req_addr + 528, 1, true); - free_head =3D qvirtqueue_add_indirect(vq, indirect); - qvirtqueue_kick(dev, vq, free_head); + indirect =3D qvring_indirect_desc_setup(qts, dev, t_alloc, 2); + qvring_indirect_desc_add(qts, indirect, req_addr, 528, false); + qvring_indirect_desc_add(qts, indirect, req_addr + 528, 1, true); + free_head =3D qvirtqueue_add_indirect(qts, vq, indirect); + qvirtqueue_kick(qts, dev, vq, free_head); =20 - qvirtio_wait_used_elem(dev, vq, free_head, NULL, + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, QVIRTIO_BLK_TIMEOUT_US); status =3D readb(req_addr + 528); g_assert_cmpint(status, =3D=3D, 0); @@ -403,13 +408,13 @@ static void indirect(void *obj, void *u_data, QGuestA= llocator *t_alloc) =20 g_free(req.data); =20 - indirect =3D qvring_indirect_desc_setup(dev, t_alloc, 2); - qvring_indirect_desc_add(indirect, req_addr, 16, false); - qvring_indirect_desc_add(indirect, req_addr + 16, 513, true); - free_head =3D qvirtqueue_add_indirect(vq, indirect); - qvirtqueue_kick(dev, vq, free_head); + indirect =3D qvring_indirect_desc_setup(qts, dev, t_alloc, 2); + qvring_indirect_desc_add(qts, indirect, req_addr, 16, false); + qvring_indirect_desc_add(qts, indirect, req_addr + 16, 513, true); + free_head =3D qvirtqueue_add_indirect(qts, vq, indirect); + qvirtqueue_kick(qts, dev, vq, free_head); =20 - qvirtio_wait_used_elem(dev, vq, free_head, NULL, + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, QVIRTIO_BLK_TIMEOUT_US); status =3D readb(req_addr + 528); g_assert_cmpint(status, =3D=3D, 0); @@ -461,6 +466,7 @@ static void msix(void *obj, void *u_data, QGuestAllocat= or *t_alloc) char *data; QOSGraphObject *blk_object =3D obj; QPCIDevice *pci_dev =3D blk_object->get_driver(blk_object, "pci-device= "); + QTestState *qts =3D global_qtest; =20 if (qpci_check_buggy_msi(pci_dev)) { return; @@ -504,12 +510,12 @@ static void msix(void *obj, void *u_data, QGuestAlloc= ator *t_alloc) =20 g_free(req.data); =20 - free_head =3D qvirtqueue_add(vq, req_addr, 16, false, true); - qvirtqueue_add(vq, req_addr + 16, 512, false, true); - qvirtqueue_add(vq, req_addr + 528, 1, true, false); - qvirtqueue_kick(dev, vq, free_head); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + qvirtqueue_kick(qts, dev, vq, free_head); =20 - qvirtio_wait_used_elem(dev, vq, free_head, NULL, + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, QVIRTIO_BLK_TIMEOUT_US); =20 status =3D readb(req_addr + 528); @@ -527,14 +533,14 @@ static void msix(void *obj, void *u_data, QGuestAlloc= ator *t_alloc) =20 g_free(req.data); =20 - free_head =3D qvirtqueue_add(vq, req_addr, 16, false, true); - qvirtqueue_add(vq, req_addr + 16, 512, true, true); - qvirtqueue_add(vq, req_addr + 528, 1, true, false); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, true, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); =20 - qvirtqueue_kick(dev, vq, free_head); + qvirtqueue_kick(qts, dev, vq, free_head); =20 =20 - qvirtio_wait_used_elem(dev, vq, free_head, NULL, + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, QVIRTIO_BLK_TIMEOUT_US); =20 status =3D readb(req_addr + 528); @@ -569,6 +575,7 @@ static void idx(void *obj, void *u_data, QGuestAllocato= r *t_alloc) char *data; QOSGraphObject *blk_object =3D obj; QPCIDevice *pci_dev =3D blk_object->get_driver(blk_object, "pci-device= "); + QTestState *qts =3D global_qtest; =20 if (qpci_check_buggy_msi(pci_dev)) { return; @@ -603,12 +610,12 @@ static void idx(void *obj, void *u_data, QGuestAlloca= tor *t_alloc) =20 g_free(req.data); =20 - free_head =3D qvirtqueue_add(vq, req_addr, 16, false, true); - qvirtqueue_add(vq, req_addr + 16, 512, false, true); - qvirtqueue_add(vq, req_addr + 528, 1, true, false); - qvirtqueue_kick(dev, vq, free_head); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + qvirtqueue_kick(qts, dev, vq, free_head); =20 - qvirtio_wait_used_elem(dev, vq, free_head, NULL, + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, QVIRTIO_BLK_TIMEOUT_US); =20 /* Write request */ @@ -623,15 +630,15 @@ static void idx(void *obj, void *u_data, QGuestAlloca= tor *t_alloc) g_free(req.data); =20 /* Notify after processing the third request */ - qvirtqueue_set_used_event(vq, 2); - free_head =3D qvirtqueue_add(vq, req_addr, 16, false, true); - qvirtqueue_add(vq, req_addr + 16, 512, false, true); - qvirtqueue_add(vq, req_addr + 528, 1, true, false); - qvirtqueue_kick(dev, vq, free_head); + qvirtqueue_set_used_event(qts, vq, 2); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + qvirtqueue_kick(qts, dev, vq, free_head); write_head =3D free_head; =20 /* No notification expected */ - status =3D qvirtio_wait_status_byte_no_isr(dev, + status =3D qvirtio_wait_status_byte_no_isr(qts, dev, vq, req_addr + 528, QVIRTIO_BLK_TIMEOUT_US); g_assert_cmpint(status, =3D=3D, 0); @@ -648,16 +655,16 @@ static void idx(void *obj, void *u_data, QGuestAlloca= tor *t_alloc) =20 g_free(req.data); =20 - free_head =3D qvirtqueue_add(vq, req_addr, 16, false, true); - qvirtqueue_add(vq, req_addr + 16, 512, true, true); - qvirtqueue_add(vq, req_addr + 528, 1, true, false); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, true, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); =20 - qvirtqueue_kick(dev, vq, free_head); + qvirtqueue_kick(qts, dev, vq, free_head); =20 /* We get just one notification for both requests */ - qvirtio_wait_used_elem(dev, vq, write_head, NULL, + qvirtio_wait_used_elem(qts, dev, vq, write_head, NULL, QVIRTIO_BLK_TIMEOUT_US); - g_assert(qvirtqueue_get_buf(vq, &desc_idx, NULL)); + g_assert(qvirtqueue_get_buf(qts, vq, &desc_idx, NULL)); g_assert_cmpint(desc_idx, =3D=3D, free_head); =20 status =3D readb(req_addr + 528); diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index 7aa9622f30..1071dd82c9 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -33,6 +33,7 @@ static void rx_test(QVirtioDevice *dev, QGuestAllocator *alloc, QVirtQueue *vq, int socket) { + QTestState *qts =3D global_qtest; uint64_t req_addr; uint32_t free_head; char test[] =3D "TEST"; @@ -51,13 +52,14 @@ static void rx_test(QVirtioDevice *dev, =20 req_addr =3D guest_alloc(alloc, 64); =20 - free_head =3D qvirtqueue_add(vq, req_addr, 64, true, false); - qvirtqueue_kick(dev, vq, free_head); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 64, true, false); + qvirtqueue_kick(qts, dev, vq, free_head); =20 ret =3D iov_send(socket, iov, 2, 0, sizeof(len) + sizeof(test)); g_assert_cmpint(ret, =3D=3D, sizeof(test) + sizeof(len)); =20 - qvirtio_wait_used_elem(dev, vq, free_head, NULL, QVIRTIO_NET_TIMEOUT_U= S); + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_NET_TIMEOUT_US); memread(req_addr + VNET_HDR_SIZE, buffer, sizeof(test)); g_assert_cmpstr(buffer, =3D=3D, "TEST"); =20 @@ -68,6 +70,7 @@ static void tx_test(QVirtioDevice *dev, QGuestAllocator *alloc, QVirtQueue *vq, int socket) { + QTestState *qts =3D global_qtest; uint64_t req_addr; uint32_t free_head; uint32_t len; @@ -77,10 +80,11 @@ static void tx_test(QVirtioDevice *dev, req_addr =3D guest_alloc(alloc, 64); memwrite(req_addr + VNET_HDR_SIZE, "TEST", 4); =20 - free_head =3D qvirtqueue_add(vq, req_addr, 64, false, false); - qvirtqueue_kick(dev, vq, free_head); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 64, false, false); + qvirtqueue_kick(qts, dev, vq, free_head); =20 - qvirtio_wait_used_elem(dev, vq, free_head, NULL, QVIRTIO_NET_TIMEOUT_U= S); + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_NET_TIMEOUT_US); guest_free(alloc, req_addr); =20 ret =3D qemu_recv(socket, &len, sizeof(len), 0); @@ -95,6 +99,7 @@ static void rx_stop_cont_test(QVirtioDevice *dev, QGuestAllocator *alloc, QVirtQueue *vq, int socket) { + QTestState *qts =3D global_qtest; uint64_t req_addr; uint32_t free_head; char test[] =3D "TEST"; @@ -114,8 +119,8 @@ static void rx_stop_cont_test(QVirtioDevice *dev, =20 req_addr =3D guest_alloc(alloc, 64); =20 - free_head =3D qvirtqueue_add(vq, req_addr, 64, true, false); - qvirtqueue_kick(dev, vq, free_head); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 64, true, false); + qvirtqueue_kick(qts, dev, vq, free_head); =20 rsp =3D qmp("{ 'execute' : 'stop'}"); qobject_unref(rsp); @@ -131,7 +136,8 @@ static void rx_stop_cont_test(QVirtioDevice *dev, rsp =3D qmp("{ 'execute' : 'cont'}"); qobject_unref(rsp); =20 - qvirtio_wait_used_elem(dev, vq, free_head, NULL, QVIRTIO_NET_TIMEOUT_U= S); + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_NET_TIMEOUT_US); memread(req_addr + VNET_HDR_SIZE, buffer, sizeof(test)); g_assert_cmpstr(buffer, =3D=3D, "TEST"); =20 @@ -283,19 +289,20 @@ static void large_tx(void *obj, void *data, QGuestAll= ocator *t_alloc) uint64_t req_addr; uint32_t free_head; size_t alloc_size =3D (size_t)data / 64; + QTestState *qts =3D global_qtest; int i; =20 /* Bypass the limitation by pointing several descriptors to a single * smaller area */ req_addr =3D guest_alloc(t_alloc, alloc_size); - free_head =3D qvirtqueue_add(vq, req_addr, alloc_size, false, true); + free_head =3D qvirtqueue_add(qts, vq, req_addr, alloc_size, false, tru= e); =20 for (i =3D 0; i < 64; i++) { - qvirtqueue_add(vq, req_addr, alloc_size, false, i !=3D 63); + qvirtqueue_add(qts, vq, req_addr, alloc_size, false, i !=3D 63); } - qvirtqueue_kick(dev->vdev, vq, free_head); + qvirtqueue_kick(qts, dev->vdev, vq, free_head); =20 - qvirtio_wait_used_elem(dev->vdev, vq, free_head, NULL, + qvirtio_wait_used_elem(qts, dev->vdev, vq, free_head, NULL, QVIRTIO_NET_TIMEOUT_US); guest_free(t_alloc, req_addr); } diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c index ae6698ddb4..6393272149 100644 --- a/tests/virtio-scsi-test.c +++ b/tests/virtio-scsi-test.c @@ -72,6 +72,7 @@ static uint8_t virtio_scsi_do_command(QVirtioSCSIQueues *= vs, uint64_t req_addr, resp_addr, data_in_addr =3D 0, data_out_addr =3D 0; uint8_t response; uint32_t free_head; + QTestState *qts =3D global_qtest; =20 vq =3D vs->vq[2]; =20 @@ -83,24 +84,24 @@ static uint8_t virtio_scsi_do_command(QVirtioSCSIQueues= *vs, =20 /* Add request header */ req_addr =3D qvirtio_scsi_alloc(vs, sizeof(req), &req); - free_head =3D qvirtqueue_add(vq, req_addr, sizeof(req), false, true); + free_head =3D qvirtqueue_add(qts, vq, req_addr, sizeof(req), false, tr= ue); =20 if (data_out_len) { data_out_addr =3D qvirtio_scsi_alloc(vs, data_out_len, data_out); - qvirtqueue_add(vq, data_out_addr, data_out_len, false, true); + qvirtqueue_add(qts, vq, data_out_addr, data_out_len, false, true); } =20 /* Add response header */ resp_addr =3D qvirtio_scsi_alloc(vs, sizeof(resp), &resp); - qvirtqueue_add(vq, resp_addr, sizeof(resp), true, !!data_in_len); + qvirtqueue_add(qts, vq, resp_addr, sizeof(resp), true, !!data_in_len); =20 if (data_in_len) { data_in_addr =3D qvirtio_scsi_alloc(vs, data_in_len, data_in); - qvirtqueue_add(vq, data_in_addr, data_in_len, true, false); + qvirtqueue_add(qts, vq, data_in_addr, data_in_len, true, false); } =20 - qvirtqueue_kick(vs->dev, vq, free_head); - qvirtio_wait_used_elem(vs->dev, vq, free_head, NULL, + qvirtqueue_kick(qts, vs->dev, vq, free_head); + qvirtio_wait_used_elem(qts, vs->dev, vq, free_head, NULL, QVIRTIO_SCSI_TIMEOUT_US); =20 response =3D readb(resp_addr + --=20 2.18.1 From nobody Sun Feb 8 15:51:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565892502; cv=none; d=zoho.com; s=zohoarc; b=CeHi0Wx2uYfyADzjKDCh57ychdOhKK1Xz5oOwGA6Vqbb738921UHP5SlYg/EvRTmulT+a/VRO60pfV+ore1/Hgv+AzkeQp2rUcl1iaXS0PTEydfDbuk4wwkGYEnIkwFrHQmiKOiBUyiIFeMAVFg+XHT2hFGD+vnyGCcxfzNXkUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565892502; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=nu42cgFZZm/SyvrosTB25pyDBXUQLstb/CXR0mTVMzg=; b=ZtATvjzxQ0C1exyJsPexcWgPywxBCeIv4WS7cI/unr/qDWapW8Ww6mQPl6t8XHRms1UlYSBO/8iA6eRuOU+GvQamyDYZy6+07GSEPqKUyd9yyyQofBIv0mPG9atRSpkiAjshvB4A+j5az6hF6lHkGHOztF05IqccuBc9ZqgWSoc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565892502546291.1288158527111; Thu, 15 Aug 2019 11:08:22 -0700 (PDT) Received: from localhost ([::1]:45798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyKAa-0006dv-AB for importer@patchew.org; Thu, 15 Aug 2019 14:08:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32785) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyK2L-0008LQ-2D for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hyK2I-0001bV-R5 for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39900) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hyK2I-0001Zc-Ld for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:42 -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 EEAA6308302F; Thu, 15 Aug 2019 17:59:41 +0000 (UTC) Received: from thuth.com (ovpn-116-65.ams2.redhat.com [10.36.116.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 534A81EA; Thu, 15 Aug 2019 17:59:40 +0000 (UTC) From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 15 Aug 2019 19:59:18 +0200 Message-Id: <20190815175922.3475-6-thuth@redhat.com> In-Reply-To: <20190815175922.3475-1-thuth@redhat.com> References: <20190815175922.3475-1-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.46]); Thu, 15 Aug 2019 17:59:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/9] tests/libqos: Make virtio-pci code independent from global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The libqos library functions should never depend on global_qtest, since these functions might be used in tests that track multiple test states. So let's use the test state of the QPCIDevice instead. Reviewed-by: Stefan Hajnoczi Reviewed-by: Eric Blake Message-Id: <20190813093047.27948-3-thuth@redhat.com> Signed-off-by: Thomas Huth --- tests/libqos/virtio-pci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c index a622ca26ca..3f55c047a0 100644 --- a/tests/libqos/virtio-pci.c +++ b/tests/libqos/virtio-pci.c @@ -138,9 +138,9 @@ static bool qvirtio_pci_get_queue_isr_status(QVirtioDev= ice *d, QVirtQueue *vq) /* No ISR checking should be done if masked, but read anyway */ return qpci_msix_pending(dev->pdev, vqpci->msix_entry); } else { - data =3D readl(vqpci->msix_addr); + data =3D qtest_readl(dev->pdev->bus->qts, vqpci->msix_addr); if (data =3D=3D vqpci->msix_data) { - writel(vqpci->msix_addr, 0); + qtest_writel(dev->pdev->bus->qts, vqpci->msix_addr, 0); return true; } else { return false; @@ -162,9 +162,9 @@ static bool qvirtio_pci_get_config_isr_status(QVirtioDe= vice *d) /* No ISR checking should be done if masked, but read anyway */ return qpci_msix_pending(dev->pdev, dev->config_msix_entry); } else { - data =3D readl(dev->config_msix_addr); + data =3D qtest_readl(dev->pdev->bus->qts, dev->config_msix_add= r); if (data =3D=3D dev->config_msix_data) { - writel(dev->config_msix_addr, 0); + qtest_writel(dev->pdev->bus->qts, dev->config_msix_addr, 0= ); return true; } else { return false; --=20 2.18.1 From nobody Sun Feb 8 15:51:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565892610; cv=none; d=zoho.com; s=zohoarc; b=m9pAw/aba9jbnBDSFYkzv9xaWfs6OzTGbfEYmaNa0xyL56AX95Y6fx4/tpviYFcm9D3jUZq6kL9tUFEvE84rhN/d0cQjWtqXlyf3zETZc2yr6hhyVVUOOU+k43iQ8sJL2YrJbKniog1+ve7jgbDy06FlDbXrVJPAifdLAgeCXEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565892610; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=sCD9s4TM79/Y7kQS8anxYCB1TDUCdIeSvSOtixD/F8Q=; b=RzKXeqKxS9N3RlRGa1QjywYUwDNOlo3QIRrqjNnJHJdmFUdyNtklpB/7BrYFr88zNQup9N/R7gAc95wiHyFbUQ08BIS9LkhaU9zQRZg2aWFCjwplB8gQxoKQjxRq84s/TSBgcKejw9Ijg2euwR+2HrE6qW0DkxRa87UwvC4/FBI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565892610221835.4427465290174; Thu, 15 Aug 2019 11:10:10 -0700 (PDT) Received: from localhost ([::1]:45820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyKCP-00008j-02 for importer@patchew.org; Thu, 15 Aug 2019 14:10:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32799) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyK2N-0008Qn-FY for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hyK2L-0001jV-7G for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51792) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hyK2L-0001h8-20 for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:45 -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 67BAD83F3C; Thu, 15 Aug 2019 17:59:44 +0000 (UTC) Received: from thuth.com (ovpn-116-65.ams2.redhat.com [10.36.116.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8854C17ADA; Thu, 15 Aug 2019 17:59:42 +0000 (UTC) From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 15 Aug 2019 19:59:19 +0200 Message-Id: <20190815175922.3475-7-thuth@redhat.com> In-Reply-To: <20190815175922.3475-1-thuth@redhat.com> References: <20190815175922.3475-1-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.27]); Thu, 15 Aug 2019 17:59:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 6/9] tests/libqtest: Remove unused function hmp() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" No test is using hmp() anymore, and since this function uses the disliked global_qtest variable, we should also make sure that nobody adds new code with this function again. qtest_hmp() should be used instead. Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20190813093047.27948-4-thuth@redhat.com> Signed-off-by: Thomas Huth --- tests/libqtest.c | 11 ----------- tests/libqtest.h | 10 ---------- 2 files changed, 21 deletions(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 3c5c3f49d8..3e9245d4c9 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -1130,17 +1130,6 @@ void qmp_assert_success(const char *fmt, ...) qobject_unref(response); } =20 -char *hmp(const char *fmt, ...) -{ - va_list ap; - char *ret; - - va_start(ap, fmt); - ret =3D qtest_vhmp(global_qtest, fmt, ap); - va_end(ap); - return ret; -} - bool qtest_big_endian(QTestState *s) { return s->big_endian; diff --git a/tests/libqtest.h b/tests/libqtest.h index cadf1d4a03..0009b65791 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -687,16 +687,6 @@ static inline void qmp_eventwait(const char *event) return qtest_qmp_eventwait(global_qtest, event); } =20 -/** - * hmp: - * @fmt...: HMP command to send to QEMU, formats arguments like sprintf(). - * - * Send HMP command to QEMU via QMP's human-monitor-command. - * - * Returns: the command's output. The caller should g_free() it. - */ -char *hmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); - /** * get_irq: * @num: Interrupt to observe. --=20 2.18.1 From nobody Sun Feb 8 15:51:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565892333; cv=none; d=zoho.com; s=zohoarc; b=RpOE92gfVlYiObTpR32kQTORLkrIIbRjHSIqC35OCiKcAslToCD0sn6Hi+rcF4auAHHoKJ/4BheBj+t4VuzvBezjrMZA0Ht/5SIZV4KFXgQnYMEkPa1GWqG/X1FcoL2JbFGYyF3ncrdvFes7vuxi24qEwtAzM0Em81agg/x9pqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565892333; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=/05z9LXJxSiFl2Wkh/G6SGKJ7hVGJivilvpTiM1VZqE=; b=jtaeQAHeGOexyH7f38LsqEL88HCpdn/MKj28wKHk8o+g7psgVAKx/rGrujZimhwcLWWknoQapVZllO774lnR0VLVe9TkmOJg47D2RgkcYFNhOHSODoZ8U8CuPVDie64Hen7fRr0Ri0dv12qiTJDuNpHyj2Y+UB2rbaXNAFTXV4g= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565892333369689.4917983616031; Thu, 15 Aug 2019 11:05:33 -0700 (PDT) Received: from localhost ([::1]:45762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyK7w-0004B8-6P for importer@patchew.org; Thu, 15 Aug 2019 14:05:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32818) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyK2R-00008w-8O for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hyK2P-0001uj-1h for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39940) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hyK2N-0001ov-He for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:48 -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 DA2F3300BCE9; Thu, 15 Aug 2019 17:59:46 +0000 (UTC) Received: from thuth.com (ovpn-116-65.ams2.redhat.com [10.36.116.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 038D417CDF; Thu, 15 Aug 2019 17:59:44 +0000 (UTC) From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 15 Aug 2019 19:59:20 +0200 Message-Id: <20190815175922.3475-8-thuth@redhat.com> In-Reply-To: <20190815175922.3475-1-thuth@redhat.com> References: <20190815175922.3475-1-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.46]); Thu, 15 Aug 2019 17:59:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 7/9] tests/libqtest: Clean up qtest_cb_for_every_machine() wrt global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The generic libqtest library functions should not use functions that require the global_qtest variable. Reviewed-by: Stefan Hajnoczi Reviewed-by: Eric Blake Message-Id: <20190813093047.27948-5-thuth@redhat.com> Signed-off-by: Thomas Huth --- tests/libqtest.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 3e9245d4c9..d1aead30ed 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -1189,9 +1189,10 @@ void qtest_cb_for_every_machine(void (*cb)(const cha= r *machine), QObject *qobj; QString *qstr; const char *mname; + QTestState *qts; =20 - qtest_start("-machine none"); - response =3D qmp("{ 'execute': 'query-machines' }"); + qts =3D qtest_init("-machine none"); + response =3D qtest_qmp(qts, "{ 'execute': 'query-machines' }"); g_assert(response); list =3D qdict_get_qlist(response, "return"); g_assert(list); @@ -1209,7 +1210,7 @@ void qtest_cb_for_every_machine(void (*cb)(const char= *machine), } } =20 - qtest_end(); + qtest_quit(qts); qobject_unref(response); } =20 --=20 2.18.1 From nobody Sun Feb 8 15:51:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565892510; cv=none; d=zoho.com; s=zohoarc; b=KkPM8QB+d6YRLLQTlaJ6yVfIP6u858J34JHv4VxVLtuzjGQhtOreoK2bFRJ++Tn26D+Y+BaWQXfpoNhdVAFbaEPnzlUFJIIBNSOADJuUL5feRT37YrpgcZCu4HmGwxh2OsEKeAK63cyudkNxt1iGE023rszIhfni11wPVJmoorg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565892510; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ZCIQ6hNlBQa7aNryJM+zxA8O2AyaxsxOZA0NjRsoVjc=; b=Lop+S4jbJqe1iiSGM6/e35af60moCtW1s55TUjtQm9b+Ft0514SpPTnW/usK+FdNDMZ9ygQr+Dk2Fz0uXbVA7hE+iWIV8j/ZNxW4tx48y1AOWU+Rgno0tx1hmZTFwFS2i4r/f1tU7ODMoGz8Bmu1jYcUMP+kvi7jk1+BoP4No6E= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565892510963878.4276485547413; Thu, 15 Aug 2019 11:08:30 -0700 (PDT) Received: from localhost ([::1]:45800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyKAn-0006q8-Ld for importer@patchew.org; Thu, 15 Aug 2019 14:08:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32844) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyK2U-0000GG-Ho for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hyK2R-0001zh-6A for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57032) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hyK2P-0001wI-T1 for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:50 -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 3F4118E90E; Thu, 15 Aug 2019 17:59:49 +0000 (UTC) Received: from thuth.com (ovpn-116-65.ams2.redhat.com [10.36.116.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 735F51EA; Thu, 15 Aug 2019 17:59:47 +0000 (UTC) From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 15 Aug 2019 19:59:21 +0200 Message-Id: <20190815175922.3475-9-thuth@redhat.com> In-Reply-To: <20190815175922.3475-1-thuth@redhat.com> References: <20190815175922.3475-1-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.26]); Thu, 15 Aug 2019 17:59:49 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 8/9] tests/libqtest: Make qtest_qmp_device_add/del independent from global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Generic library functions like qtest_qmp_device_add() and _del() should not depend on the global_qtest variable. Pass the test state via parameter instead. Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20190813093047.27948-6-thuth@redhat.com> Signed-off-by: Thomas Huth --- tests/cpu-plug-test.c | 15 +++++++++------ tests/e1000e-test.c | 2 +- tests/ivshmem-test.c | 2 +- tests/libqos/usb.c | 6 +++--- tests/libqos/usb.h | 2 +- tests/libqtest.c | 15 +++++++-------- tests/libqtest.h | 8 +++++--- tests/usb-hcd-ohci-test.c | 2 +- tests/usb-hcd-uhci-test.c | 8 +++++--- tests/usb-hcd-xhci-test.c | 22 +++++++++++++--------- tests/virtio-blk-test.c | 2 +- tests/virtio-ccw-test.c | 20 +++++++++++--------- tests/virtio-net-test.c | 2 +- tests/virtio-rng-test.c | 2 +- tests/virtio-scsi-test.c | 6 ++++-- tests/virtio-serial-test.c | 4 ++-- 16 files changed, 66 insertions(+), 52 deletions(-) diff --git a/tests/cpu-plug-test.c b/tests/cpu-plug-test.c index 668f00144e..3049620854 100644 --- a/tests/cpu-plug-test.c +++ b/tests/cpu-plug-test.c @@ -77,18 +77,19 @@ static void test_plug_with_device_add_x86(gconstpointer= data) const PlugTestData *td =3D data; char *args; unsigned int s, c, t; + QTestState *qts; =20 args =3D g_strdup_printf("-machine %s -cpu %s " "-smp 1,sockets=3D%u,cores=3D%u,threads=3D%u,ma= xcpus=3D%u", td->machine, td->cpu_model, td->sockets, td->cores, td->threads, td->maxcpu= s); - qtest_start(args); + qts =3D qtest_init(args); =20 for (s =3D 1; s < td->sockets; s++) { for (c =3D 0; c < td->cores; c++) { for (t =3D 0; t < td->threads; t++) { char *id =3D g_strdup_printf("id-%i-%i-%i", s, c, t); - qtest_qmp_device_add(td->device_model, id, + qtest_qmp_device_add(qts, td->device_model, id, "{'socket-id':%u, 'core-id':%u," " 'thread-id':%u}", s, c, t); @@ -97,7 +98,7 @@ static void test_plug_with_device_add_x86(gconstpointer d= ata) } } =20 - qtest_end(); + qtest_quit(qts); g_free(args); } =20 @@ -106,20 +107,22 @@ static void test_plug_with_device_add_coreid(gconstpo= inter data) const PlugTestData *td =3D data; char *args; unsigned int c; + QTestState *qts; =20 args =3D g_strdup_printf("-machine %s -cpu %s " "-smp 1,sockets=3D%u,cores=3D%u,threads=3D%u,ma= xcpus=3D%u", td->machine, td->cpu_model, td->sockets, td->cores, td->threads, td->maxcpu= s); - qtest_start(args); + qts =3D qtest_init(args); =20 for (c =3D 1; c < td->cores; c++) { char *id =3D g_strdup_printf("id-%i", c); - qtest_qmp_device_add(td->device_model, id, "{'core-id':%u}", c); + qtest_qmp_device_add(qts, td->device_model, id, + "{'core-id':%u}", c); g_free(id); } =20 - qtest_end(); + qtest_quit(qts); g_free(args); } =20 diff --git a/tests/e1000e-test.c b/tests/e1000e-test.c index 445787a7e4..93628c588d 100644 --- a/tests/e1000e-test.c +++ b/tests/e1000e-test.c @@ -235,7 +235,7 @@ static void test_e1000e_hotplug(void *obj, void *data, = QGuestAllocator * alloc) { QTestState *qts =3D global_qtest; /* TODO: get rid of global_qtest he= re */ =20 - qtest_qmp_device_add("e1000e", "e1000e_net", "{'addr': '0x06'}"); + qtest_qmp_device_add(qts, "e1000e", "e1000e_net", "{'addr': '0x06'}"); qpci_unplug_acpi_device_test(qts, "e1000e_net", 0x06); } =20 diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c index a467b8c03d..b76457948b 100644 --- a/tests/ivshmem-test.c +++ b/tests/ivshmem-test.c @@ -389,7 +389,7 @@ static void test_ivshmem_hotplug(void) qts =3D qtest_init("-object memory-backend-ram,size=3D1M,id=3Dmb1"); =20 global_qtest =3D qts; /* TODO: Get rid of global_qtest here */ - qtest_qmp_device_add("ivshmem-plain", "iv1", + qtest_qmp_device_add(qts, "ivshmem-plain", "iv1", "{'addr': %s, 'memdev': 'mb1'}", stringify(PCI_SLOT_HP)); if (strcmp(arch, "ppc64") !=3D 0) { diff --git a/tests/libqos/usb.c b/tests/libqos/usb.c index 49e2f4bc0a..d7a9cb3c72 100644 --- a/tests/libqos/usb.c +++ b/tests/libqos/usb.c @@ -37,20 +37,20 @@ void uhci_port_test(struct qhc *hc, int port, uint16_t = expect) g_assert((value & mask) =3D=3D (expect & mask)); } =20 -void usb_test_hotplug(const char *hcd_id, const char *port, +void usb_test_hotplug(QTestState *qts, const char *hcd_id, const char *por= t, void (*port_check)(void)) { char *id =3D g_strdup_printf("usbdev%s", port); char *bus =3D g_strdup_printf("%s.0", hcd_id); =20 - qtest_qmp_device_add("usb-tablet", id, "{'port': %s, 'bus': %s}", + qtest_qmp_device_add(qts, "usb-tablet", id, "{'port': %s, 'bus': %s}", port, bus); =20 if (port_check) { port_check(); } =20 - qtest_qmp_device_del(id); + qtest_qmp_device_del(qts, id); =20 g_free(bus); g_free(id); diff --git a/tests/libqos/usb.h b/tests/libqos/usb.h index c506418a13..eeced39a2f 100644 --- a/tests/libqos/usb.h +++ b/tests/libqos/usb.h @@ -13,6 +13,6 @@ void qusb_pci_init_one(QPCIBus *pcibus, struct qhc *hc, void uhci_port_test(struct qhc *hc, int port, uint16_t expect); void uhci_deinit(struct qhc *hc); =20 -void usb_test_hotplug(const char *bus_name, const char *port, +void usb_test_hotplug(QTestState *qts, const char *bus_name, const char *p= ort, void (*port_check)(void)); #endif diff --git a/tests/libqtest.c b/tests/libqtest.c index d1aead30ed..19c1fc2e97 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -1246,7 +1246,7 @@ QDict *qtest_qmp_receive_success(QTestState *s, /* * Generic hot-plugging test via the device_add QMP command. */ -void qtest_qmp_device_add(const char *driver, const char *id, +void qtest_qmp_device_add(QTestState *qts, const char *driver, const char = *id, const char *fmt, ...) { QDict *args, *response; @@ -1260,7 +1260,8 @@ void qtest_qmp_device_add(const char *driver, const c= har *id, qdict_put_str(args, "driver", driver); qdict_put_str(args, "id", id); =20 - response =3D qmp("{'execute': 'device_add', 'arguments': %p}", args); + response =3D qtest_qmp(qts, "{'execute': 'device_add', 'arguments': %p= }", + args); g_assert(response); g_assert(!qdict_haskey(response, "event")); /* We don't expect any eve= nts */ g_assert(!qdict_haskey(response, "error")); @@ -1293,19 +1294,17 @@ static void device_deleted_cb(void *opaque, const c= har *name, QDict *data) * * But the order of arrival may vary - so we've got to detect both. */ -void qtest_qmp_device_del(const char *id) +void qtest_qmp_device_del(QTestState *qts, const char *id) { bool got_event =3D false; QDict *rsp; =20 - qtest_qmp_send(global_qtest, - "{'execute': 'device_del', 'arguments': {'id': %s}}", + qtest_qmp_send(qts, "{'execute': 'device_del', 'arguments': {'id': %s}= }", id); - rsp =3D qtest_qmp_receive_success(global_qtest, device_deleted_cb, - &got_event); + rsp =3D qtest_qmp_receive_success(qts, device_deleted_cb, &got_event); qobject_unref(rsp); if (!got_event) { - rsp =3D qtest_qmp_receive(global_qtest); + rsp =3D qtest_qmp_receive(qts); g_assert_cmpstr(qdict_get_try_str(rsp, "event"), =3D=3D, "DEVICE_DELETED"); qobject_unref(rsp); diff --git a/tests/libqtest.h b/tests/libqtest.h index 0009b65791..d93144fb74 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -946,6 +946,7 @@ void qtest_cb_for_every_machine(void (*cb)(const char *= machine), =20 /** * qtest_qmp_device_add: + * @qts: QTestState instance to operate on * @driver: Name of the device that should be added * @id: Identification string * @fmt...: QMP message to send to qemu, formatted like @@ -954,16 +955,17 @@ void qtest_cb_for_every_machine(void (*cb)(const char= *machine), * * Generic hot-plugging test via the device_add QMP command. */ -void qtest_qmp_device_add(const char *driver, const char *id, const char *= fmt, - ...) GCC_FMT_ATTR(3, 4); +void qtest_qmp_device_add(QTestState *qts, const char *driver, const char = *id, + const char *fmt, ...) GCC_FMT_ATTR(4, 5); =20 /** * qtest_qmp_device_del: + * @qts: QTestState instance to operate on * @id: Identification string * * Generic hot-unplugging test via the device_del QMP command. */ -void qtest_qmp_device_del(const char *id); +void qtest_qmp_device_del(QTestState *qts, const char *id); =20 /** * qmp_rsp_is_err: diff --git a/tests/usb-hcd-ohci-test.c b/tests/usb-hcd-ohci-test.c index c12b892085..0cd73b7363 100644 --- a/tests/usb-hcd-ohci-test.c +++ b/tests/usb-hcd-ohci-test.c @@ -23,7 +23,7 @@ struct QOHCI_PCI { =20 static void test_ohci_hotplug(void *obj, void *data, QGuestAllocator *allo= c) { - usb_test_hotplug("ohci", "1", NULL); + usb_test_hotplug(global_qtest, "ohci", "1", NULL); } =20 static void *ohci_pci_get_driver(void *obj, const char *interface) diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c index 6d355c29da..2eef8e3d1c 100644 --- a/tests/usb-hcd-uhci-test.c +++ b/tests/usb-hcd-uhci-test.c @@ -43,14 +43,16 @@ static void test_port_2(void) =20 static void test_uhci_hotplug(void) { - usb_test_hotplug("uhci", "2", test_port_2); + usb_test_hotplug(global_qtest, "uhci", "2", test_port_2); } =20 static void test_usb_storage_hotplug(void) { - qtest_qmp_device_add("usb-storage", "usbdev0", "{'drive': 'drive0'}"); + QTestState *qts =3D global_qtest; =20 - qtest_qmp_device_del("usbdev0"); + qtest_qmp_device_add(qts, "usb-storage", "usbdev0", "{'drive': 'drive0= '}"); + + qtest_qmp_device_del(qts, "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 b15a51123f..01845371f9 100644 --- a/tests/usb-hcd-xhci-test.c +++ b/tests/usb-hcd-xhci-test.c @@ -18,30 +18,34 @@ static void test_xhci_init(void) =20 static void test_xhci_hotplug(void) { - usb_test_hotplug("xhci", "1", NULL); + usb_test_hotplug(global_qtest, "xhci", "1", NULL); } =20 static void test_usb_uas_hotplug(void) { - qtest_qmp_device_add("usb-uas", "uas", "{}"); - qtest_qmp_device_add("scsi-hd", "scsihd", "{'drive': 'drive0'}"); + QTestState *qts =3D global_qtest; + + qtest_qmp_device_add(qts, "usb-uas", "uas", "{}"); + qtest_qmp_device_add(qts, "scsi-hd", "scsihd", "{'drive': 'drive0'}"); =20 /* TODO: UAS HBA driver in libqos, to check that added disk is visible after BUS rescan */ =20 - qtest_qmp_device_del("scsihd"); - qtest_qmp_device_del("uas"); + qtest_qmp_device_del(qts, "scsihd"); + qtest_qmp_device_del(qts, "uas"); } =20 static void test_usb_ccid_hotplug(void) { - qtest_qmp_device_add("usb-ccid", "ccid", "{}"); - qtest_qmp_device_del("ccid"); + QTestState *qts =3D global_qtest; + + qtest_qmp_device_add(qts, "usb-ccid", "ccid", "{}"); + qtest_qmp_device_del(qts, "ccid"); /* check the device can be added again */ - qtest_qmp_device_add("usb-ccid", "ccid", "{}"); - qtest_qmp_device_del("ccid"); + qtest_qmp_device_add(qts, "usb-ccid", "ccid", "{}"); + qtest_qmp_device_del(qts, "ccid"); } =20 int main(int argc, char **argv) diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index 882b08ae29..982ff1538c 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -690,7 +690,7 @@ static void pci_hotplug(void *obj, void *data, QGuestAl= locator *t_alloc) QTestState *qts =3D dev1->pdev->bus->qts; =20 /* plug secondary disk */ - qtest_qmp_device_add("virtio-blk-pci", "drv1", + qtest_qmp_device_add(qts, "virtio-blk-pci", "drv1", "{'addr': %s, 'drive': 'drive1'}", stringify(PCI_SLOT_HP) ".0"); =20 diff --git a/tests/virtio-ccw-test.c b/tests/virtio-ccw-test.c index 6be4e6aaf6..9f445ef4ad 100644 --- a/tests/virtio-ccw-test.c +++ b/tests/virtio-ccw-test.c @@ -45,10 +45,12 @@ static void virtio_serial_nop(void) =20 static void virtio_serial_hotplug(void) { - global_qtest =3D qtest_initf("-device virtio-serial-ccw"); - qtest_qmp_device_add("virtserialport", "hp-port", "{}"); - qtest_qmp_device_del("hp-port"); - qtest_end(); + QTestState *qts =3D qtest_initf("-device virtio-serial-ccw"); + + qtest_qmp_device_add(qts, "virtserialport", "hp-port", "{}"); + qtest_qmp_device_del(qts, "hp-port"); + + qtest_quit(qts); } =20 static void virtio_blk_nop(void) @@ -79,16 +81,16 @@ static void virtio_scsi_nop(void) =20 static void virtio_scsi_hotplug(void) { - global_qtest =3D qtest_initf("-drive if=3Dnone,id=3Ddrv0,file=3Dnull-c= o://," - "file.read-zeroes=3Don,format=3Draw " + QTestState *s =3D qtest_initf("-drive if=3Dnone,id=3Ddrv0,file=3Dnull-= co://," + "file.read-zeroes=3Don,format=3Draw " "-drive if=3Dnone,id=3Ddrv1,file=3Dnull-co= ://," "file.read-zeroes=3Don,format=3Draw " "-device virtio-scsi-ccw " "-device scsi-hd,drive=3Ddrv0"); - qtest_qmp_device_add("scsi-hd", "scsihd", "{'drive': 'drv1'}"); - qtest_qmp_device_del("scsihd"); + qtest_qmp_device_add(s, "scsi-hd", "scsihd", "{'drive': 'drv1'}"); + qtest_qmp_device_del(s, "scsihd"); =20 - qtest_end(); + qtest_quit(s); } =20 int main(int argc, char **argv) diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index 1071dd82c9..840875aaae 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -174,7 +174,7 @@ static void hotplug(void *obj, void *data, QGuestAlloca= tor *t_alloc) QTestState *qts =3D dev->pdev->bus->qts; const char *arch =3D qtest_get_arch(); =20 - qtest_qmp_device_add("virtio-net-pci", "net1", + qtest_qmp_device_add(qts, "virtio-net-pci", "net1", "{'addr': %s}", stringify(PCI_SLOT_HP)); =20 if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { diff --git a/tests/virtio-rng-test.c b/tests/virtio-rng-test.c index a38a0d175b..092ba13068 100644 --- a/tests/virtio-rng-test.c +++ b/tests/virtio-rng-test.c @@ -22,7 +22,7 @@ static void rng_hotplug(void *obj, void *data, QGuestAllo= cator *alloc) =20 const char *arch =3D qtest_get_arch(); =20 - qtest_qmp_device_add("virtio-rng-pci", "rng1", + qtest_qmp_device_add(qts, "virtio-rng-pci", "rng1", "{'addr': %s}", stringify(PCI_SLOT_HP)); =20 if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c index 6393272149..16481491e3 100644 --- a/tests/virtio-scsi-test.c +++ b/tests/virtio-scsi-test.c @@ -150,8 +150,10 @@ static QVirtioSCSIQueues *qvirtio_scsi_init(QVirtioDev= ice *dev) =20 static void hotplug(void *obj, void *data, QGuestAllocator *alloc) { - qtest_qmp_device_add("scsi-hd", "scsihd", "{'drive': 'drv1'}"); - qtest_qmp_device_del("scsihd"); + QTestState *qts =3D global_qtest; + + qtest_qmp_device_add(qts, "scsi-hd", "scsihd", "{'drive': 'drv1'}"); + qtest_qmp_device_del(qts, "scsihd"); } =20 /* Test WRITE SAME with the lba not aligned */ diff --git a/tests/virtio-serial-test.c b/tests/virtio-serial-test.c index 066ca61280..e584ad76e8 100644 --- a/tests/virtio-serial-test.c +++ b/tests/virtio-serial-test.c @@ -20,8 +20,8 @@ static void virtio_serial_nop(void *obj, void *data, QGue= stAllocator *alloc) =20 static void serial_hotplug(void *obj, void *data, QGuestAllocator *alloc) { - qtest_qmp_device_add("virtserialport", "hp-port", "{}"); - qtest_qmp_device_del("hp-port"); + qtest_qmp_device_add(global_qtest, "virtserialport", "hp-port", "{}"); + qtest_qmp_device_del(global_qtest, "hp-port"); } =20 static void register_virtio_serial_test(void) --=20 2.18.1 From nobody Sun Feb 8 15:51:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565892793; cv=none; d=zoho.com; s=zohoarc; b=gSEr/5paOgYCA1WcL83Tm1nxCtZY86xWbFTDq/YT1VmQIBq1i58jQ+kpbRBZhrRbszqQMP+ydZNNOZgKq20jetHD21W8imVhn2glKwCWu6g1cPsZpNTEu7+e6HGHdaa4tH91dMk867uWYoCURJn2Ot/Ztmcc+w+F2OWXpN5DaB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565892793; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=3PXZg4QUujPB9kirv3jjcF0y/06jTvGTmAg2WvNi57A=; b=bE3ExZdKF9fFsiUkI5o4CmsU1ksbw+Bc4I7fsGfM8NipB3mW2BSg4Juj82sxQGplS5WfbfbY3kZC83LudEeULhnRCWmthOn1/lDwTY45RbVSdRjXyJpjljmwiheH1rgMuMth3y8Zl0EVY4DWHOti8qjkwsOAsUz48tz2jxwwWdU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565892793263529.3329230392224; Thu, 15 Aug 2019 11:13:13 -0700 (PDT) Received: from localhost ([::1]:45840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyKFH-0002eb-VH for importer@patchew.org; Thu, 15 Aug 2019 14:13:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32847) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyK2V-0000HA-0L for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hyK2S-00023R-J0 for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:54 -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 1hyK2S-00021E-Bt for qemu-devel@nongnu.org; Thu, 15 Aug 2019 13:59:52 -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 AC7A37FDCA; Thu, 15 Aug 2019 17:59:51 +0000 (UTC) Received: from thuth.com (ovpn-116-65.ams2.redhat.com [10.36.116.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA3F417CDF; Thu, 15 Aug 2019 17:59:49 +0000 (UTC) From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 15 Aug 2019 19:59:22 +0200 Message-Id: <20190815175922.3475-10-thuth@redhat.com> In-Reply-To: <20190815175922.3475-1-thuth@redhat.com> References: <20190815175922.3475-1-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.27]); Thu, 15 Aug 2019 17:59:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 9/9] tests/libqtest: Make qmp_assert_success() independent from global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The normal libqtest library functions should never depend on global_qtest. Pass in the test state via parameter instead. And while we're at it, also rename this function to qtest_qmp_assert_success() to make it clear that it is part of libqtest. Reviewed-by: Stefan Hajnoczi Reviewed-by: Eric Blake Message-Id: <20190813093047.27948-7-thuth@redhat.com> Signed-off-by: Thomas Huth --- tests/libqtest.c | 4 ++-- tests/libqtest.h | 6 ++++-- tests/virtio-scsi-test.c | 10 ++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 19c1fc2e97..eb971d0d11 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -1111,13 +1111,13 @@ QDict *qmp(const char *fmt, ...) return response; } =20 -void qmp_assert_success(const char *fmt, ...) +void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...) { va_list ap; QDict *response; =20 va_start(ap, fmt); - response =3D qtest_vqmp(global_qtest, fmt, ap); + response =3D qtest_vqmp(qts, fmt, ap); va_end(ap); =20 g_assert(response); diff --git a/tests/libqtest.h b/tests/libqtest.h index d93144fb74..7833148358 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -666,7 +666,8 @@ static inline void qtest_end(void) QDict *qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); =20 /** - * qmp_assert_success: + * qtest_qmp_assert_success: + * @qts: QTestState instance to operate on * @fmt...: QMP message to send to qemu, formatted like * qobject_from_jsonf_nofail(). See parse_escape() for what's * supported after '%'. @@ -674,7 +675,8 @@ QDict *qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); * Sends a QMP message to QEMU and asserts that a 'return' key is present = in * the response. */ -void qmp_assert_success(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...) + GCC_FMT_ATTR(2, 3); =20 /* * qmp_eventwait: diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c index 16481491e3..09348765d7 100644 --- a/tests/virtio-scsi-test.c +++ b/tests/virtio-scsi-test.c @@ -225,10 +225,12 @@ static void test_iothread_attach_node(void *obj, void= *data, mkqcow2(tmp_path, 64); =20 /* Attach the overlay to the null0 node */ - qmp_assert_success("{'execute': 'blockdev-add', 'arguments': {" - " 'driver': 'qcow2', 'node-name': 'overlay'," - " 'backing': 'null0', 'file': {" - " 'driver': 'file', 'filename': %s}}}", tmp_pat= h); + qtest_qmp_assert_success(scsi_pci->pci_vdev.pdev->bus->qts, + "{'execute': 'blockdev-add', 'arguments': {" + " 'driver': 'qcow2', 'node-name': 'overlay'= ," + " 'backing': 'null0', 'file': {" + " 'driver': 'file', 'filename': %s}}}", + tmp_path); =20 /* Send a request to see if the AioContext is still right */ ret =3D virtio_scsi_do_command(vs, write_cdb, NULL, 0, buf, 512, NULL); --=20 2.18.1