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 4B879606A33C for ; Tue, 24 Nov 2026 08:57:34 +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=azLbq4AZ Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xVmKN-00083l-3P; Tue, 24 Nov 2026 03:56:39 -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 1xVmJz-0007wo-23; Tue, 24 Nov 2026 03:56:21 -0500 Received: from tor.source.kernel.org ([172.105.4.254]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xVmJx-0008Gi-KQ; Tue, 24 Nov 2026 03:56:14 -0500 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id B41B662512; Tue, 24 Nov 2026 08:56:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 491881F000ED; Tue, 24 Nov 2026 08:56:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795510572; bh=voyPR/bXe4YfB68mL9g+Rgv89OkC7HH0gv/QNpaxG1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=azLbq4AZQ4z+xdspMKAnNQCz1DyvlHGun6vs75ZSOweMEcAMwqWduTwTLnDHCgfX+ ws+7x+baFbA/UxS5ji2qa/5Tu+gSsuoa7SSVUAp4xS3HGAyLQk1EmUuexG1j8lLGjw wmmBKWLGFZfQ/vG97XREQMIWF2xAXdNGE2dP8Zy3Vv9nyqeJAmY99diUuzl66IhKOu UgkQICML+dGDT8S7fSCbSIxF0h2ro3WNBxGCOf+z4zo6DxKtnKnIIxXfl6vNHU+L3+ royGV/esny43siKIoBE6BIEjGST1MYMAKcaZsIqk+NYu2b3KQPMhpzNIpqP40BbK+U edqZLgvzy8CYA== 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 v18 09/10] block: add accessors for the zone model, capacity and open zone limit Date: Tue, 24 Nov 2026 09:55:28 +0100 Message-ID: <20261124085529.1537572-10-cassel@kernel.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261124085529.1537572-1-cassel@kernel.org> References: <20261124085529.1537572-1-cassel@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=172.105.4.254; envelope-from=cassel@kernel.org; helo=tor.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