From nobody Sat Nov 15 14:09:02 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1751459589606166.4467149227313; Wed, 2 Jul 2025 05:33:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uWwdS-0005Qq-5U; Wed, 02 Jul 2025 08:32:22 -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 1uWwdP-0005Pc-ON; Wed, 02 Jul 2025 08:32:19 -0400 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uWwdL-0000Ra-5R; Wed, 02 Jul 2025 08:32:19 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id B493F4756F; Wed, 2 Jul 2025 14:32:10 +0200 (CEST) From: Fiona Ebner To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, eblake@redhat.com, armbru@redhat.com Subject: [PATCH v3 1/2] block/qapi: include child references in block device info Date: Wed, 2 Jul 2025 14:31:27 +0200 Message-ID: <20250702123204.325470-2-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250702123204.325470-1-f.ebner@proxmox.com> References: <20250702123204.325470-1-f.ebner@proxmox.com> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.237, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1751459592204116600 Content-Type: text/plain; charset="utf-8" In combination with using a throttle filter to enforce IO limits for a guest device, knowing the 'file' child of a block device can be useful. If the throttle filter is only intended for guest IO, block jobs should not also be limited by the throttle filter, so the block operations need to be done with the 'file' child of the top throttle node as the target. In combination with mirroring, the name of that child is not fixed. Another scenario is when unplugging a guest device after mirroring below a top throttle node, where the mirror target is added explicitly via blockdev-add. After mirroring, the target becomes the new 'file' child of the throttle node. For unplugging, both the top throttle node and the mirror target need to be deleted, because only implicitly added child nodes are deleted automatically, and the current 'file' child of the throttle node was explicitly added (as the mirror target). In other scenarios, it could be useful to follow the backing chain. Note that iotests 191 and 273 use _filter_img_info, so the 'children' information is filtered out there. Signed-off-by: Fiona Ebner --- Changes in v3: * Drop superfluous check for child->bs being non-NULL. * Make @node-name non-optional and expect it to be set. * Use 'block/qapi' rather than just 'block' as commit title prefix. block/qapi.c | 10 ++++++++++ qapi/block-core.json | 16 ++++++++++++++++ tests/qemu-iotests/184.out | 8 ++++++++ 3 files changed, 34 insertions(+) diff --git a/block/qapi.c b/block/qapi.c index 2c50a6bf3b..e08a1e970f 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -51,6 +51,8 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, ImageInfo *backing_info; BlockDriverState *backing; BlockDeviceInfo *info; + BlockdevChildList **children_list_tail; + BdrvChild *child; =20 if (!bs->drv) { error_setg(errp, "Block device %s is ejected", bs->node_name); @@ -77,6 +79,14 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *bl= k, info->node_name =3D g_strdup(bs->node_name); } =20 + children_list_tail =3D &info->children; + QLIST_FOREACH(child, &bs->children, next) { + BlockdevChild *child_ref =3D g_new0(BlockdevChild, 1); + child_ref->child =3D g_strdup(child->name); + child_ref->node_name =3D g_strdup(child->bs->node_name); + QAPI_LIST_APPEND(children_list_tail, child_ref); + } + backing =3D bdrv_cow_bs(bs); if (backing) { info->backing_file =3D g_strdup(backing->filename); diff --git a/qapi/block-core.json b/qapi/block-core.json index 1df6644f0d..3e720af5ad 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -461,6 +461,19 @@ 'direct': 'bool', 'no-flush': 'bool' } } =20 +## +# @BlockdevChild: +# +# @child: The name of the child, for example 'file' or 'backing'. +# +# @node-name: The name of the child's block driver node. +# +# Since: 10.1 +## +{ 'struct': 'BlockdevChild', + 'data': { 'child': 'str', + 'node-name': 'str' } } + ## # @BlockDeviceInfo: # @@ -486,6 +499,8 @@ # @backing_file_depth: number of files in the backing file chain # (since: 1.2) # +# @children: Information about child block nodes. (since: 10.1) +# # @active: true if the backend is active; typical cases for inactive backe= nds # are on the migration source instance after migration completes and o= n the # destination before it completes. (since: 10.0) @@ -560,6 +575,7 @@ { 'struct': 'BlockDeviceInfo', 'data': { 'file': 'str', '*node-name': 'str', 'ro': 'bool', 'drv': 'str', '*backing_file': 'str', 'backing_file_depth': 'int', + 'children': ['BlockdevChild'], 'active': 'bool', 'encrypted': 'bool', 'detect_zeroes': 'BlockdevDetectZeroesOptions', 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int', diff --git a/tests/qemu-iotests/184.out b/tests/qemu-iotests/184.out index 52692b6b3b..ef99bb2e9a 100644 --- a/tests/qemu-iotests/184.out +++ b/tests/qemu-iotests/184.out @@ -41,6 +41,12 @@ Testing: }, "iops_wr": 0, "ro": false, + "children": [ + { + "node-name": "disk0", + "child": "file" + } + ], "node-name": "throttle0", "backing_file_depth": 1, "drv": "throttle", @@ -69,6 +75,8 @@ Testing: }, "iops_wr": 0, "ro": false, + "children": [ + ], "node-name": "disk0", "backing_file_depth": 0, "drv": "null-co", --=20 2.47.2