From nobody Sat Feb 7 08:44:16 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1768920571; cv=none; d=zohomail.com; s=zohoarc; b=bUSEuXC82jndE2jsdSNVpXvZwUFanwTYWboW1vXiXSJgP6fqn+aXcjeygNyUNghAHSAIUTi2X5XaY0SppHV2mrEd/D2+BO0WszF1d8EW+8G/H3Sxa+P9K7vD5BLYg/tf6uu/QzuG0bkry4+bzREPVR6RN4IumDk8k6cTi9fvAQc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768920571; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HG1rGVQqePPLE6IDyoIRVlwYVulYX3EC6KP3mE4Zk34=; b=V0C4GW4xEhMBpXtehdabK4v1mOQy9AVUIOWhR15bhE+Zm4rzoIdb04gyMt6g1wmQpqju7uEEETa9h7d091zNqSlQqi0y7N5Byil0kcgzSB8OXErmiE9/iiW0dmENX9tf0KfCXV4T4hjz/nt7YJD9Fz9OM+2k7KKl+iXwzuhl/Nk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17689205719131020.1912186810432; Tue, 20 Jan 2026 06:49:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1viD1x-0004rv-W5; Tue, 20 Jan 2026 09:48:30 -0500 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 1viCzw-00049i-2P for qemu-devel@nongnu.org; Tue, 20 Jan 2026 09:46:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1viCzt-0007NZ-Kw for qemu-devel@nongnu.org; Tue, 20 Jan 2026 09:46:23 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-9-KH2y7BJXPH2t1_GXwrglgg-1; Tue, 20 Jan 2026 09:46:04 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9D0E619560B5; Tue, 20 Jan 2026 14:46:03 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.22.5]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BF2ED18004D8; Tue, 20 Jan 2026 14:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768920368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HG1rGVQqePPLE6IDyoIRVlwYVulYX3EC6KP3mE4Zk34=; b=H3orIQUOmXQsC8/2La8pNZ3947FEAXIojkWfE1iK617xh1X0ReZm5ndMa+msyCBkYJ2e2E EpHnHcbdNYhHHFMKrlAGgk2vxQ+RF/nJ52WnarQgGs467JI7ZGpVL0Tim5oj+F0715kbr/ FJ8s7FwUKhBL47zDHCELaHLIFlcJdvw= X-MC-Unique: KH2y7BJXPH2t1_GXwrglgg-1 X-Mimecast-MFC-AGG-ID: KH2y7BJXPH2t1_GXwrglgg_1768920363 From: Peter Krempa To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Eric Blake , Markus Armbruster Subject: [PATCH v2 1/2] block: Wire up 'flat' mode also for 'query-block' Date: Tue, 20 Jan 2026 15:45:56 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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 (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=170.10.129.124; envelope-from=pkrempa@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.087, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable 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-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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1768920573971158500 Content-Type: text/plain; charset="utf-8" From: Peter Krempa 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 Acked-by: Markus Armbruster --- block/monitor/block-hmp-cmds.c | 4 ++-- block/qapi.c | 9 +++++---- qapi/block-core.json | 7 +++++++ ui/cocoa.m | 2 +- 4 files changed, 15 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 *qd= ict) /* Then try adding all block devices. If one fails, close all and * exit. */ - block_list =3D qmp_query_block(NULL); + block_list =3D qmp_query_block(false, false, NULL); for (info =3D block_list; info; info =3D 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 =3D qmp_query_block(NULL); + block_list =3D qmp_query_block(false, false, NULL); } else { block_list =3D NULL; } diff --git a/block/qapi.c b/block/qapi.c index 27e0ac6a32..3688d0e713 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 =3D g_malloc0(sizeof(*info)); BlockDriverState *bs =3D blk_bs(blk); @@ -488,7 +488,7 @@ bdrv_query_info(BlockBackend *blk, BlockInfo **p_info, = Error **errp) } if (bs && bs->drv) { - info->inserted =3D bdrv_block_device_info(blk, bs, false, errp); + info->inserted =3D bdrv_block_device_info(blk, bs, flat, errp); if (info->inserted =3D=3D NULL) { goto err; } @@ -698,11 +698,12 @@ bdrv_query_bds_stats(BlockDriverState *bs, bool blk_l= evel) return s; } -BlockInfoList *qmp_query_block(Error **errp) +BlockInfoList *qmp_query_block(bool has_flat, bool flat, Error **errp) { BlockInfoList *head =3D NULL, **p_next =3D &head; BlockBackend *blk; Error *local_err =3D NULL; + bool return_flat =3D has_flat && flat; GRAPH_RDLOCK_GUARD_MAINLOOP(); @@ -714,7 +715,7 @@ BlockInfoList *qmp_query_block(Error **errp) } info =3D g_malloc0(sizeof(*info)); - bdrv_query_info(blk, &info->value, &local_err); + bdrv_query_info(blk, return_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..f55cf01dca 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -855,6 +855,12 @@ # # Get a list of `BlockInfo` for all virtual block devices. # +# @flat: Omit the nested data about backing image (Omitted are +# contents of 'backing-image' key of the 'ImageInfo' struct +# which is returned as 'image' key of 'BlockDeviceInfo' struct +# returned as 'inserted' key in 'BlockInfo' struct returned +# by this command). 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 +951,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 =3D qmp_query_block(NULL); + currentDevice =3D qmp_query_block(false, false, NULL); pointerToFree =3D currentDevice; menu =3D [[[NSApp mainMenu] itemWithTitle:@"Machine"] submenu]; --=20 2.52.0 From nobody Sat Feb 7 08:44:16 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1768920542; cv=none; d=zohomail.com; s=zohoarc; b=g87e5HfGiHqB/gz+rqgdgR55X66Keqb00NrmbFTEWQDMlYUhqp5gmycYHPXDqdhqcUsBE2hVvBan3pClWBVqr6UA6DkTYiKoON9t7OhVNs8yAHYJbfhw6BjAkkOKQvGz6HBKueeKGFnfD/UNEYBFaZ7VQ8h7I5jPBWiuu57+uB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768920542; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rtvOs6oqUv/P4O+hxq7j2SLb0tEOZS5BMGbK2lAS/OA=; b=ckxygzQ0GyKOvjYA3WnwBQGVYCumbABpVFu3dRiAuTF6YrPUw1MXCpWMFMy07Degq/vhuJqFpnRreu3w9U8WoeAFtLxXFj6ts4ej7Ki6yMYMZOUENUDyIUDgqHDcMsh3oMfUtAJnZJQLgUQGMqdCg2168H6v9KZ7zq7Qd/n6Etc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1768920542919482.0376227580613; Tue, 20 Jan 2026 06:49:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1viD1x-0004s6-VE; Tue, 20 Jan 2026 09:48:29 -0500 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 1viCzx-00049m-6h for qemu-devel@nongnu.org; Tue, 20 Jan 2026 09:46:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1viCzv-0007Nh-3y for qemu-devel@nongnu.org; Tue, 20 Jan 2026 09:46:24 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-84-0MHIKvp9PxShdvNJTGDjUQ-1; Tue, 20 Jan 2026 09:46:06 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 17F431954B06; Tue, 20 Jan 2026 14:46:06 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.22.5]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 102451800993; Tue, 20 Jan 2026 14:46:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768920370; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rtvOs6oqUv/P4O+hxq7j2SLb0tEOZS5BMGbK2lAS/OA=; b=VuZyJ0p0tsrtfcSdHD0woOzcUOdTFlReYEaamPG+DhyX6DHVeuT8YaZyizjHwG3FOpGYHk laiOJZk0YfEL7/J0PhesLDTdigHlFpW73a0To+/xUk2/BaA8hyzwCURhXJMNz40C5hipv9 Whyyl2xGcZR6aS9OzNG3RkzxJ8QDwbg= X-MC-Unique: 0MHIKvp9PxShdvNJTGDjUQ-1 X-Mimecast-MFC-AGG-ID: 0MHIKvp9PxShdvNJTGDjUQ_1768920366 From: Peter Krempa To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Eric Blake , Markus Armbruster Subject: [PATCH v2 2/2] hmp_nbd_server_start: Don't ask for backing image data Date: Tue, 20 Jan 2026 15:45:57 +0100 Message-ID: <3d34ff5e7166abf4fd9d9b9b324cde3a1c2b00ee.1768920111.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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 (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=170.10.133.124; envelope-from=pkrempa@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.087, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable 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-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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1768920543716158500 Content-Type: text/plain; charset="utf-8" From: Peter Krempa '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 Reviewed-by: Eric Blake --- 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 *qd= ict) /* Then try adding all block devices. If one fails, close all and * exit. */ - block_list =3D qmp_query_block(false, false, NULL); + block_list =3D qmp_query_block(true, true, NULL); for (info =3D block_list; info; info =3D info->next) { if (!info->value->inserted) { --=20 2.52.0