Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C321B606A31E for ; Fri, 27 Nov 2026 17:13:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=J2L5Jcjq Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xWzUQ-00075g-CH; Fri, 27 Nov 2026 12:12:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWzUN-00070C-Sx; Fri, 27 Nov 2026 12:11:59 -0500 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWzUM-0004hz-7U; Fri, 27 Nov 2026 12:11:59 -0500 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id EAA1940D41; Fri, 27 Nov 2026 17:11:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 858451F000C1; Fri, 27 Nov 2026 17:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795799516; bh=voyPR/bXe4YfB68mL9g+Rgv89OkC7HH0gv/QNpaxG1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=J2L5JcjqTJeK/ZEogeLrsvb11uCfJAIuhv2ggcVkARVpY0OK0cBkcawU+M66woOvv y37bdIAVKE9+7UucX2A+B4d4zIytvZuxRUk7gxvKn37aUkX76hZ0+3sQQfBsP/P6IR ypkj3qphP2uqAerRTY57t3l7KTY8UrRdk5NfK+QvFmUKbVr/KXrJRrVQnQu9ZzOULT iFt+V0cwYofVbrOrNbRwDu3GaLozgkz3mtNfI8XyxmCr0JZ2+Yt77ZNmpvxoOmMiWn 1whZ0yo2C2EYVexatVbFs3xqc2R1xoEPpPYobBEDUf/nPgdKMEgVbD7SHKRblPpk1U b/umtNiaEn8eg== From: Niklas Cassel To: qemu-devel@nongnu.org Cc: Damien Le Moal , Stefan Hajnoczi , Pierrick Bouvier , "Michael S. Tsirkin" , Hanna Reitz , Markus Armbruster , Kevin Wolf , Eric Blake , qemu-block@nongnu.org, Sam Li , Paolo Bonzini , Fam Zheng , Jeuk Kim , Daejun Park , Niklas Cassel Subject: [PATCH v19 10/11] block: add accessors for the zone model, capacity and open zone limit Date: Fri, 27 Nov 2026 18:11:07 +0100 Message-ID: <20261127171108.3256778-11-cassel@kernel.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261127171108.3256778-1-cassel@kernel.org> References: <20261127171108.3256778-1-cassel@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2600:3c0a:e001:78e:0:1991:8:25; envelope-from=cassel@kernel.org; helo=sea.source.kernel.org 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, 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_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Add the block-backend accessors blk_get_zone_model(), blk_get_zone_capacity() and blk_get_max_open_zones(), which report the zoned model, the zone capacity and the maximum number of open zones of the backing device, mirroring the existing blk_get_zone_size(). This lets device models query the zoned geometry without dereferencing BlockDriverState internals. Signed-off-by: Niklas Cassel --- block/block-backend.c | 33 +++++++++++++++++++++++++++++++ include/system/block-backend-io.h | 3 +++ 2 files changed, 36 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index 656c0aed67..397ec9ed5a 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2338,6 +2338,39 @@ uint64_t blk_get_zone_size(BlockBackend *blk) return bs ? bs->bl.zone_size : 0; } +/* + * Returns the zoned model of @blk (BLK_Z_HM, BLK_Z_HA), or BLK_Z_NONE if + * @blk does not present zoned geometry. + */ +BlockZoneModel blk_get_zone_model(BlockBackend *blk) +{ + BlockDriverState *bs = blk_bs(blk); + IO_CODE(); + return bs ? bs->bl.zoned : BLK_Z_NONE; +} + +/* + * Returns the maximum number of simultaneously open zones for a zoned + * backend, or 0 if there is no limit or @blk is not zoned. + */ +uint32_t blk_get_max_open_zones(BlockBackend *blk) +{ + BlockDriverState *bs = blk_bs(blk); + IO_CODE(); + return bs ? bs->bl.max_open_zones : 0; +} + +/* + * Returns how many bytes of each zone of @blk can be written (the zone + * capacity), or 0 if that is not known. + */ +uint64_t blk_get_zone_capacity(BlockBackend *blk) +{ + BlockDriverState *bs = blk_bs(blk); + IO_CODE(); + return bs ? bs->bl.zone_capacity : 0; +} + /* Returns the optimal write zeroes alignment, in bytes; guaranteed nonzero */ uint32_t blk_get_pwrite_zeroes_alignment(BlockBackend *blk) { diff --git a/include/system/block-backend-io.h b/include/system/block-backend-io.h index 78d410b8df..7c958843b4 100644 --- a/include/system/block-backend-io.h +++ b/include/system/block-backend-io.h @@ -122,6 +122,9 @@ uint32_t blk_get_pwrite_zeroes_alignment(BlockBackend *blk); uint32_t blk_get_max_transfer(BlockBackend *blk); uint64_t blk_get_max_hw_transfer(BlockBackend *blk); uint64_t blk_get_zone_size(BlockBackend *blk); +BlockZoneModel blk_get_zone_model(BlockBackend *blk); +uint32_t blk_get_max_open_zones(BlockBackend *blk); +uint64_t blk_get_zone_capacity(BlockBackend *blk); int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in, BlockBackend *blk_out, int64_t off_out, -- 2.56.1