* [PATCH v4 0/2] block: Wire up 'flat' mode also for 'query-block'
@ 2026-02-04 13:15 Peter Krempa
2026-02-04 13:15 ` [PATCH v4 1/2] " Peter Krempa
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Peter Krempa @ 2026-02-04 13:15 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Kevin Wolf, Hanna Reitz, Eric Blake,
Markus Armbruster
v4:
- No need to check 'has_flat', as qemu doesn't have warnings about
unused variables active (Markus)
- Doc wording tweak (Markus)
v3:
- Doc wording tweak (Eric)
v2:
- More descriptive docs text for the new QAPI option (Markus; new
wording not approved)
- use new options in hmp_nbd_server_start to avoid fetching unused
backing image info, impossible in 'info block' worker (Markus)
Peter Krempa (2):
block: Wire up 'flat' mode also for 'query-block'
hmp_nbd_server_start: Don't ask for backing image data
block/monitor/block-hmp-cmds.c | 4 ++--
block/qapi.c | 8 ++++----
qapi/block-core.json | 5 +++++
ui/cocoa.m | 2 +-
4 files changed, 12 insertions(+), 7 deletions(-)
--
2.52.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4 1/2] block: Wire up 'flat' mode also for 'query-block'
2026-02-04 13:15 [PATCH v4 0/2] block: Wire up 'flat' mode also for 'query-block' Peter Krempa
@ 2026-02-04 13:15 ` Peter Krempa
2026-02-04 13:15 ` [PATCH v4 2/2] hmp_nbd_server_start: Don't ask for backing image data Peter Krempa
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Peter Krempa @ 2026-02-04 13:15 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Kevin Wolf, Hanna Reitz, Eric Blake,
Markus Armbruster
From: Peter Krempa <pkrempa@redhat.com>
Some time ago (commit facda5443f5a8) I've added 'flat' mode (which
omits 'backing-image' key in reply) to 'query-named-block-nodes' to
minimize the size of the returned JSON for deeper backing chains.
While 'query-block' behaved slightly better it turns out that in libvirt
we do call 'query-block' to figure out some information about the
block device (e.g. throttling info) but we don't look at the backing
chain itself.
Wire up 'flat' for 'query-block' so that libvirt can ask for an
abbreviated output. The implementation is much simpler as the internals
are shared with 'query-named-block-nodes'.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
---
block/monitor/block-hmp-cmds.c | 4 ++--
block/qapi.c | 8 ++++----
qapi/block-core.json | 5 +++++
ui/cocoa.m | 2 +-
4 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index 3391cee4d2..bde25bb588 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -422,7 +422,7 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
/* Then try adding all block devices. If one fails, close all and
* exit.
*/
- block_list = qmp_query_block(NULL);
+ block_list = qmp_query_block(false, false, NULL);
for (info = block_list; info; info = info->next) {
if (!info->value->inserted) {
@@ -741,7 +741,7 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
/* Print BlockBackend information */
if (!nodes) {
- block_list = qmp_query_block(NULL);
+ block_list = qmp_query_block(false, false, NULL);
} else {
block_list = NULL;
}
diff --git a/block/qapi.c b/block/qapi.c
index 27e0ac6a32..eabfbfc258 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -456,7 +456,7 @@ fail:
/* @p_info will be set only on success. */
static void GRAPH_RDLOCK
-bdrv_query_info(BlockBackend *blk, BlockInfo **p_info, Error **errp)
+bdrv_query_info(BlockBackend *blk, bool flat, BlockInfo **p_info, Error **errp)
{
BlockInfo *info = g_malloc0(sizeof(*info));
BlockDriverState *bs = blk_bs(blk);
@@ -488,7 +488,7 @@ bdrv_query_info(BlockBackend *blk, BlockInfo **p_info, Error **errp)
}
if (bs && bs->drv) {
- info->inserted = bdrv_block_device_info(blk, bs, false, errp);
+ info->inserted = bdrv_block_device_info(blk, bs, flat, errp);
if (info->inserted == NULL) {
goto err;
}
@@ -698,7 +698,7 @@ bdrv_query_bds_stats(BlockDriverState *bs, bool blk_level)
return s;
}
-BlockInfoList *qmp_query_block(Error **errp)
+BlockInfoList *qmp_query_block(bool has_flat, bool flat, Error **errp)
{
BlockInfoList *head = NULL, **p_next = &head;
BlockBackend *blk;
@@ -714,7 +714,7 @@ BlockInfoList *qmp_query_block(Error **errp)
}
info = g_malloc0(sizeof(*info));
- bdrv_query_info(blk, &info->value, &local_err);
+ bdrv_query_info(blk, flat, &info->value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
g_free(info);
diff --git a/qapi/block-core.json b/qapi/block-core.json
index b82af74256..b66bf316e2 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -855,6 +855,10 @@
#
# Get a list of `BlockInfo` for all virtual block devices.
#
+# @flat: Omit nested data about the backing image, i.e. `BlockInfo`
+# member 'inserted.image.backing-image' will be absent.
+# Default is false. (Since 11.0)
+#
# Returns: a list describing each virtual block device. Filter nodes
# that were created implicitly are skipped over.
#
@@ -945,6 +949,7 @@
# }
##
{ 'command': 'query-block', 'returns': ['BlockInfo'],
+ 'data': { '*flat': 'bool' },
'allow-preconfig': true }
##
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 23b7a736d7..5b21fe3aea 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1849,7 +1849,7 @@ static void addRemovableDevicesMenuItems(void)
BlockInfoList *currentDevice, *pointerToFree;
NSString *deviceName;
- currentDevice = qmp_query_block(NULL);
+ currentDevice = qmp_query_block(false, false, NULL);
pointerToFree = currentDevice;
menu = [[[NSApp mainMenu] itemWithTitle:@"Machine"] submenu];
--
2.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 2/2] hmp_nbd_server_start: Don't ask for backing image data
2026-02-04 13:15 [PATCH v4 0/2] block: Wire up 'flat' mode also for 'query-block' Peter Krempa
2026-02-04 13:15 ` [PATCH v4 1/2] " Peter Krempa
@ 2026-02-04 13:15 ` Peter Krempa
2026-02-12 16:13 ` [PATCH v4 0/2] block: Wire up 'flat' mode also for 'query-block' Peter Krempa
2026-02-24 13:17 ` Kevin Wolf
3 siblings, 0 replies; 5+ messages in thread
From: Peter Krempa @ 2026-02-04 13:15 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Kevin Wolf, Hanna Reitz, Eric Blake,
Markus Armbruster
From: Peter Krempa <pkrempa@redhat.com>
'hmp_nbd_server_start' uses only the device name from the data returned
from 'qmp_query_block', thus no backing file information. Use the new
options to suppress asking for the unused parts to save on resources.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
block/monitor/block-hmp-cmds.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index bde25bb588..1fd28d59eb 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -422,7 +422,7 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
/* Then try adding all block devices. If one fails, close all and
* exit.
*/
- block_list = qmp_query_block(false, false, NULL);
+ block_list = qmp_query_block(true, true, NULL);
for (info = block_list; info; info = info->next) {
if (!info->value->inserted) {
--
2.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v4 0/2] block: Wire up 'flat' mode also for 'query-block'
2026-02-04 13:15 [PATCH v4 0/2] block: Wire up 'flat' mode also for 'query-block' Peter Krempa
2026-02-04 13:15 ` [PATCH v4 1/2] " Peter Krempa
2026-02-04 13:15 ` [PATCH v4 2/2] hmp_nbd_server_start: Don't ask for backing image data Peter Krempa
@ 2026-02-12 16:13 ` Peter Krempa
2026-02-24 13:17 ` Kevin Wolf
3 siblings, 0 replies; 5+ messages in thread
From: Peter Krempa @ 2026-02-12 16:13 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Kevin Wolf, Hanna Reitz, Eric Blake,
Markus Armbruster
On Wed, Feb 04, 2026 at 14:15:42 +0100, Peter Krempa wrote:
> v4:
> - No need to check 'has_flat', as qemu doesn't have warnings about
> unused variables active (Markus)
> - Doc wording tweak (Markus)
>
> v3:
> - Doc wording tweak (Eric)
>
> v2:
> - More descriptive docs text for the new QAPI option (Markus; new
> wording not approved)
> - use new options in hmp_nbd_server_start to avoid fetching unused
> backing image info, impossible in 'info block' worker (Markus)
>
> Peter Krempa (2):
> block: Wire up 'flat' mode also for 'query-block'
> hmp_nbd_server_start: Don't ask for backing image data
Ping?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4 0/2] block: Wire up 'flat' mode also for 'query-block'
2026-02-04 13:15 [PATCH v4 0/2] block: Wire up 'flat' mode also for 'query-block' Peter Krempa
` (2 preceding siblings ...)
2026-02-12 16:13 ` [PATCH v4 0/2] block: Wire up 'flat' mode also for 'query-block' Peter Krempa
@ 2026-02-24 13:17 ` Kevin Wolf
3 siblings, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2026-02-24 13:17 UTC (permalink / raw)
To: Peter Krempa
Cc: qemu-devel, qemu-block, Hanna Reitz, Eric Blake,
Markus Armbruster
Am 04.02.2026 um 14:15 hat Peter Krempa geschrieben:
> v4:
> - No need to check 'has_flat', as qemu doesn't have warnings about
> unused variables active (Markus)
> - Doc wording tweak (Markus)
>
> v3:
> - Doc wording tweak (Eric)
>
> v2:
> - More descriptive docs text for the new QAPI option (Markus; new
> wording not approved)
> - use new options in hmp_nbd_server_start to avoid fetching unused
> backing image info, impossible in 'info block' worker (Markus)
>
> Peter Krempa (2):
> block: Wire up 'flat' mode also for 'query-block'
> hmp_nbd_server_start: Don't ask for backing image data
Thanks, applied to the block branch.
If you'd like the feature to keep working in future versions, I'd
recommend a follow-up patch that makes qemu-iotests print the result
with flat=true in some test case.
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-02-24 13:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-04 13:15 [PATCH v4 0/2] block: Wire up 'flat' mode also for 'query-block' Peter Krempa
2026-02-04 13:15 ` [PATCH v4 1/2] " Peter Krempa
2026-02-04 13:15 ` [PATCH v4 2/2] hmp_nbd_server_start: Don't ask for backing image data Peter Krempa
2026-02-12 16:13 ` [PATCH v4 0/2] block: Wire up 'flat' mode also for 'query-block' Peter Krempa
2026-02-24 13:17 ` Kevin Wolf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.