From nobody Sun Feb 8 21:33:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513766927220985.3904977534265; Wed, 20 Dec 2017 02:48:47 -0800 (PST) Received: from localhost ([::1]:45372 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRbvX-0007uR-5K for importer@patchew.org; Wed, 20 Dec 2017 05:48:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRbjD-0004uc-E7 for qemu-devel@nongnu.org; Wed, 20 Dec 2017 05:36:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eRbjB-0005O5-RH for qemu-devel@nongnu.org; Wed, 20 Dec 2017 05:35:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39348) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eRbj7-0005Hl-35; Wed, 20 Dec 2017 05:35:53 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 39E9AC00D899; Wed, 20 Dec 2017 10:35:52 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-136.ams2.redhat.com [10.36.116.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id C906918B2F; Wed, 20 Dec 2017 10:35:50 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 20 Dec 2017 11:34:07 +0100 Message-Id: <20171220103412.13048-15-kwolf@redhat.com> In-Reply-To: <20171220103412.13048-1-kwolf@redhat.com> References: <20171220103412.13048-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 20 Dec 2017 10:35:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 14/19] test-bdrv-drain: Test behaviour in coroutine context X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pbonzini@redhat.com, famz@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If bdrv_do_drained_begin/end() are called in coroutine context, they first use a BH to get out of the coroutine context. Call some existing tests again from a coroutine to cover this code path. Signed-off-by: Kevin Wolf --- tests/test-bdrv-drain.c | 51 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 51 insertions(+) diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index c00d96bb2f..a1e5693f33 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -188,6 +188,30 @@ static void test_drv_cb_drain_subtree(void) test_drv_cb_common(BDRV_SUBTREE_DRAIN, true); } =20 +static coroutine_fn void test_drv_cb_coroutine_entry(void *opaque) +{ + bool *done =3D opaque; + + // XXX bdrv_drain_all() doesn't work in coroutine context + //test_drv_cb_drain_all(); + test_drv_cb_drain(); + test_drv_cb_drain_subtree(); + + *done =3D true; +} + +static void test_drv_cb_coroutine(void) +{ + Coroutine *co; + bool done; + + co =3D qemu_coroutine_create(test_drv_cb_coroutine_entry, &done); + qemu_coroutine_enter(co); + while (!done) { + aio_poll(qemu_get_aio_context(), true); + } +} + static void test_quiesce_common(enum drain_type drain_type, bool recursive) { BlockBackend *blk; @@ -235,6 +259,30 @@ static void test_quiesce_drain_subtree(void) test_quiesce_common(BDRV_SUBTREE_DRAIN, true); } =20 +static coroutine_fn void test_quiesce_coroutine_entry(void *opaque) +{ + bool *done =3D opaque; + + // XXX bdrv_drain_all() doesn't work in coroutine context + //test_quiesce_drain_all(); + test_quiesce_drain(); + test_quiesce_drain_subtree(); + + *done =3D true; +} + +static void test_quiesce_coroutine(void) +{ + Coroutine *co; + bool done; + + co =3D qemu_coroutine_create(test_quiesce_coroutine_entry, &done); + qemu_coroutine_enter(co); + while (!done) { + aio_poll(qemu_get_aio_context(), true); + } +} + static void test_nested(void) { BlockBackend *blk; @@ -421,11 +469,14 @@ int main(int argc, char **argv) g_test_add_func("/bdrv-drain/driver-cb/drain", test_drv_cb_drain); g_test_add_func("/bdrv-drain/driver-cb/drain_subtree", test_drv_cb_drain_subtree); + g_test_add_func("/bdrv-drain/driver-cb/coroutine", test_drv_cb_corouti= ne); + =20 g_test_add_func("/bdrv-drain/quiesce/drain_all", test_quiesce_drain_al= l); g_test_add_func("/bdrv-drain/quiesce/drain", test_quiesce_drain); g_test_add_func("/bdrv-drain/quiesce/drain_subtree", test_quiesce_drain_subtree); + g_test_add_func("/bdrv-drain/quiesce/coroutine", test_quiesce_coroutin= e); =20 g_test_add_func("/bdrv-drain/nested", test_nested); =20 --=20 2.13.6