From nobody Sun Feb 8 23:32:55 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1663938612; cv=none; d=zohomail.com; s=zohoarc; b=EQGR39TzEO9Qb221QM7yuylbUTZ7MKAWxymI+5JgP2ssO8NVeepK7/ysS6W3hrEQZI47Q8xERJ1btazmD8o8m9wx8308oF4svn9vKz7hiKZ7SgJmtnyTR81bt3G8Fs87rPwSoAvjaeQUI1ml4vOtY3wpAv1q6RluF5kUPGmFJMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663938612; h=Content-Type: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; bh=0nEvWeYCznZKcS4hfRAFfcpNRzaqHk/p4F0V2zWBYds=; b=lUNFNliNxbgOwC5ZSvKKKig6Eotg2btrDYYi0T4gQQaAaKEKp/a9a3jGDaWtQhYTLCogpwiyXfwhqxScclZcBbrqhFtO0zdhbh/y/FV1hasNwt/wSCHpTMfkvprn1IxK18MAHnanJLfMAOljDHdG7kw+1gZ3kAZut3qTzrx1ZDY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1663938612313282.0539568937677; Fri, 23 Sep 2022 06:10:12 -0700 (PDT) Received: from localhost ([::1]:44656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1obiRV-0001Ko-IM for importer@patchew.org; Fri, 23 Sep 2022 09:10:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obiBx-00040M-Jn for qemu-devel@nongnu.org; Fri, 23 Sep 2022 08:54:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obiBu-0004JC-7b for qemu-devel@nongnu.org; Fri, 23 Sep 2022 08:54:04 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-322-QxhdHYQ9ONKu1xn_A13R9g-1; Fri, 23 Sep 2022 08:52:31 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D434D1C13951; Fri, 23 Sep 2022 12:52:30 +0000 (UTC) Received: from localhost (unknown [10.39.194.96]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 790EE1402BDB; Fri, 23 Sep 2022 12:52:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663937640; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0nEvWeYCznZKcS4hfRAFfcpNRzaqHk/p4F0V2zWBYds=; b=WpsFv+6XDOyyyA54HyA7JhOxtz6yORNyiwVxNDE53neD78xMjJkWJlB3NYrWhh5IZIfl5t YLSv3XRHp1ZgL/qyTslQtP7dc/8IdImWWhZIuDSENSRRlyoB0gYS8sCLumUlIweFPwKC9L 5TKiesy1fw19sdFeDJI9hOyKzg17N74= X-MC-Unique: QxhdHYQ9ONKu1xn_A13R9g-1 From: Hanna Reitz To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, Hanna Reitz , Kevin Wolf , Stefan Hajnoczi Subject: [PATCH 1/3] block: bdrv_child_get_parent_aio_context is not GS Date: Fri, 23 Sep 2022 14:52:25 +0200 Message-Id: <20220923125227.300202-2-hreitz@redhat.com> In-Reply-To: <20220923125227.300202-1-hreitz@redhat.com> References: <20220923125227.300202-1-hreitz@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1663938613836100001 Content-Type: text/plain; charset="utf-8" All implementations of bdrv_child_get_parent_aio_context() are IO_CODE (or do not mark anything in the case of block jobs), so this too can be IO_CODE. By the definition of "I/O API functions" in block-io.h, this is a strict relaxation, as I/O code can be run from both GS and I/O code arbitrarily. Signed-off-by: Hanna Reitz --- block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block.c b/block.c index bc85f46eed..7f2a9d4df0 100644 --- a/block.c +++ b/block.c @@ -1499,7 +1499,7 @@ const BdrvChildClass child_of_bds =3D { =20 AioContext *bdrv_child_get_parent_aio_context(BdrvChild *c) { - GLOBAL_STATE_CODE(); + IO_CODE(); return c->klass->get_parent_aio_context(c); } =20 --=20 2.36.1 From nobody Sun Feb 8 23:32:55 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1663938281; cv=none; d=zohomail.com; s=zohoarc; b=D2KLh27FejXe9HQ6Attf8TWxzoTRwiV77NXi3AVAMnjBlDldGVEx2TS+lrJ7hCMsXswNWeejXjROVD5WjqIJhS21fFYcxMGnEHkM/0b0pQNf+KB/GKgXwgP3PbZFSwKJsOj9nhKNIHyTNzlz+iaeFhWThG+9rYJ75tEoPmlxRA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663938281; h=Content-Type: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; bh=oqaBaOGdyy1YdBdUubG5/n0xrm29DW3Coz1MbYetgXc=; b=NrnV89Tlsl+XbZ3WGaaUU1HYQGvOqyG8IavKVEX84mX4ckYA1TeqmB23da7KmwqC/B6mKMa4IhHBH7ueaO5+ioeToLTE0SfjpKCqc+fwLcd16L0Rg1zNateoc60vHBZgW0UStWD2+SVn6F6hFkSZE3nCfTbXCF1tyBpYifC75ZY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1663938281453741.962729800395; Fri, 23 Sep 2022 06:04:41 -0700 (PDT) Received: from localhost ([::1]:45010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1obiMB-0004S6-M1 for importer@patchew.org; Fri, 23 Sep 2022 09:04:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obiBy-00040O-7t for qemu-devel@nongnu.org; Fri, 23 Sep 2022 08:54:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:45738) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obiBu-0004J6-JE for qemu-devel@nongnu.org; Fri, 23 Sep 2022 08:54:05 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-131-MmKbIhnXPvexlQUSdfb-og-1; Fri, 23 Sep 2022 08:52:32 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C736185A7AE; Fri, 23 Sep 2022 12:52:32 +0000 (UTC) Received: from localhost (unknown [10.39.194.96]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2B2B2492B08; Fri, 23 Sep 2022 12:52:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663937640; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oqaBaOGdyy1YdBdUubG5/n0xrm29DW3Coz1MbYetgXc=; b=RhlD3zm6lffVnns7Cd01UHh+AQNjsqruxOB0sMjOkScDQuksskkKo6YZ+I6OCNefyynD51 3/UWvG24jv6NoVyNR4iwrNgnyOV78FNM8Bt6U7kNw4dfrgtdUab9MUx2vG14WTVe6l828n c6tG7otgFFWuP4HU0iaA3Tv6lE7BHek= X-MC-Unique: MmKbIhnXPvexlQUSdfb-og-1 From: Hanna Reitz To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, Hanna Reitz , Kevin Wolf , Stefan Hajnoczi Subject: [PATCH 2/3] block-backend: Update ctx immediately after root Date: Fri, 23 Sep 2022 14:52:26 +0200 Message-Id: <20220923125227.300202-3-hreitz@redhat.com> In-Reply-To: <20220923125227.300202-1-hreitz@redhat.com> References: <20220923125227.300202-1-hreitz@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1663938282253100001 Content-Type: text/plain; charset="utf-8" blk_get_aio_context() asserts that blk->ctx is always equal to the root BDS's context (if there is a root BDS). Therefore, blk_do_set_aio_context() must update blk->ctx immediately after the root BDS's context has changed. Without this patch, the next patch would break iotest 238, because bdrv_drained_begin() (called by blk_do_set_aio_context()) may then invoke bdrv_child_get_parent_aio_context() on the root child, i.e. blk_get_aio_context(). However, by this point, blk->ctx would not have been updated and thus differ from the root node's context. This patch fixes that. Signed-off-by: Hanna Reitz Reviewed-by: Kevin Wolf --- block/block-backend.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index d4a5df2ac2..abdb5ff5af 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2156,6 +2156,7 @@ static int blk_do_set_aio_context(BlockBackend *blk, = AioContext *new_context, return ret; } } + blk->ctx =3D new_context; if (tgm->throttle_state) { bdrv_drained_begin(bs); throttle_group_detach_aio_context(tgm); @@ -2164,9 +2165,10 @@ static int blk_do_set_aio_context(BlockBackend *blk,= AioContext *new_context, } =20 bdrv_unref(bs); + } else { + blk->ctx =3D new_context; } =20 - blk->ctx =3D new_context; return 0; } =20 --=20 2.36.1 From nobody Sun Feb 8 23:32:55 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1663938123; cv=none; d=zohomail.com; s=zohoarc; b=X7u/OyR80cypSHCgiyB+a7rQa39GRO5NRWhcjLTUc2/jgTf81gF83nt8R8OEdTdS80KloLXOBU+DHoWFcIrEdr5a/rUNP+AxU+0BcS2Igx67+qp9jLzxxZEz/WlHIoSejt8VxOjmW3toDg6MjveeegNeaUV1e3JQeS0KWRVFkmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663938123; h=Content-Type: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; bh=EkKRskXPzBwMCLI1Mo41jU9e8hcxjqJ8DUdjfKH7+PU=; b=TcKfK79PumvffVj1jWxOTPoMrCsODheImx/waZx3L6W5kQbNvbagPadZQxNNgrVlQx+W7SlqkE0UyNnK9nqVAdyrmyq0GXzJ8LkxG9WIepRqyTFU6oCilgIdjRDtNpc3R/wy7H8y9v5z+MgARr1SYjUTMsQHy3XtsXw9O3fiy3c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1663938123678377.6640918189928; Fri, 23 Sep 2022 06:02:03 -0700 (PDT) Received: from localhost ([::1]:59512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1obiJe-00026W-Gu for importer@patchew.org; Fri, 23 Sep 2022 09:02:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59956) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obiBy-00040P-7t for qemu-devel@nongnu.org; Fri, 23 Sep 2022 08:54:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37046) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obiBv-0004JS-92 for qemu-devel@nongnu.org; Fri, 23 Sep 2022 08:54:05 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-594-lRDh_vWmNsizgx1uk0v6bw-1; Fri, 23 Sep 2022 08:52:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC737882829; Fri, 23 Sep 2022 12:52:38 +0000 (UTC) Received: from localhost (unknown [10.39.194.96]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA4CB111F3BB; Fri, 23 Sep 2022 12:52:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663937641; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EkKRskXPzBwMCLI1Mo41jU9e8hcxjqJ8DUdjfKH7+PU=; b=YQBSUFjLeV0wC5HQY4l+aI/mjECkICO/RMh3Fp8+1y9n5ZWD6/1fGOUDhS6YCwI9RelxM9 79wfoyYDA0Pqw6smHEO0Tp+tVs2SKd5N6oTBJtLND6382HzsE2UvfWPSrEaiFIvcqjRvG7 FefFPRVHVlraHy2DD4lyIaoq1vsoZPc= X-MC-Unique: lRDh_vWmNsizgx1uk0v6bw-1 From: Hanna Reitz To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, Hanna Reitz , Kevin Wolf , Stefan Hajnoczi Subject: [PATCH 3/3] block: Start/end drain on correct AioContext Date: Fri, 23 Sep 2022 14:52:27 +0200 Message-Id: <20220923125227.300202-4-hreitz@redhat.com> In-Reply-To: <20220923125227.300202-1-hreitz@redhat.com> References: <20220923125227.300202-1-hreitz@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1663938125187100001 Content-Type: text/plain; charset="utf-8" bdrv_parent_drained_{begin,end}_single() are supposed to operate on the parent, not on the child, so they should not attempt to get the context to poll from the child but the parent instead. BDRV_POLL_WHILE(c->bs) does get the context from the child, so we should replace it with AIO_WAIT_WHILE() on the parent's context instead. This problem becomes apparent when bdrv_replace_child_noperm() invokes bdrv_parent_drained_end_single() after removing a child from a subgraph that is in an I/O thread. By the time bdrv_parent_drained_end_single() is called, child->bs is NULL, and so BDRV_POLL_WHILE(c->bs, ...) will poll the main loop instead of the I/O thread; but anything that bdrv_parent_drained_end_single_no_poll() may have scheduled is going to want to run in the I/O thread, but because we poll the main loop, the I/O thread is never unpaused, and nothing is run, resulting in a deadlock. Closes: https://gitlab.com/qemu-project/qemu/-/issues/1215 Signed-off-by: Hanna Reitz Reviewed-by: Kevin Wolf --- block/io.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index 0a8cbefe86..7df1129b3b 100644 --- a/block/io.c +++ b/block/io.c @@ -71,9 +71,10 @@ static void bdrv_parent_drained_end_single_no_poll(BdrvC= hild *c, void bdrv_parent_drained_end_single(BdrvChild *c) { int drained_end_counter =3D 0; + AioContext *ctx =3D bdrv_child_get_parent_aio_context(c); IO_OR_GS_CODE(); bdrv_parent_drained_end_single_no_poll(c, &drained_end_counter); - BDRV_POLL_WHILE(c->bs, qatomic_read(&drained_end_counter) > 0); + AIO_WAIT_WHILE(ctx, qatomic_read(&drained_end_counter) > 0); } =20 static void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignor= e, @@ -116,13 +117,14 @@ static bool bdrv_parent_drained_poll(BlockDriverState= *bs, BdrvChild *ignore, =20 void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll) { + AioContext *ctx =3D bdrv_child_get_parent_aio_context(c); IO_OR_GS_CODE(); c->parent_quiesce_counter++; if (c->klass->drained_begin) { c->klass->drained_begin(c); } if (poll) { - BDRV_POLL_WHILE(c->bs, bdrv_parent_drained_poll_single(c)); + AIO_WAIT_WHILE(ctx, bdrv_parent_drained_poll_single(c)); } } =20 --=20 2.36.1