From nobody Thu Dec 18 13:19:09 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=1559575463; cv=none; d=zoho.com; s=zohoarc; b=eggLsam3DBgGm7AdV0YV38/koThdI/uQ5TugJhnEhKH/ygUXhZhB4St3CQ+dd8hPj9w9B2sodaJ15Qs9vO4SjpZbbtws481CCP9eX2P13aVZnhiCHvDrOQNHBZ69RNoUqyFy8E1tL33nhrqx53LfDs1SqQEBE9R6X6veQ1VNiuI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559575463; 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=NoY/rDVVZgcnyohCYACE1HBi10d101xXwmK/untU/aY=; b=NEHxxg6tr7Fr3bc1VGs5mkg5A/MtC9hZkF2IKDVtR2qRyOmb5EGbl13y580oSBX945qBxdJWWuXX2DNBar6sNBv3eyoIfy/BryQc0YmU1yauNk3oA49sqJzVgKjrT/egqgrew4LHvcOUugs4iVNnAVC81ipyfRdD4rIJBNxEhqg= 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 1559575463083998.6328948441827; Mon, 3 Jun 2019 08:24:23 -0700 (PDT) Received: from localhost ([127.0.0.1]:36600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXoot-0000e6-4m for importer@patchew.org; Mon, 03 Jun 2019 11:24:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40321) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXoW0-0001Va-DG for qemu-devel@nongnu.org; Mon, 03 Jun 2019 11:04:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXoVy-0001Ly-26 for qemu-devel@nongnu.org; Mon, 03 Jun 2019 11:04:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42008) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hXoVu-0000WI-Cp; Mon, 03 Jun 2019 11:04:42 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7BFA5946A; Mon, 3 Jun 2019 15:04:09 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id 927D067279; Mon, 3 Jun 2019 15:04:07 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 3 Jun 2019 17:02:23 +0200 Message-Id: <20190603150233.6614-19-kwolf@redhat.com> In-Reply-To: <20190603150233.6614-1-kwolf@redhat.com> References: <20190603150233.6614-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 03 Jun 2019 15:04:13 +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 18/28] test-block-iothread: BlockBackend AioContext across root node change 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, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Test that BlockBackends preserve their assigned AioContext even when the root node goes away. Inserting a new root node will move it to the right AioContext. Signed-off-by: Kevin Wolf --- tests/test-block-iothread.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/test-block-iothread.c b/tests/test-block-iothread.c index 38f59999ab..f41082e3bd 100644 --- a/tests/test-block-iothread.c +++ b/tests/test-block-iothread.c @@ -695,6 +695,38 @@ static void test_attach_second_node(void) blk_unref(blk); } =20 +static void test_attach_preserve_blk_ctx(void) +{ + IOThread *iothread =3D iothread_new(); + AioContext *ctx =3D iothread_get_aio_context(iothread); + BlockBackend *blk; + BlockDriverState *bs; + + blk =3D blk_new(ctx, BLK_PERM_ALL, BLK_PERM_ALL); + bs =3D bdrv_new_open_driver(&bdrv_test, "base", BDRV_O_RDWR, &error_ab= ort); + bs->total_sectors =3D 65536 / BDRV_SECTOR_SIZE; + + /* Add node to BlockBackend that has an iothread context assigned */ + blk_insert_bs(blk, bs, &error_abort); + g_assert(blk_get_aio_context(blk) =3D=3D ctx); + g_assert(bdrv_get_aio_context(bs) =3D=3D ctx); + + /* Remove the node again */ + blk_remove_bs(blk); + /* TODO bs should move back to main context here */ + g_assert(blk_get_aio_context(blk) =3D=3D ctx); + g_assert(bdrv_get_aio_context(bs) =3D=3D ctx); + + /* Re-attach the node */ + blk_insert_bs(blk, bs, &error_abort); + g_assert(blk_get_aio_context(blk) =3D=3D ctx); + g_assert(bdrv_get_aio_context(bs) =3D=3D ctx); + + blk_set_aio_context(blk, qemu_get_aio_context(), &error_abort); + bdrv_unref(bs); + blk_unref(blk); +} + int main(int argc, char **argv) { int i; @@ -711,6 +743,7 @@ int main(int argc, char **argv) =20 g_test_add_func("/attach/blockjob", test_attach_blockjob); g_test_add_func("/attach/second_node", test_attach_second_node); + g_test_add_func("/attach/preserve_blk_ctx", test_attach_preserve_blk_c= tx); g_test_add_func("/propagate/basic", test_propagate_basic); g_test_add_func("/propagate/diamond", test_propagate_diamond); g_test_add_func("/propagate/mirror", test_propagate_mirror); --=20 2.20.1