From patchwork Wed Dec 20 10:34:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 10125461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 62E0A6019C for ; Wed, 20 Dec 2017 10:48:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E58B296F1 for ; Wed, 20 Dec 2017 10:48:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3326C296F4; Wed, 20 Dec 2017 10:48:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C0821296F1 for ; Wed, 20 Dec 2017 10:48:11 +0000 (UTC) Received: from localhost ([::1]:45372 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRbv0-0007uR-TH for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 Dec 2017 05:48:10 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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); } +static coroutine_fn void test_drv_cb_coroutine_entry(void *opaque) +{ + bool *done = 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 = true; +} + +static void test_drv_cb_coroutine(void) +{ + Coroutine *co; + bool done; + + co = 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); } +static coroutine_fn void test_quiesce_coroutine_entry(void *opaque) +{ + bool *done = opaque; + + // XXX bdrv_drain_all() doesn't work in coroutine context + //test_quiesce_drain_all(); + test_quiesce_drain(); + test_quiesce_drain_subtree(); + + *done = true; +} + +static void test_quiesce_coroutine(void) +{ + Coroutine *co; + bool done; + + co = 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_coroutine); + g_test_add_func("/bdrv-drain/quiesce/drain_all", test_quiesce_drain_all); 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_coroutine); g_test_add_func("/bdrv-drain/nested", test_nested);