From nobody Tue Nov 26 06:37:18 2024 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; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709316801172234.83311117557196; Fri, 1 Mar 2024 10:13:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rg7NB-0004Tg-PN; Fri, 01 Mar 2024 13:12:42 -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 1rg7N9-0004Sq-IZ for qemu-devel@nongnu.org; Fri, 01 Mar 2024 13:12:39 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg7N7-00050H-EW for qemu-devel@nongnu.org; Fri, 01 Mar 2024 13:12:39 -0500 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 1EFA44E6013; Fri, 1 Mar 2024 19:12:31 +0100 (CET) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id YV6P0doiTqEV; Fri, 1 Mar 2024 19:12:29 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 332754E602B; Fri, 1 Mar 2024 19:12:29 +0100 (CET) X-Virus-Scanned: amavisd-new at eik.bme.hu From: BALATON Zoltan Subject: [PATCH] hmp: Add option to info qtree to omit details Date: Fri, 01 Mar 2024 19:05:22 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org Cc: Dr David Alan Gilbert , Paolo Bonzini , Eduardo Habkost , berrange@redhat.com Message-Id: <20240301181229.332754E602B@zero.eik.bme.hu> 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=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 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: 1709316802822100001 Content-Type: text/plain; charset="utf-8" The output of info qtree monitor command is very long. Add an option to print a brief overview omitting all the details. Signed-off-by: BALATON Zoltan Reviewed-by: Dr. David Alan Gilbert --- hmp-commands-info.hx | 6 +++--- system/qdev-monitor.c | 24 +++++++++++++----------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index da120f82a3..ad1b1306e3 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -540,9 +540,9 @@ ERST =20 { .name =3D "qtree", - .args_type =3D "", - .params =3D "", - .help =3D "show device tree", + .args_type =3D "brief:-b", + .params =3D "[-b]", + .help =3D "show device tree (-b: brief, omit properties)", .cmd =3D hmp_info_qtree, }, =20 diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index a13db763e5..d5cef36800 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -744,7 +744,6 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **er= rp) } =20 #define qdev_printf(fmt, ...) monitor_printf(mon, "%*s" fmt, indent, "", #= # __VA_ARGS__) -static void qbus_print(Monitor *mon, BusState *bus, int indent); =20 static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *pro= ps, int indent) @@ -784,13 +783,9 @@ static void bus_print_dev(BusState *bus, Monitor *mon,= DeviceState *dev, int ind static void qdev_print(Monitor *mon, DeviceState *dev, int indent) { ObjectClass *class; - BusState *child; NamedGPIOList *ngl; NamedClockList *ncl; =20 - qdev_printf("dev: %s, id \"%s\"\n", object_get_typename(OBJECT(dev)), - dev->id ? dev->id : ""); - indent +=3D 2; QLIST_FOREACH(ngl, &dev->gpios, node) { if (ngl->num_in) { qdev_printf("gpio-in \"%s\" %d\n", ngl->name ? ngl->name : "", @@ -814,12 +809,9 @@ static void qdev_print(Monitor *mon, DeviceState *dev,= int indent) class =3D object_class_get_parent(class); } while (class !=3D object_class_by_name(TYPE_DEVICE)); bus_print_dev(dev->parent_bus, mon, dev, indent); - QLIST_FOREACH(child, &dev->child_bus, sibling) { - qbus_print(mon, child, indent); - } } =20 -static void qbus_print(Monitor *mon, BusState *bus, int indent) +static void qbus_print(Monitor *mon, BusState *bus, int indent, bool detai= ls) { BusChild *kid; =20 @@ -827,16 +819,26 @@ static void qbus_print(Monitor *mon, BusState *bus, i= nt indent) indent +=3D 2; qdev_printf("type %s\n", object_get_typename(OBJECT(bus))); QTAILQ_FOREACH(kid, &bus->children, sibling) { + BusState *child_bus; DeviceState *dev =3D kid->child; - qdev_print(mon, dev, indent); + qdev_printf("dev: %s, id \"%s\"\n", object_get_typename(OBJECT(dev= )), + dev->id ? dev->id : ""); + if (details) { + qdev_print(mon, dev, indent + 2); + } + QLIST_FOREACH(child_bus, &dev->child_bus, sibling) { + qbus_print(mon, child_bus, indent + 2, details); + } } } #undef qdev_printf =20 void hmp_info_qtree(Monitor *mon, const QDict *qdict) { + bool brief =3D qdict_get_try_bool(qdict, "brief", false); + if (sysbus_get_default()) - qbus_print(mon, sysbus_get_default(), 0); + qbus_print(mon, sysbus_get_default(), 0, !brief); } =20 void hmp_info_qdm(Monitor *mon, const QDict *qdict) --=20 2.30.9