From nobody Thu May 2 22:29:30 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1686342065; cv=none; d=zohomail.com; s=zohoarc; b=FG9TZdZ+HVJg1Dgimy0BngfUOmbxx0dLISb+4pK5g0GGAWwvVbPoET15528Y+RihaF0cFLfjMcpjtOeNd2aHb1DkS+t6w4sUTalfnMMZJQIntwAUxSOvn6UCxm+a4lQ97ZaELDblbhN4cdxpAR0MolVFO3oH6XNY1Pg5twMBWAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686342065; 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; bh=RXj0EuXOLKtqtlvBCvBMqLRUqLmYf6zo5k0zO0GeMwE=; b=BZk+1T5tZUVj+txhW7ry0FHSXZ6Umx6HacuHX01urAHa7FER0qiJt/mqAemvd2WIWCHJigUFLqHO0selBYGXc9N0bQSIcl/IfjbRdn4+dJF1ZV7qGAQti3UNcJNjSSlhG41VJw0WSMBceU8e3cqZuF0evxJ2i8d/FKzsbVxxJ9A= 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+importer2=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 1686342065417599.3600948285082; Fri, 9 Jun 2023 13:21:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7iZw-0001x5-7W; Fri, 09 Jun 2023 16:19:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7iZu-0001wZ-Pg; Fri, 09 Jun 2023 16:19:22 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7iZt-00007w-8i; Fri, 09 Jun 2023 16:19:22 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1B51321A37; Fri, 9 Jun 2023 20:19:19 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2FCE7139C8; Fri, 9 Jun 2023 20:19:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IMQ3OUOJg2R/SwAAMHmgww (envelope-from ); Fri, 09 Jun 2023 20:19:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686341959; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RXj0EuXOLKtqtlvBCvBMqLRUqLmYf6zo5k0zO0GeMwE=; b=OUQ/Fi8bjXvdexKRpQiWLjDKe1/snAo++tqkoO53V7BcJGYS6L5TX4XRqpG5Cz05lVXa19 yGKzL9Khb7dIBKFrBFc1OvmPeZgBnpMFxKrUKCOED79okjTCQHECc/h0DJdpnJinJlgZVV 5xnq6gpjiPaEid6tXBMBKWlA7LMWv+o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686341959; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RXj0EuXOLKtqtlvBCvBMqLRUqLmYf6zo5k0zO0GeMwE=; b=LDNx0qen4N7/gVvFKOg37Mt2cvxrxiYOKlUbuE3YsXtmyAmLQE5KIhuQxiWDgf8C6X6Vll QJ8SepRja1TaP9Bw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?UTF-8?q?Jo=C3=A3o=20Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake Subject: [PATCH v2 01/10] block: Remove bdrv_query_block_node_info Date: Fri, 9 Jun 2023 17:19:01 -0300 Message-Id: <20230609201910.12100-2-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230609201910.12100-1-farosas@suse.de> References: <20230609201910.12100-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.220.28; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1686342066457100001 Content-Type: text/plain; charset="utf-8" The last call site of this function has been removed by commit c04d0ab026 ("qemu-img: Let info print block graph"). Reviewed-by: Claudio Fontana Signed-off-by: Fabiano Rosas --- block/qapi.c | 27 --------------------------- include/block/qapi.h | 3 --- 2 files changed, 30 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index f34f95e0ef..79bf80c503 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -309,33 +309,6 @@ out: aio_context_release(bdrv_get_aio_context(bs)); } =20 -/** - * bdrv_query_block_node_info: - * @bs: block node to examine - * @p_info: location to store node information - * @errp: location to store error information - * - * Store image information about @bs in @p_info. - * - * @p_info will be set only on success. On error, store error in @errp. - */ -void bdrv_query_block_node_info(BlockDriverState *bs, - BlockNodeInfo **p_info, - Error **errp) -{ - BlockNodeInfo *info; - ERRP_GUARD(); - - info =3D g_new0(BlockNodeInfo, 1); - bdrv_do_query_node_info(bs, info, errp); - if (*errp) { - qapi_free_BlockNodeInfo(info); - return; - } - - *p_info =3D info; -} - /** * bdrv_query_image_info: * @bs: block node to examine diff --git a/include/block/qapi.h b/include/block/qapi.h index 18d48ddb70..8663971c58 100644 --- a/include/block/qapi.h +++ b/include/block/qapi.h @@ -36,9 +36,6 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, int bdrv_query_snapshot_info_list(BlockDriverState *bs, SnapshotInfoList **p_list, Error **errp); -void bdrv_query_block_node_info(BlockDriverState *bs, - BlockNodeInfo **p_info, - Error **errp); void bdrv_query_image_info(BlockDriverState *bs, ImageInfo **p_info, bool flat, --=20 2.35.3 From nobody Thu May 2 22:29:30 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1686342048; cv=none; d=zohomail.com; s=zohoarc; b=gS8Boq1OzKnLRMFcYCm30zTrwyE+ycNX6RbNmeYvvk4Vy0R9sRnJwH4u5/2CceKIubd8uh4I3xhoRZYorOgyrY50W63oMX3ADo6cv6VngIZe4dCIZq/4RTR9qGN+PsOi4IMMBuEqE2laPrmOa2VLaPfON2+LJxIPY2liOqdfsyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686342048; 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; bh=aDPG6s1wnzqzM13GXTRnGfhBWM8mOiq7KY/UmYgH2Sw=; b=m1WyB9dyPyn3lPyc7JJH8eCHsaJ6TrGIyMKibObs0BE5N4RtUlb2Puy/1mQMHAm3FmX4ebf0dqcOKDlW0+gaAcc1OQq3Jl1+nNBNVf9jwI/Gz7WCZ7r449nu7+3rF3woVaIKsoRcTJ+VDOuQbuiC82etUEA7gdSkWY+3JXpnIAk= 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+importer2=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 1686342048002434.31222949518826; Fri, 9 Jun 2023 13:20:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7iZz-0001yu-Sg; Fri, 09 Jun 2023 16:19:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7iZx-0001xb-Bs; Fri, 09 Jun 2023 16:19:25 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7iZv-00008e-SW; Fri, 09 Jun 2023 16:19:25 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7D95421A6D; Fri, 9 Jun 2023 20:19:22 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 92908139C8; Fri, 9 Jun 2023 20:19:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AH9SFUeJg2R/SwAAMHmgww (envelope-from ); Fri, 09 Jun 2023 20:19:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686341962; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aDPG6s1wnzqzM13GXTRnGfhBWM8mOiq7KY/UmYgH2Sw=; b=1LpKv9zP4zx7oYdgOpDBccLBceIp+wimqT6A/HTZ9IrF7+t+wm7aWbkt+gsAkFScFcuwZR rQmnBLXCZXcCSc9sjY1+unq5EOK4wXOKJi3YJNM8U5LOUnDutrl0AREA6+h1bGxG1+tqJr yL38G9tZzueqmIf4+tIKux0HDhyt9jA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686341962; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aDPG6s1wnzqzM13GXTRnGfhBWM8mOiq7KY/UmYgH2Sw=; b=r4jBIUIwg9ooqlrP6z8qcabSMCYuMZt0CCmJp5XgAvszOQdddEEzrM2Mau8280ds321jhx r+X6vX2k0YHv02Bg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?UTF-8?q?Jo=C3=A3o=20Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake Subject: [PATCH v2 02/10] block: Remove unnecessary variable in bdrv_block_device_info Date: Fri, 9 Jun 2023 17:19:02 -0300 Message-Id: <20230609201910.12100-3-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230609201910.12100-1-farosas@suse.de> References: <20230609201910.12100-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.220.28; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1686342048304100001 Content-Type: text/plain; charset="utf-8" The commit 5d8813593f ("block/qapi: Let bdrv_query_image_info() recurse") removed the loop where we set the 'bs0' variable, so now it is just the same as 'bs'. Signed-off-by: Fabiano Rosas Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- block/qapi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 79bf80c503..1cbb0935ff 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -48,7 +48,7 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, { ImageInfo **p_image_info; ImageInfo *backing_info; - BlockDriverState *bs0, *backing; + BlockDriverState *backing; BlockDeviceInfo *info; ERRP_GUARD(); =20 @@ -145,7 +145,6 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *b= lk, =20 info->write_threshold =3D bdrv_write_threshold_get(bs); =20 - bs0 =3D bs; p_image_info =3D &info->image; info->backing_file_depth =3D 0; =20 @@ -153,7 +152,7 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *b= lk, * Skip automatically inserted nodes that the user isn't aware of for * query-block (blk !=3D NULL), but not for query-named-block-nodes */ - bdrv_query_image_info(bs0, p_image_info, flat, blk !=3D NULL, errp); + bdrv_query_image_info(bs, p_image_info, flat, blk !=3D NULL, errp); if (*errp) { qapi_free_BlockDeviceInfo(info); return NULL; --=20 2.35.3 From nobody Thu May 2 22:29:30 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1686342059; cv=none; d=zohomail.com; s=zohoarc; b=gyTK4GA8IONoDdvHXW2l6OnUjbvFRpCwMrj9XuTyO//6TJXGcNcHKzLEWB4YWcAIKaKgAQydgdF9UaEf+71azJd9oV7Ija9Z7NcDmM83I3S5MKZwr+zM5wtL10U0kIAJRKs/1xWd0NmlGEcNqBdDGNXetrcFJp+tbN384/FBt1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686342059; 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; bh=vFwsJTPWJty3/T05QzFhYEKl4bsab+BWn3aE/jqF4R4=; b=GIn8149zHPlL1JZQJYQxECCM+2IbiHZEAMqJlwgIEYcToGjJwZZEPHAYuWoxz/SxS94Hu3hkyeDESKNOqW3U9kq7jJY2U211cI3czvBPOVnA6/9qD5E/sJO2fjFeb7hE+R6R8yER/nXAxzrjrg6OAsWVuw9yN9tujoSp/3FGa84= 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+importer2=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 1686342059760112.21260825781496; Fri, 9 Jun 2023 13:20:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7ia2-0001zC-Iu; Fri, 09 Jun 2023 16:19:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7ia1-0001yy-8K; Fri, 09 Jun 2023 16:19:29 -0400 Received: from smtp-out1.suse.de ([2001:67c:2178:6::1c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7iZz-00009L-P7; Fri, 09 Jun 2023 16:19:29 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5CEDC21A7A; Fri, 9 Jun 2023 20:19:26 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 024A5139C8; Fri, 9 Jun 2023 20:19:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SGvnLUqJg2R/SwAAMHmgww (envelope-from ); Fri, 09 Jun 2023 20:19:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686341966; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vFwsJTPWJty3/T05QzFhYEKl4bsab+BWn3aE/jqF4R4=; b=jIG0CYfylW1Hc90egWl7UJIgp3HMUJfvjqNp2C2VF2i/GzNxPtZVVOAp19JUq/XesT7z0r nQbBYJPQpXBY8Z7AP+kONODf1c7I4JiLCNNAOq/U8O3raLkRqXvaGVK9Rd1KV4pTX/H8FN rRqJbF95tGyV1mBbk2FQmOQSjho/gqY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686341966; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vFwsJTPWJty3/T05QzFhYEKl4bsab+BWn3aE/jqF4R4=; b=xYSfuXEQ7jTqCoFz75uSc8nhlbN0ivH+5cn/ZzxJnXemMDNeg1X+zP5pDabZQPNC3NDHne Nnda1ZfJqCH3joAw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?UTF-8?q?Jo=C3=A3o=20Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake , John Snow , Cleber Rosa Subject: [PATCH v2 03/10] block: Allow the wrapper script to see functions declared in qapi.h Date: Fri, 9 Jun 2023 17:19:03 -0300 Message-Id: <20230609201910.12100-4-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230609201910.12100-1-farosas@suse.de> References: <20230609201910.12100-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:67c:2178:6::1c; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1686342061450100003 Content-Type: text/plain; charset="utf-8" The following patches will add co_wrapper annotations to functions declared in qapi.h. Add that header to the set of files used by block-coroutine-wrapper.py. Signed-off-by: Fabiano Rosas Reviewed-by: Hanna Czenczek --- block/meson.build | 1 + scripts/block-coroutine-wrapper.py | 1 + 2 files changed, 2 insertions(+) diff --git a/block/meson.build b/block/meson.build index fb4332bd66..7ad6a396a4 100644 --- a/block/meson.build +++ b/block/meson.build @@ -150,6 +150,7 @@ block_gen_c =3D custom_target('block-gen.c', '../include/block/dirty-bitmap.h', '../include/block/block_int-io.h', '../include/block/block-global-state= .h', + '../include/block/qapi.h', '../include/sysemu/block-backend-glo= bal-state.h', '../include/sysemu/block-backend-io.= h', 'coroutines.h' diff --git a/scripts/block-coroutine-wrapper.py b/scripts/block-coroutine-w= rapper.py index d4a183db61..814b62df26 100644 --- a/scripts/block-coroutine-wrapper.py +++ b/scripts/block-coroutine-wrapper.py @@ -44,6 +44,7 @@ def gen_header(): #include "block/block-gen.h" #include "block/block_int.h" #include "block/dirty-bitmap.h" +#include "block/qapi.h" """ =20 =20 --=20 2.35.3 From nobody Thu May 2 22:29:30 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1686342024; cv=none; d=zohomail.com; s=zohoarc; b=hmPoIa7p/ZYOaCqfXYJ2QORe+rwZZuV54gKsUTIwLspZ4eG0MaSPkUnIkx2okLnYCjyBOwn7ceQJqvJJ+dH04DqUz+bQaME7mZnajhhbaOG/nJyfe72RaJ0L+LQ6AO/6v+w0jl2jG3cvVwLZLNfvtpGOuV+IE987H35WsyaGMxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686342024; 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; bh=Jh5sG1xHrngl1FNbbZPSUScxdD6RZ8Ufzb6l9Teg74M=; b=dHBQTgV+qTzUKPtbPNa8Hnl7+aZPBQ1qpC57oZ71gouS6ND8OJ8dbiVoKEN7c6LJKq/mIPk8LNpbvHWYcCtq0W8NabyW5ixRUJYDgvUOxKQ0VOoun0ICpv6V6aUM3laZSh+9ivZd9tMCIM5rvs8NTqZR3dQBCMKKc0AeKlvOopk= 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+importer2=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 168634202449026.988584227424212; Fri, 9 Jun 2023 13:20:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7ia6-00020Z-Gc; Fri, 09 Jun 2023 16:19:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7ia4-0001zq-TG; Fri, 09 Jun 2023 16:19:32 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7ia3-00009y-DT; Fri, 09 Jun 2023 16:19:32 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CD37721A37; Fri, 9 Jun 2023 20:19:29 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D50E6139C8; Fri, 9 Jun 2023 20:19:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OGC/JU6Jg2R/SwAAMHmgww (envelope-from ); Fri, 09 Jun 2023 20:19:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686341969; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jh5sG1xHrngl1FNbbZPSUScxdD6RZ8Ufzb6l9Teg74M=; b=WbzjSUiipfucxhWysqpze0E4zNjJfxnOTZvE//o9H/eXOyrp+bQjnkLG+CXkdGi1zDEM05 q4xuaK8kYvVYI01ZGOWeW/B0l7mA/jtTuslyjOWHGfpRGhsMwhDOLfF1bE3XsIfzeM2qU7 +kevUTPDFOne/CljiH6enAVxI4epBK0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686341969; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jh5sG1xHrngl1FNbbZPSUScxdD6RZ8Ufzb6l9Teg74M=; b=A8yVtKHsYmRY2AnvMfds3rVDk4s6FhpCo7N2P+GlYDSkgk//BUJU8qet4QMjO3VQxECO5a PjI1SOvQuMOUynBQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?UTF-8?q?Jo=C3=A3o=20Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake Subject: [PATCH v2 04/10] block: Temporarily mark bdrv_co_get_allocated_file_size as mixed Date: Fri, 9 Jun 2023 17:19:04 -0300 Message-Id: <20230609201910.12100-5-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230609201910.12100-1-farosas@suse.de> References: <20230609201910.12100-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.220.28; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1686342026467100005 Content-Type: text/plain; charset="utf-8" Some callers of this function are about to be converted to run in coroutines, so allow it to be executed both inside and outside a coroutine while we convert all the callers. This will be reverted once all callers of bdrv_do_query_node_info run in a coroutine. Signed-off-by: Fabiano Rosas Reviewed-by: Eric Blake Reviewed-by: Hanna Czenczek --- include/block/block-io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/block/block-io.h b/include/block/block-io.h index 43af816d75..f31e25cf56 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -87,7 +87,7 @@ int64_t co_wrapper_mixed_bdrv_rdlock bdrv_getlength(Block= DriverState *bs); int64_t coroutine_fn GRAPH_RDLOCK bdrv_co_get_allocated_file_size(BlockDriverState *bs); =20 -int64_t co_wrapper_bdrv_rdlock +int64_t co_wrapper_mixed_bdrv_rdlock bdrv_get_allocated_file_size(BlockDriverState *bs); =20 BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts, --=20 2.35.3 From nobody Thu May 2 22:29:30 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1686342024; cv=none; d=zohomail.com; s=zohoarc; b=XWDB2l2wv3Njr2OqQlL0kk7dEV0ThhF8/04h+xaUENJeKwZ3OmJtK6b4MtXQ8rgbwe4Sxjabgp/lVlZ03NdtLX3MOjyGtoBiBpbNWrqvFcW1ixL2x948ZvYTqZHO1Mwl4ESBHSYXoTsZIcryQvDcBEwZWAvubpr1IJR3eQr7jf8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686342024; 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; bh=dII3YeyRx5/wTOevFR7gC9FxsWNXtQL9wfxZonUGT+M=; b=hOggwe2CQ8KYMx/qo/SXamKLyImH78aqF+BzP2NSOT5YTvH9qDPPuAA+/lKgpJBJunQ2SW2ZHd2iJDGgxmARAyHSmHfKZGIDmQLskh/cnjCHDtrL6orU4RcG+7RoCxy0xFVMQGnMS0Mq16bY+CZQr83iwQo34OpDncYCxHTAX7A= 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+importer2=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 1686342024395895.7075327578833; Fri, 9 Jun 2023 13:20:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7iaA-00022h-Ad; Fri, 09 Jun 2023 16:19:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7ia8-00022E-7A; Fri, 09 Jun 2023 16:19:36 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7ia6-0000AT-IT; Fri, 09 Jun 2023 16:19:35 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2882B21A37; Fri, 9 Jun 2023 20:19:33 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4692F139C8; Fri, 9 Jun 2023 20:19:30 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yOIkA1KJg2R/SwAAMHmgww (envelope-from ); Fri, 09 Jun 2023 20:19:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686341973; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dII3YeyRx5/wTOevFR7gC9FxsWNXtQL9wfxZonUGT+M=; b=g+BDXGM1ptuz36/1RqcON/bXXgf2jCHzH9mZY3eynkVyns31/VBHVoHGJT8ftklMmDOPhz sHQxPwwM90CX0agKQhKrSvj5Rk0HbX6YVYQ135ANWxUjU2dADOYOvxFecFOD88e5STl0v0 hC9F2umaYWRYh8o/ZSlVFqVja7N+Bt0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686341973; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dII3YeyRx5/wTOevFR7gC9FxsWNXtQL9wfxZonUGT+M=; b=Z97rGZhmyf/48SikgZNxzxsSeFTvzbx4Ejpkj+m2xTCsL2XTlNmE8qWjN6rLwzW+yWlXm5 Ze+RuUSbwRR7E7AA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?UTF-8?q?Jo=C3=A3o=20Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake Subject: [PATCH v2 05/10] block: Convert bdrv_query_block_graph_info to coroutine Date: Fri, 9 Jun 2023 17:19:05 -0300 Message-Id: <20230609201910.12100-6-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230609201910.12100-1-farosas@suse.de> References: <20230609201910.12100-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.220.28; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1686342025375100002 Content-Type: text/plain; charset="utf-8" We're converting callers of bdrv_get_allocated_file_size() to run in coroutines because that function will be made asynchronous when called (indirectly) from the QMP dispatcher. This function is a candidate because it calls bdrv_do_query_node_info(), which in turn calls bdrv_get_allocated_file_size(). All the functions called from bdrv_do_query_node_info() onwards are coroutine-safe, either have a coroutine version themselves[1] or are mostly simple code/string manipulation[2]. 1) bdrv_getlength(), bdrv_get_allocated_file_size(), bdrv_get_info(), bdrv_get_specific_info(); 2) bdrv_refresh_filename(), bdrv_get_format_name(), bdrv_get_full_backing_filename(), bdrv_query_snapshot_info_list(); Signed-off-by: Fabiano Rosas Reviewed-by: Hanna Czenczek --- block/qapi.c | 12 +++++++----- include/block/qapi.h | 6 +++++- qemu-img.c | 2 -- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 1cbb0935ff..a2e71edaff 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -375,7 +375,7 @@ fail: } =20 /** - * bdrv_query_block_graph_info: + * bdrv_co_query_block_graph_info: * @bs: root node to start from * @p_info: location to store image information * @errp: location to store error information @@ -384,15 +384,17 @@ fail: * * @p_info will be set only on success. On error, store error in @errp. */ -void bdrv_query_block_graph_info(BlockDriverState *bs, - BlockGraphInfo **p_info, - Error **errp) +void coroutine_fn bdrv_co_query_block_graph_info(BlockDriverState *bs, + BlockGraphInfo **p_info, + Error **errp) { BlockGraphInfo *info; BlockChildInfoList **children_list_tail; BdrvChild *c; ERRP_GUARD(); =20 + assert_bdrv_graph_readable(); + info =3D g_new0(BlockGraphInfo, 1); bdrv_do_query_node_info(bs, qapi_BlockGraphInfo_base(info), errp); if (*errp) { @@ -408,7 +410,7 @@ void bdrv_query_block_graph_info(BlockDriverState *bs, QAPI_LIST_APPEND(children_list_tail, c_info); =20 c_info->name =3D g_strdup(c->name); - bdrv_query_block_graph_info(c->bs, &c_info->info, errp); + bdrv_co_query_block_graph_info(c->bs, &c_info->info, errp); if (*errp) { goto fail; } diff --git a/include/block/qapi.h b/include/block/qapi.h index 8663971c58..7035bcd1ae 100644 --- a/include/block/qapi.h +++ b/include/block/qapi.h @@ -25,6 +25,7 @@ #ifndef BLOCK_QAPI_H #define BLOCK_QAPI_H =20 +#include "block/block-common.h" #include "block/graph-lock.h" #include "block/snapshot.h" #include "qapi/qapi-types-block-core.h" @@ -41,7 +42,10 @@ void bdrv_query_image_info(BlockDriverState *bs, bool flat, bool skip_implicit_filters, Error **errp); -void GRAPH_RDLOCK +void coroutine_fn GRAPH_RDLOCK +bdrv_co_query_block_graph_info(BlockDriverState *bs, BlockGraphInfo **p_in= fo, + Error **errp); +void co_wrapper_bdrv_rdlock bdrv_query_block_graph_info(BlockDriverState *bs, BlockGraphInfo **p_info, Error **errp); =20 diff --git a/qemu-img.c b/qemu-img.c index 27f48051b0..8066286f5e 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2945,9 +2945,7 @@ static BlockGraphInfoList *collect_image_info_list(bo= ol image_opts, * duplicate the backing chain information that we obtain by walki= ng * the chain manually here. */ - bdrv_graph_rdlock_main_loop(); bdrv_query_block_graph_info(bs, &info, &err); - bdrv_graph_rdunlock_main_loop(); =20 if (err) { error_report_err(err); --=20 2.35.3 From nobody Thu May 2 22:29:30 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1686342098; cv=none; d=zohomail.com; s=zohoarc; b=Z7nB8iERlediQeO0A1rfcEYMKzjmkjP/7+PK5nroWtJ3jkAB6RNZ4xj5/zY3h0DXORrWFXF201GtQ3HW3lxB2oZEn4D3lP+QevecXcn1g9iBJZsoWrsLgtEXQ6yObhGmgU9ZDTla5jjZc1LxwJCcGye0UJci+va0CuVBxRLjFd0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686342098; 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; bh=tpsBsTWWwIgYxCL079sJNHRptOhse1wDEWsxBAJclkY=; b=FPYFOTuRdvoDl77n+2Si3gJYf6qA3W/jCU2y+bnGzefjoHd2tEwcNuZnF/L9nYVjk1ZeJsmeXEwUd2Dw5UtASC0PcM3V16upOu0iKlbv8HdvAE7suu81yb6TqEKp5KfOBFJuZZu+Ff5WlH9YvjhfPcwutZQvRB4FCdElRVlwcV8= 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+importer2=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 16863420980941002.5779125503037; Fri, 9 Jun 2023 13:21:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7iaV-00025S-BM; Fri, 09 Jun 2023 16:19:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7iaR-00023z-DG; Fri, 09 Jun 2023 16:19:56 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7ia9-0000BA-V7; Fri, 09 Jun 2023 16:19:39 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8394E1FD6D; Fri, 9 Jun 2023 20:19:36 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A16EA139C8; Fri, 9 Jun 2023 20:19:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WFDzGFWJg2R/SwAAMHmgww (envelope-from ); Fri, 09 Jun 2023 20:19:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686341976; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tpsBsTWWwIgYxCL079sJNHRptOhse1wDEWsxBAJclkY=; b=GYDyhdSbarljKxwWeOHTMR+IOUudyXBvFWCQ4/nGYUJSJPb5tui+h/hDKTMT6NgahGipq3 w0m9Z19lwgyRBxl/IM6CFYUsBancfIxMUXwdqcZBr20sVCmCPvVDo3OL67Qy6sBU3uSR/4 EL9KhU0jtDQ4jS4jfxawCkri+fdfFmI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686341976; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tpsBsTWWwIgYxCL079sJNHRptOhse1wDEWsxBAJclkY=; b=sRK+L+DG+z3qwDeRzqHvAy3o9Z5Q8lNTVqWbeExxPxxdH4MXxA168dl59gdNSKtrDVoGvo r4/48xZff6EKLtAA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?UTF-8?q?Jo=C3=A3o=20Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake Subject: [PATCH v2 06/10] block: Convert bdrv_block_device_info into co_wrapper Date: Fri, 9 Jun 2023 17:19:06 -0300 Message-Id: <20230609201910.12100-7-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230609201910.12100-1-farosas@suse.de> References: <20230609201910.12100-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.220.29; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1686342099700100003 Content-Type: text/plain; charset="utf-8" We're converting callers of bdrv_get_allocated_file_size() to run in coroutines because that function will be made asynchronous when called (indirectly) from the QMP dispatcher. This function is a candidate because it calls bdrv_query_image_info() -> bdrv_do_query_node_info() -> bdrv_get_allocated_file_size(). It is safe to turn this is a coroutine because the code it calls is made up of either simple accessors and string manipulation functions [1] or it has already been determined to be safe [2]. 1) bdrv_refresh_filename(), bdrv_is_read_only(), blk_enable_write_cache(), bdrv_cow_bs(), blk_get_public(), throttle_group_get_name(), bdrv_write_threshold_get(), bdrv_query_dirty_bitmaps(), throttle_group_get_config(), bdrv_filter_or_cow_bs(), bdrv_skip_implicit_filters() 2) bdrv_do_query_node_info() (see previous commit); Signed-off-by: Fabiano Rosas --- block/qapi.c | 8 ++++---- include/block/qapi.h | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index a2e71edaff..20660e15d6 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -41,10 +41,10 @@ #include "qemu/qemu-print.h" #include "sysemu/block-backend.h" =20 -BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, - BlockDriverState *bs, - bool flat, - Error **errp) +BlockDeviceInfo *coroutine_fn bdrv_co_block_device_info(BlockBackend *blk, + BlockDriverState *= bs, + bool flat, + Error **errp) { ImageInfo **p_image_info; ImageInfo *backing_info; diff --git a/include/block/qapi.h b/include/block/qapi.h index 7035bcd1ae..5cb0202791 100644 --- a/include/block/qapi.h +++ b/include/block/qapi.h @@ -30,10 +30,14 @@ #include "block/snapshot.h" #include "qapi/qapi-types-block-core.h" =20 -BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, - BlockDriverState *bs, - bool flat, - Error **errp); +BlockDeviceInfo *coroutine_fn bdrv_co_block_device_info(BlockBackend *blk, + BlockDriverState *= bs, + bool flat, + Error **errp); +BlockDeviceInfo *co_wrapper bdrv_block_device_info(BlockBackend *blk, + BlockDriverState *bs, + bool flat, + Error **errp); int bdrv_query_snapshot_info_list(BlockDriverState *bs, SnapshotInfoList **p_list, Error **errp); --=20 2.35.3 From nobody Thu May 2 22:29:30 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1686342099; cv=none; d=zohomail.com; s=zohoarc; b=VRlA4HJv1bdHvvr9MYJAK7LiijduoL8KSmYC+v6ffEzSv9KvnHp+OstjKhnndx9CqlSd2Rz8wvhuuXqN0RzbNX+EUCgXh7VCJnwCKJhkuAC4WoaobhaVygTOGKRoTGN2opKkxr8xaRSz8GczqA/4Q8WCBfY3V0KnQaWkXMlEACM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686342099; 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; bh=pKxypfCH/TWYNn3NOXAvEalB2qXeE4bPySVDgd5YRIg=; b=Jqvz/Z94FhQvbBHLxLJeMwzbNGr7bll7S4Hv6Y62Df41c1ZCo2/N45RRhfKBmykyiaSY9xJ9FbhvnkVmIaKeMNYolORaA4rIQERcTqNIxc8JYZyhIODhg1qUVup1lR/SdilcOHBFQi6FsqFa51r6nL3PQdBoenc2D9bh8J9ng78= 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+importer2=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 1686342099861215.34752899487455; Fri, 9 Jun 2023 13:21:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7iaX-00027C-CJ; Fri, 09 Jun 2023 16:20:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7iaU-00024d-Qp; Fri, 09 Jun 2023 16:19:58 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7iaR-0000Da-Ia; Fri, 09 Jun 2023 16:19:58 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DDCC421A89; Fri, 9 Jun 2023 20:19:39 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 08DDF139C8; Fri, 9 Jun 2023 20:19:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MIOuL1iJg2R/SwAAMHmgww (envelope-from ); Fri, 09 Jun 2023 20:19:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686341979; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pKxypfCH/TWYNn3NOXAvEalB2qXeE4bPySVDgd5YRIg=; b=SX+uPmHOrQLflHH8hZ90+gEZRg2+aX6gVn4rDglsuDHXvajM42dHOqjYJODea1nvo//2Fa IFJzyLrvUM3toAvkwrFv637RWTPXzFXLxfphLhfTcZVnQfmU1HYx0v1qCXCrP40wWeGqad FoN16aqjIStzxexBVHg304ggOAFjJUY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686341979; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pKxypfCH/TWYNn3NOXAvEalB2qXeE4bPySVDgd5YRIg=; b=oja0keUZBFL7mgPWsH3tuU2JtvnfIkJNtqiSXhZiZPuzN6jW7B7NQC6gL1wsGKQKipIbGQ 6+22gjfQyHeF/IAA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?UTF-8?q?Jo=C3=A3o=20Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake Subject: [PATCH v2 07/10] block: Convert qmp_query_named_block_nodes to coroutine Date: Fri, 9 Jun 2023 17:19:07 -0300 Message-Id: <20230609201910.12100-8-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230609201910.12100-1-farosas@suse.de> References: <20230609201910.12100-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.220.28; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1686342100752100005 Content-Type: text/plain; charset="utf-8" From: Lin Ma We're converting callers of bdrv_get_allocated_file_size() to run in coroutines because that function will be made asynchronous when called (indirectly) from the QMP dispatcher. This QMP command is a candidate because it indirectly calls bdrv_get_allocated_file_size() through bdrv_block_device_info() -> bdrv_query_image_info() -> bdrv_query_image_info(). The previous patches have determined that bdrv_query_image_info() and bdrv_do_query_node_info() are coroutine-safe so we can just make the QMP command run in a coroutine. Signed-off-by: Lin Ma Signed-off-by: Fabiano Rosas --- block.c | 2 +- blockdev.c | 6 +++--- qapi/block-core.json | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index f94cee8930..abed744b60 100644 --- a/block.c +++ b/block.c @@ -6148,7 +6148,7 @@ BlockDeviceInfoList *bdrv_named_nodes_list(bool flat, =20 list =3D NULL; QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) { - BlockDeviceInfo *info =3D bdrv_block_device_info(NULL, bs, flat, e= rrp); + BlockDeviceInfo *info =3D bdrv_co_block_device_info(NULL, bs, flat= , errp); if (!info) { qapi_free_BlockDeviceInfoList(list); return NULL; diff --git a/blockdev.c b/blockdev.c index e6eba61484..8b5f7d06c8 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2818,9 +2818,9 @@ void qmp_drive_backup(DriveBackup *backup, Error **er= rp) blockdev_do_action(&action, errp); } =20 -BlockDeviceInfoList *qmp_query_named_block_nodes(bool has_flat, - bool flat, - Error **errp) +BlockDeviceInfoList *coroutine_fn qmp_query_named_block_nodes(bool has_fla= t, + bool flat, + Error **errp) { bool return_flat =3D has_flat && flat; =20 diff --git a/qapi/block-core.json b/qapi/block-core.json index 5dd5f7e4b0..9d4c92f2c9 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1972,7 +1972,8 @@ { 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ], 'data': { '*flat': 'bool' }, - 'allow-preconfig': true } + 'allow-preconfig': true, + 'coroutine': true} =20 ## # @XDbgBlockGraphNodeType: --=20 2.35.3 From nobody Thu May 2 22:29:30 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1686342106; cv=none; d=zohomail.com; s=zohoarc; b=kN0X3YERgqTSPQkls71/9+/vXkGKkPFMHf9VpkKvS4VM1ORzWGlaTKIhtF5ZCF+3QCR0HCP7ZscFJBFLwtMZGfJywijXB1d7kbKCe1hRG4CGLHbfAT6trEpSlfa5alME+yRVwr24k+rY9Rut0Cn+XJrG1uO0rRAYt13tzopamKQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686342106; 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; bh=IAYfXytPDBRwVP2G0FvkZTp/QNZh8w1vC/I5UdCl9Qc=; b=EIqFCKMCIu4JUo1sfZgaLfvLfA9IhWkIkxk297N4OFMTODvkTO0C8GP5U5CMEQbvxqx/GcnwUGYcpwOnMa9TDLZ7rGLlIrTW7Sf5HWJeyTbAuWvGv8ydC+PR7ut0i9ZwgPbsc+qpjGhgI8jO2+BhqaOPheD4lwTwda8Xh/sPG1A= 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+importer2=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 1686342106837337.32017585949427; Fri, 9 Jun 2023 13:21:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7iaX-00026y-7R; Fri, 09 Jun 2023 16:20:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7iaU-00024T-Lv; Fri, 09 Jun 2023 16:19:58 -0400 Received: from smtp-out2.suse.de ([2001:67c:2178:6::1d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7iaR-0000Dt-HY; Fri, 09 Jun 2023 16:19:58 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 43C771FE13; Fri, 9 Jun 2023 20:19:43 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 60712139C8; Fri, 9 Jun 2023 20:19:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YN1eCVyJg2R/SwAAMHmgww (envelope-from ); Fri, 09 Jun 2023 20:19:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686341983; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IAYfXytPDBRwVP2G0FvkZTp/QNZh8w1vC/I5UdCl9Qc=; b=z/RTtIPWgmTXDVaU/tHMliLe15sUelYljhui202FrVHLxtZbT/BAz9J+4k+iEe1THo8sK8 ywg+WbF/ZJsgqWr/sgTbC8dJ8blhfPAFS3L9Yp9TgOXzgnMhU1mZYyy8fYkk1xRiF7kmnI cxxYTbc5eZJeWDyDICCIRmyq+RkgyVw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686341983; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IAYfXytPDBRwVP2G0FvkZTp/QNZh8w1vC/I5UdCl9Qc=; b=EChQqPKF1mEE8Uzme6jGqT3VPrCCn7UdMqF5P/dwDfZpqYzuZhc3K72eNhFQSk1gNUKmzn Ms/Pem9yzchvG0CA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?UTF-8?q?Jo=C3=A3o=20Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake Subject: [PATCH v2 08/10] block: Don't query all block devices at hmp_nbd_server_start Date: Fri, 9 Jun 2023 17:19:08 -0300 Message-Id: <20230609201910.12100-9-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230609201910.12100-1-farosas@suse.de> References: <20230609201910.12100-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:67c:2178:6::1d; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1686342108682100001 Content-Type: text/plain; charset="utf-8" We're currently doing a full query-block just to enumerate the devices for qmp_nbd_server_add and then discarding the BlockInfoList afterwards. Alter hmp_nbd_server_start to instead iterate explicitly over the block_backends list. This allows the removal of the dependency on qmp_query_block from hmp_nbd_server_start. This is desirable because we're about to move qmp_query_block into a coroutine and don't need to change the NBD code at the same time. Signed-off-by: Fabiano Rosas --- block/monitor/block-hmp-cmds.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index ca2599de44..26116fe831 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -394,7 +394,7 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qd= ict) bool writable =3D qdict_get_try_bool(qdict, "writable", false); bool all =3D qdict_get_try_bool(qdict, "all", false); Error *local_err =3D NULL; - BlockInfoList *block_list, *info; + BlockBackend *blk; SocketAddress *addr; NbdServerAddOptions export; =20 @@ -419,18 +419,24 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *= qdict) return; } =20 - /* Then try adding all block devices. If one fails, close all and + /* + * Then try adding all block devices. If one fails, close all and * exit. */ - block_list =3D qmp_query_block(NULL); + for (blk =3D blk_all_next(NULL); blk; blk =3D blk_all_next(blk)) { + BlockDriverState *bs =3D blk_bs(blk); =20 - for (info =3D block_list; info; info =3D info->next) { - if (!info->value->inserted) { + if (!*blk_name(blk) && !blk_get_attached_dev(blk)) { + continue; + } + + bs =3D bdrv_skip_implicit_filters(bs); + if (!bs || !bs->drv) { continue; } =20 export =3D (NbdServerAddOptions) { - .device =3D info->value->device, + .device =3D g_strdup(blk_name(blk)), .has_writable =3D true, .writable =3D writable, }; @@ -443,8 +449,6 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qd= ict) } } =20 - qapi_free_BlockInfoList(block_list); - exit: hmp_handle_error(mon, local_err); } --=20 2.35.3 From nobody Thu May 2 22:29:30 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1686342047; cv=none; d=zohomail.com; s=zohoarc; b=RDVZLnaACaWikAkN5f9xM8EiG+wXhSLQBP8PwoPNr4gIuU1W4IgYCE98EvFDob1DqVhVtmqtDbf1OX+lQkGMEFURXyzl+Dwo5E5t7AL280ZjbMD2DJN48hndrmVrUEvhvY02w/BCeb511iNu62Jvnwoyv+erWpIqhf+emvq8pg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686342047; 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; bh=enuupaTJDX4N+4BscN7GlbxD/HxwHwJVr5Z+5Z5sObA=; b=jswXu7r9GaLBUcWgxEDlT+ljRlO90nJFeBtEReajbyWpJRD1S1VjQBHzqssjylpPaIm2bJPqYtIOMU3yDYvIaI3/3YU65T7EPYvVR4EzA9pM4a7EBCbIxayD1U4gvpQh0jYO0YePUvUY+sSpE5jq40RmoRkByHKXK8l8KOMqK2E= 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+importer2=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 1686342047957448.64687608599013; Fri, 9 Jun 2023 13:20:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7iaW-000268-MT; Fri, 09 Jun 2023 16:20:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7iaT-00024O-CR; Fri, 09 Jun 2023 16:19:57 -0400 Received: from smtp-out1.suse.de ([2001:67c:2178:6::1c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7iaR-0000EO-HK; Fri, 09 Jun 2023 16:19:57 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DA5E321A8C; Fri, 9 Jun 2023 20:19:46 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C348D139C8; Fri, 9 Jun 2023 20:19:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6N+2IV+Jg2R/SwAAMHmgww (envelope-from ); Fri, 09 Jun 2023 20:19:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686341986; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=enuupaTJDX4N+4BscN7GlbxD/HxwHwJVr5Z+5Z5sObA=; b=kaUPKoAYt5RDGsGfdaCO2116pTjaxBy093NXvyjeqcHMBtAg+kj2bkKQMmlqgEbv2wHrY/ w+WbyHa5YTPnolIwU6QgIqvEBA7Pqgp15IJwHW0w85jVc8WyKBzp/1Bc+r+XBgXflhXIM4 HoLyYEZ7Rhzn+GghfQyE3nwPjAbVYzU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686341986; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=enuupaTJDX4N+4BscN7GlbxD/HxwHwJVr5Z+5Z5sObA=; b=BHNsJbxSScxTewwhqltYKgYpZj4upKBgqTEYeWoJ76mMYS83dlugUXUi4gFiEe+kqBUth1 3VV3zoWprYqGeGAg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?UTF-8?q?Jo=C3=A3o=20Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake , "Dr. David Alan Gilbert" Subject: [PATCH v2 09/10] block: Convert qmp_query_block() to coroutine_fn Date: Fri, 9 Jun 2023 17:19:09 -0300 Message-Id: <20230609201910.12100-10-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230609201910.12100-1-farosas@suse.de> References: <20230609201910.12100-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:67c:2178:6::1c; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1686342048364100003 Content-Type: text/plain; charset="utf-8" This is another caller of bdrv_get_allocated_file_size() that needs to be converted to a coroutine because that function will be made asynchronous when called (indirectly) from the QMP dispatcher. This QMP command is a candidate because it calls bdrv_do_query_node_info(), which in turn calls bdrv_get_allocated_file_size(). We've determined bdrv_do_query_node_info() to be coroutine-safe (see previous commits), so we can just put this QMP command in a coroutine. Since qmp_query_block() now expects to run in a coroutine, its callers need to be converted as well. Convert hmp_info_block(), which calls only coroutine-safe code, including qmp_query_named_block_nodes() which has been converted to coroutine in the previous patches. Now that all callers of bdrv_[co_]block_device_info() are using the coroutine version, a few things happen: - we can return to using bdrv_block_device_info() without a wrapper; - bdrv_get_allocated_file_size() can stop being mixed; - bdrv_co_get_allocated_file_size() needs to be put under the graph lock because it is being called wthout the wrapper; - bdrv_do_query_node_info() doesn't need to acquire the AioContext because it doesn't call aio_poll anymore; Signed-off-by: Fabiano Rosas --- block.c | 2 +- block/monitor/block-hmp-cmds.c | 2 +- block/qapi.c | 18 +++++++++--------- hmp-commands-info.hx | 1 + include/block/block-hmp-cmds.h | 2 +- include/block/block-io.h | 2 +- include/block/qapi.h | 12 ++++-------- qapi/block-core.json | 2 +- 8 files changed, 19 insertions(+), 22 deletions(-) diff --git a/block.c b/block.c index abed744b60..f94cee8930 100644 --- a/block.c +++ b/block.c @@ -6148,7 +6148,7 @@ BlockDeviceInfoList *bdrv_named_nodes_list(bool flat, =20 list =3D NULL; QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) { - BlockDeviceInfo *info =3D bdrv_co_block_device_info(NULL, bs, flat= , errp); + BlockDeviceInfo *info =3D bdrv_block_device_info(NULL, bs, flat, e= rrp); if (!info) { qapi_free_BlockDeviceInfoList(list); return NULL; diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index 26116fe831..1049f9b006 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -742,7 +742,7 @@ static void print_block_info(Monitor *mon, BlockInfo *i= nfo, } } =20 -void hmp_info_block(Monitor *mon, const QDict *qdict) +void coroutine_fn hmp_info_block(Monitor *mon, const QDict *qdict) { BlockInfoList *block_list, *info; BlockDeviceInfoList *blockdev_list, *blockdev; diff --git a/block/qapi.c b/block/qapi.c index 20660e15d6..3b4bc0b782 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -41,10 +41,10 @@ #include "qemu/qemu-print.h" #include "sysemu/block-backend.h" =20 -BlockDeviceInfo *coroutine_fn bdrv_co_block_device_info(BlockBackend *blk, - BlockDriverState *= bs, - bool flat, - Error **errp) +BlockDeviceInfo *coroutine_fn bdrv_block_device_info(BlockBackend *blk, + BlockDriverState *bs, + bool flat, + Error **errp) { ImageInfo **p_image_info; ImageInfo *backing_info; @@ -235,8 +235,6 @@ static void bdrv_do_query_node_info(BlockDriverState *b= s, int ret; Error *err =3D NULL; =20 - aio_context_acquire(bdrv_get_aio_context(bs)); - size =3D bdrv_getlength(bs); if (size < 0) { error_setg_errno(errp, -size, "Can't get image size '%s'", @@ -249,7 +247,9 @@ static void bdrv_do_query_node_info(BlockDriverState *b= s, info->filename =3D g_strdup(bs->filename); info->format =3D g_strdup(bdrv_get_format_name(bs)); info->virtual_size =3D size; - info->actual_size =3D bdrv_get_allocated_file_size(bs); + bdrv_graph_co_rdlock(); + info->actual_size =3D bdrv_co_get_allocated_file_size(bs); + bdrv_graph_co_rdunlock(); info->has_actual_size =3D info->actual_size >=3D 0; if (bs->encrypted) { info->encrypted =3D true; @@ -305,7 +305,7 @@ static void bdrv_do_query_node_info(BlockDriverState *b= s, } =20 out: - aio_context_release(bdrv_get_aio_context(bs)); + return; } =20 /** @@ -668,7 +668,7 @@ bdrv_query_bds_stats(BlockDriverState *bs, bool blk_lev= el) return s; } =20 -BlockInfoList *qmp_query_block(Error **errp) +BlockInfoList *coroutine_fn qmp_query_block(Error **errp) { BlockInfoList *head =3D NULL, **p_next =3D &head; BlockBackend *blk; diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 47d63d26db..996895f417 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -65,6 +65,7 @@ ERST .help =3D "show info of one block device or all block device= s " "(-n: show named nodes; -v: show details)", .cmd =3D hmp_info_block, + .coroutine =3D true, }, =20 SRST diff --git a/include/block/block-hmp-cmds.h b/include/block/block-hmp-cmds.h index 71113cd7ef..6d9152318f 100644 --- a/include/block/block-hmp-cmds.h +++ b/include/block/block-hmp-cmds.h @@ -48,7 +48,7 @@ void hmp_eject(Monitor *mon, const QDict *qdict); =20 void hmp_qemu_io(Monitor *mon, const QDict *qdict); =20 -void hmp_info_block(Monitor *mon, const QDict *qdict); +void coroutine_fn hmp_info_block(Monitor *mon, const QDict *qdict); void hmp_info_blockstats(Monitor *mon, const QDict *qdict); void hmp_info_block_jobs(Monitor *mon, const QDict *qdict); void hmp_info_snapshots(Monitor *mon, const QDict *qdict); diff --git a/include/block/block-io.h b/include/block/block-io.h index f31e25cf56..43af816d75 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -87,7 +87,7 @@ int64_t co_wrapper_mixed_bdrv_rdlock bdrv_getlength(Block= DriverState *bs); int64_t coroutine_fn GRAPH_RDLOCK bdrv_co_get_allocated_file_size(BlockDriverState *bs); =20 -int64_t co_wrapper_mixed_bdrv_rdlock +int64_t co_wrapper_bdrv_rdlock bdrv_get_allocated_file_size(BlockDriverState *bs); =20 BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts, diff --git a/include/block/qapi.h b/include/block/qapi.h index 5cb0202791..c37cba2a09 100644 --- a/include/block/qapi.h +++ b/include/block/qapi.h @@ -30,14 +30,10 @@ #include "block/snapshot.h" #include "qapi/qapi-types-block-core.h" =20 -BlockDeviceInfo *coroutine_fn bdrv_co_block_device_info(BlockBackend *blk, - BlockDriverState *= bs, - bool flat, - Error **errp); -BlockDeviceInfo *co_wrapper bdrv_block_device_info(BlockBackend *blk, - BlockDriverState *bs, - bool flat, - Error **errp); +BlockDeviceInfo *coroutine_fn bdrv_block_device_info(BlockBackend *blk, + BlockDriverState *bs, + bool flat, + Error **errp); int bdrv_query_snapshot_info_list(BlockDriverState *bs, SnapshotInfoList **p_list, Error **errp); diff --git a/qapi/block-core.json b/qapi/block-core.json index 9d4c92f2c9..a78dc92493 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -838,7 +838,7 @@ # } ## { 'command': 'query-block', 'returns': ['BlockInfo'], - 'allow-preconfig': true } + 'allow-preconfig': true, 'coroutine': true } =20 ## # @BlockDeviceTimedStats: --=20 2.35.3 From nobody Thu May 2 22:29:31 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1686342104; cv=none; d=zohomail.com; s=zohoarc; b=Glhftufh7xqlpnm9gWD4U7k+j09r1+eD7UlNEwxXs3JiJI5rbokox03YyKV2Zu9+TRP8aPuplIaH35Iqif8FMoS78sRQOEyKZIEXDXd6SYmU2METhOH0AZAuDr+BvSGoob2LA/6tJQUi4xBvUdxQrMSHr/C5QPiqZlK5eRVLu0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686342104; 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=9BZOXurVoJ+AQ+tk5I7Ro4BE104/p5HQV3p7nnyxKDg=; b=XGzMfsb9IeNwSsC0MbQviUFk5605XR/ueaP3qbSYVI9ycwMqQAUHvGwJuf1VPhKl54aswfSfEloLVKEhnHnyBHL0dMUVFhuNpyNO7PE7Yeoc3pLI8zZc/GGfRU/s21bXuk2nAbyhaAVihGL8BMIkryiLeaFd1KYk12x0tsoVrxs= 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+importer2=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 1686342104016240.4691816882048; Fri, 9 Jun 2023 13:21:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7iaZ-00028k-Ue; Fri, 09 Jun 2023 16:20:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7iaU-00024h-RV; Fri, 09 Jun 2023 16:19:58 -0400 Received: from smtp-out1.suse.de ([2001:67c:2178:6::1c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7iaR-0000Ei-IM; Fri, 09 Jun 2023 16:19:58 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3E48321A8D; Fri, 9 Jun 2023 20:19:50 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5D755139C8; Fri, 9 Jun 2023 20:19:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ECi1CGOJg2R/SwAAMHmgww (envelope-from ); Fri, 09 Jun 2023 20:19:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686341990; h=from:from:reply-to: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=9BZOXurVoJ+AQ+tk5I7Ro4BE104/p5HQV3p7nnyxKDg=; b=XJWvEGfvxgdrFHTurk77YsAoO3y7QeQKBA0RGRxqWXNdl7WZW0jNMrpW0R2NrYXkIdsMQ1 e22ui/zTIZRyhyIlCGeytW1ZTw4YiL7K/a0w2XunX/fUhQyTQeK7MGocMZmucv0dP5So0I owB9Ced7S6jq2QxZa3WrteMfqZEfSAU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686341990; h=from:from:reply-to: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=9BZOXurVoJ+AQ+tk5I7Ro4BE104/p5HQV3p7nnyxKDg=; b=8eK4WI8X85VIZ0G9liv03V3tr2Uh10pK7yI32/HFdE6Umn40dGRn7lbxe9gZ1qQ9VwuCQL lYf4+i3g4ZwH5MBg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?UTF-8?q?Jo=C3=A3o=20Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake Subject: [PATCH v2 10/10] block: Add a thread-pool version of fstat Date: Fri, 9 Jun 2023 17:19:10 -0300 Message-Id: <20230609201910.12100-11-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230609201910.12100-1-farosas@suse.de> References: <20230609201910.12100-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:67c:2178:6::1c; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1686342104750100011 From: Jo=C3=A3o Silva The fstat call can take a long time to finish when running over NFS. Add a version of it that runs in the thread pool. Adapt one of its users, raw_co_get_allocated_file size to use the new version. That function is called via QMP under the qemu_global_mutex so it has a large chance of blocking VCPU threads in case it takes too long to finish. Reviewed-by: Claudio Fontana Signed-off-by: Jo=C3=A3o Silva Signed-off-by: Fabiano Rosas Reviewed-by: Hanna Czenczek --- block/file-posix.c | 40 +++++++++++++++++++++++++++++++++++++--- include/block/raw-aio.h | 4 +++- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index ac1ed54811..45232dc0f9 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -227,6 +227,9 @@ typedef struct RawPosixAIOData { struct { unsigned long op; } zone_mgmt; + struct { + struct stat *st; + } fstat; }; } RawPosixAIOData; =20 @@ -2614,6 +2617,34 @@ static void raw_close(BlockDriverState *bs) } } =20 +static int handle_aiocb_fstat(void *opaque) +{ + RawPosixAIOData *aiocb =3D opaque; + + if (fstat(aiocb->aio_fildes, aiocb->fstat.st) < 0) { + return -errno; + } + + return 0; +} + +static int coroutine_fn raw_co_fstat(BlockDriverState *bs, struct stat *st) +{ + BDRVRawState *s =3D bs->opaque; + RawPosixAIOData acb; + + acb =3D (RawPosixAIOData) { + .bs =3D bs, + .aio_fildes =3D s->fd, + .aio_type =3D QEMU_AIO_FSTAT, + .fstat =3D { + .st =3D st, + }, + }; + + return raw_thread_pool_submit(handle_aiocb_fstat, &acb); +} + /** * Truncates the given regular file @fd to @offset and, when growing, fill= s the * new space according to @prealloc. @@ -2853,11 +2884,14 @@ static int64_t coroutine_fn raw_co_getlength(BlockD= riverState *bs) static int64_t coroutine_fn raw_co_get_allocated_file_size(BlockDriverStat= e *bs) { struct stat st; - BDRVRawState *s =3D bs->opaque; + int ret; =20 - if (fstat(s->fd, &st) < 0) { - return -errno; + ret =3D raw_co_fstat(bs, &st); + + if (ret) { + return ret; } + return (int64_t)st.st_blocks * 512; } =20 diff --git a/include/block/raw-aio.h b/include/block/raw-aio.h index 0f63c2800c..1f2c678461 100644 --- a/include/block/raw-aio.h +++ b/include/block/raw-aio.h @@ -31,6 +31,7 @@ #define QEMU_AIO_ZONE_REPORT 0x0100 #define QEMU_AIO_ZONE_MGMT 0x0200 #define QEMU_AIO_ZONE_APPEND 0x0400 +#define QEMU_AIO_FSTAT 0x0800 #define QEMU_AIO_TYPE_MASK \ (QEMU_AIO_READ | \ QEMU_AIO_WRITE | \ @@ -42,7 +43,8 @@ QEMU_AIO_TRUNCATE | \ QEMU_AIO_ZONE_REPORT | \ QEMU_AIO_ZONE_MGMT | \ - QEMU_AIO_ZONE_APPEND) + QEMU_AIO_ZONE_APPEND | \ + QEMU_AIO_FSTAT) =20 /* AIO flags */ #define QEMU_AIO_MISALIGNED 0x1000 --=20 2.35.3