From nobody Wed Dec 17 05:35:05 2025 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=1563543964; cv=none; d=zoho.com; s=zohoarc; b=Cx3d5oDNOtOFWOMBbgSzFP0mH5eROAmcc62i17OstDdVOpkWbH5Yzu42f/K81HieImHKPp4NYmKaTSMa1ssp31Lrs3ynjVORuJyYSsosSo1lXg7P3VVc1Z+9k7BjuFID/Q/vTPNieig3ap1VtSm25CNUhBGfQ+enXkolW5rgFgE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563543964; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=44VeuK2MC41bqZKDcR6dOyncGzis6RF2AIt7N1egdYQ=; b=eHu+9w6Wo0+WvQOIjJ+CxxgSf4ApxLwTEgj18TQuUllXa3+5o1acJc1tvdSgPsYBqWNr0772JcrD2KqRNmXWMQjqtzAVvJTnNsQ0mw2ZpcOLBW7t2Itfmnt3Nvra4URfuzhxvCnlzAhBfmtupnti84bw626ePvFz/+5LsdeOUIs= 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 1563543964932558.5784908057958; Fri, 19 Jul 2019 06:46:04 -0700 (PDT) Received: from localhost ([::1]:45658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoTD1-0002Jx-GD for importer@patchew.org; Fri, 19 Jul 2019 09:46:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40372) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoTBB-0003ck-LJ for qemu-devel@nongnu.org; Fri, 19 Jul 2019 09:44:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hoTB9-0003XN-Gb for qemu-devel@nongnu.org; Fri, 19 Jul 2019 09:44:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60676) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hoTB5-0003UG-PE; Fri, 19 Jul 2019 09:44:03 -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 112293092656; Fri, 19 Jul 2019 13:44:03 +0000 (UTC) Received: from dhcp-200-226.str.redhat.com (dhcp-200-226.str.redhat.com [10.33.200.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24A2D608A4; Fri, 19 Jul 2019 13:44:02 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 19 Jul 2019 15:43:38 +0200 Message-Id: <20190719134345.23526-7-kwolf@redhat.com> In-Reply-To: <20190719134345.23526-1-kwolf@redhat.com> References: <20190719134345.23526-1-kwolf@redhat.com> MIME-Version: 1.0 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.43]); Fri, 19 Jul 2019 13:44:03 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 06/13] tests: Lock AioContexts in test-block-iothread 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: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Max Reitz When changing a node's AioContext, the caller must acquire the old AioContext (unless it currently runs in that old context). Therefore, unless the node currently is in the main context, we always have to acquire the old context around calls that may change a node's AioContext. Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- tests/test-block-iothread.c | 40 ++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/tests/test-block-iothread.c b/tests/test-block-iothread.c index 79d9cf8a57..1949d5e61a 100644 --- a/tests/test-block-iothread.c +++ b/tests/test-block-iothread.c @@ -348,8 +348,8 @@ static void test_sync_op(const void *opaque) if (t->blkfn) { t->blkfn(blk); } - aio_context_release(ctx); blk_set_aio_context(blk, qemu_get_aio_context(), &error_abort); + aio_context_release(ctx); =20 bdrv_unref(bs); blk_unref(blk); @@ -476,6 +476,7 @@ static void test_propagate_basic(void) { IOThread *iothread =3D iothread_new(); AioContext *ctx =3D iothread_get_aio_context(iothread); + AioContext *main_ctx; BlockBackend *blk; BlockDriverState *bs_a, *bs_b, *bs_verify; QDict *options; @@ -504,12 +505,14 @@ static void test_propagate_basic(void) g_assert(bdrv_get_aio_context(bs_b) =3D=3D ctx); =20 /* Switch the AioContext back */ - ctx =3D qemu_get_aio_context(); - blk_set_aio_context(blk, ctx, &error_abort); - g_assert(blk_get_aio_context(blk) =3D=3D ctx); - g_assert(bdrv_get_aio_context(bs_a) =3D=3D ctx); - g_assert(bdrv_get_aio_context(bs_verify) =3D=3D ctx); - g_assert(bdrv_get_aio_context(bs_b) =3D=3D ctx); + main_ctx =3D qemu_get_aio_context(); + aio_context_acquire(ctx); + blk_set_aio_context(blk, main_ctx, &error_abort); + aio_context_release(ctx); + g_assert(blk_get_aio_context(blk) =3D=3D main_ctx); + g_assert(bdrv_get_aio_context(bs_a) =3D=3D main_ctx); + g_assert(bdrv_get_aio_context(bs_verify) =3D=3D main_ctx); + g_assert(bdrv_get_aio_context(bs_b) =3D=3D main_ctx); =20 bdrv_unref(bs_verify); bdrv_unref(bs_b); @@ -534,6 +537,7 @@ static void test_propagate_diamond(void) { IOThread *iothread =3D iothread_new(); AioContext *ctx =3D iothread_get_aio_context(iothread); + AioContext *main_ctx; BlockBackend *blk; BlockDriverState *bs_a, *bs_b, *bs_c, *bs_verify; QDict *options; @@ -573,13 +577,15 @@ static void test_propagate_diamond(void) g_assert(bdrv_get_aio_context(bs_c) =3D=3D ctx); =20 /* Switch the AioContext back */ - ctx =3D qemu_get_aio_context(); - blk_set_aio_context(blk, ctx, &error_abort); - g_assert(blk_get_aio_context(blk) =3D=3D ctx); - g_assert(bdrv_get_aio_context(bs_verify) =3D=3D ctx); - g_assert(bdrv_get_aio_context(bs_a) =3D=3D ctx); - g_assert(bdrv_get_aio_context(bs_b) =3D=3D ctx); - g_assert(bdrv_get_aio_context(bs_c) =3D=3D ctx); + main_ctx =3D qemu_get_aio_context(); + aio_context_acquire(ctx); + blk_set_aio_context(blk, main_ctx, &error_abort); + aio_context_release(ctx); + g_assert(blk_get_aio_context(blk) =3D=3D main_ctx); + g_assert(bdrv_get_aio_context(bs_verify) =3D=3D main_ctx); + g_assert(bdrv_get_aio_context(bs_a) =3D=3D main_ctx); + g_assert(bdrv_get_aio_context(bs_b) =3D=3D main_ctx); + g_assert(bdrv_get_aio_context(bs_c) =3D=3D main_ctx); =20 blk_unref(blk); bdrv_unref(bs_verify); @@ -685,7 +691,9 @@ static void test_attach_second_node(void) g_assert(bdrv_get_aio_context(bs) =3D=3D ctx); g_assert(bdrv_get_aio_context(filter) =3D=3D ctx); =20 + aio_context_acquire(ctx); blk_set_aio_context(blk, main_ctx, &error_abort); + aio_context_release(ctx); g_assert(blk_get_aio_context(blk) =3D=3D main_ctx); g_assert(bdrv_get_aio_context(bs) =3D=3D main_ctx); g_assert(bdrv_get_aio_context(filter) =3D=3D main_ctx); @@ -712,7 +720,9 @@ static void test_attach_preserve_blk_ctx(void) g_assert(bdrv_get_aio_context(bs) =3D=3D ctx); =20 /* Remove the node again */ + aio_context_acquire(ctx); blk_remove_bs(blk); + aio_context_release(ctx); g_assert(blk_get_aio_context(blk) =3D=3D ctx); g_assert(bdrv_get_aio_context(bs) =3D=3D qemu_get_aio_context()); =20 @@ -721,7 +731,9 @@ static void test_attach_preserve_blk_ctx(void) g_assert(blk_get_aio_context(blk) =3D=3D ctx); g_assert(bdrv_get_aio_context(bs) =3D=3D ctx); =20 + aio_context_acquire(ctx); blk_set_aio_context(blk, qemu_get_aio_context(), &error_abort); + aio_context_release(ctx); bdrv_unref(bs); blk_unref(blk); } --=20 2.20.1