* [PATCH v3 0/2] block/qapi: include child references in block device info
@ 2025-07-02 12:31 Fiona Ebner
2025-07-02 12:31 ` [PATCH v3 1/2] " Fiona Ebner
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Fiona Ebner @ 2025-07-02 12:31 UTC (permalink / raw)
To: qemu-block; +Cc: qemu-devel, kwolf, hreitz, eblake, armbru
Changes in v3:
* Add patch to make @node-name non-optional for @BlockDeviceInfo.
* 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.
Fiona Ebner (2):
block/qapi: include child references in block device info
block/qapi: make @node-name in @BlockDeviceInfo non-optional
block/qapi.c | 12 ++++++++++--
qapi/block-core.json | 18 +++++++++++++++++-
tests/qemu-iotests/184.out | 8 ++++++++
3 files changed, 35 insertions(+), 3 deletions(-)
--
2.47.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3 1/2] block/qapi: include child references in block device info
2025-07-02 12:31 [PATCH v3 0/2] block/qapi: include child references in block device info Fiona Ebner
@ 2025-07-02 12:31 ` Fiona Ebner
2025-07-02 12:31 ` [PATCH v3 2/2] block/qapi: make @node-name in @BlockDeviceInfo non-optional Fiona Ebner
2025-07-14 15:11 ` [PATCH v3 0/2] block/qapi: include child references in block device info Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Fiona Ebner @ 2025-07-02 12:31 UTC (permalink / raw)
To: qemu-block; +Cc: qemu-devel, kwolf, hreitz, eblake, armbru
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 <f.ebner@proxmox.com>
---
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;
if (!bs->drv) {
error_setg(errp, "Block device %s is ejected", bs->node_name);
@@ -77,6 +79,14 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
info->node_name = g_strdup(bs->node_name);
}
+ children_list_tail = &info->children;
+ QLIST_FOREACH(child, &bs->children, next) {
+ BlockdevChild *child_ref = g_new0(BlockdevChild, 1);
+ child_ref->child = g_strdup(child->name);
+ child_ref->node_name = g_strdup(child->bs->node_name);
+ QAPI_LIST_APPEND(children_list_tail, child_ref);
+ }
+
backing = bdrv_cow_bs(bs);
if (backing) {
info->backing_file = 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' } }
+##
+# @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 backends
# are on the migration source instance after migration completes and on 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",
--
2.47.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3 2/2] block/qapi: make @node-name in @BlockDeviceInfo non-optional
2025-07-02 12:31 [PATCH v3 0/2] block/qapi: include child references in block device info Fiona Ebner
2025-07-02 12:31 ` [PATCH v3 1/2] " Fiona Ebner
@ 2025-07-02 12:31 ` Fiona Ebner
2025-07-14 15:11 ` [PATCH v3 0/2] block/qapi: include child references in block device info Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Fiona Ebner @ 2025-07-02 12:31 UTC (permalink / raw)
To: qemu-block; +Cc: qemu-devel, kwolf, hreitz, eblake, armbru
Since commit 15489c769b ("block: auto-generated node-names"), if the
node name of a block driver state is not explicitly specified, it
will be auto-generated.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
New in v3.
block/qapi.c | 4 +---
qapi/block-core.json | 2 +-
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/block/qapi.c b/block/qapi.c
index e08a1e970f..12fbf8d1b7 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -75,9 +75,7 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
.no_flush = !!(bs->open_flags & BDRV_O_NO_FLUSH),
};
- if (bs->node_name[0]) {
- info->node_name = g_strdup(bs->node_name);
- }
+ info->node_name = g_strdup(bs->node_name);
children_list_tail = &info->children;
QLIST_FOREACH(child, &bs->children, next) {
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 3e720af5ad..9d36927fc1 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -573,7 +573,7 @@
# Since: 0.14
##
{ 'struct': 'BlockDeviceInfo',
- 'data': { 'file': 'str', '*node-name': 'str', 'ro': 'bool', 'drv': 'str',
+ 'data': { 'file': 'str', 'node-name': 'str', 'ro': 'bool', 'drv': 'str',
'*backing_file': 'str', 'backing_file_depth': 'int',
'children': ['BlockdevChild'],
'active': 'bool', 'encrypted': 'bool',
--
2.47.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3 0/2] block/qapi: include child references in block device info
2025-07-02 12:31 [PATCH v3 0/2] block/qapi: include child references in block device info Fiona Ebner
2025-07-02 12:31 ` [PATCH v3 1/2] " Fiona Ebner
2025-07-02 12:31 ` [PATCH v3 2/2] block/qapi: make @node-name in @BlockDeviceInfo non-optional Fiona Ebner
@ 2025-07-14 15:11 ` Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Kevin Wolf @ 2025-07-14 15:11 UTC (permalink / raw)
To: Fiona Ebner; +Cc: qemu-block, qemu-devel, hreitz, eblake, armbru
Am 02.07.2025 um 14:31 hat Fiona Ebner geschrieben:
> Changes in v3:
> * Add patch to make @node-name non-optional for @BlockDeviceInfo.
> * 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.
>
> Fiona Ebner (2):
> block/qapi: include child references in block device info
> block/qapi: make @node-name in @BlockDeviceInfo non-optional
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-07-14 16:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-02 12:31 [PATCH v3 0/2] block/qapi: include child references in block device info Fiona Ebner
2025-07-02 12:31 ` [PATCH v3 1/2] " Fiona Ebner
2025-07-02 12:31 ` [PATCH v3 2/2] block/qapi: make @node-name in @BlockDeviceInfo non-optional Fiona Ebner
2025-07-14 15:11 ` [PATCH v3 0/2] block/qapi: include child references in block device info Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).