From patchwork Thu Oct 21 06:37:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 68526 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 03A6E1007D3 for ; Thu, 21 Oct 2010 17:46:33 +1100 (EST) Received: from localhost ([127.0.0.1]:54401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8ov0-0002aU-7w for incoming@patchwork.ozlabs.org; Thu, 21 Oct 2010 02:46:30 -0400 Received: from [140.186.70.92] (port=44584 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8omE-0006If-My for qemu-devel@nongnu.org; Thu, 21 Oct 2010 02:37:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P8omD-0001b6-KI for qemu-devel@nongnu.org; Thu, 21 Oct 2010 02:37:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51637) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P8omD-0001aw-Bf for qemu-devel@nongnu.org; Thu, 21 Oct 2010 02:37:25 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9L6bOVZ015675 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 21 Oct 2010 02:37:24 -0400 Received: from playa.redhat.com (vpn-6-82.tlv.redhat.com [10.35.6.82]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9L6bKDf006086 for ; Thu, 21 Oct 2010 02:37:23 -0400 From: Alon Levy To: qemu-devel@nongnu.org Date: Thu, 21 Oct 2010 08:37:20 +0200 Message-Id: <1287643040-21200-3-git-send-email-alevy@redhat.com> In-Reply-To: <1287643040-21200-1-git-send-email-alevy@redhat.com> References: <1287643040-21200-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 2/2] monitor info qtree: add optional bus id X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org --- hw/qdev.c | 17 ++++++++++++++--- hw/qdev.h | 2 +- monitor.c | 34 +++++++++++++++++++++++++++++----- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index d669a9d..e6cf7af 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -774,10 +774,21 @@ static void qbus_print(Monitor *mon, BusState *bus, int indent) } #undef qdev_printf -void do_info_qtree(Monitor *mon) +void do_info_qtree(Monitor *mon, const QDict *qdict) { - if (main_system_bus) - qbus_print(mon, main_system_bus, 0); + const char *id; + BusState *bus = main_system_bus; + DeviceState *dev; + + if (qdict != NULL && (id = qdict_get_try_str(qdict, "id")) != NULL) { + bus = qbus_find_recursive(main_system_bus, id, NULL); + if (bus == NULL && (dev = qdev_find_recursive(main_system_bus, id)) != NULL) { + bus = dev->parent_bus; + } + } + if (bus) { + qbus_print(mon, bus, 0); + } } void do_info_qdm(Monitor *mon) diff --git a/hw/qdev.h b/hw/qdev.h index 214066e..c08a525 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -183,7 +183,7 @@ DeviceState *qdev_find_recursive(BusState *bus, const char *id); /*** monitor commands ***/ -void do_info_qtree(Monitor *mon); +void do_info_qtree(Monitor *mon, const QDict *qdict); void do_info_qdm(Monitor *mon); int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data); int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data); diff --git a/monitor.c b/monitor.c index 7d1d3b1..69ec651 100644 --- a/monitor.c +++ b/monitor.c @@ -640,6 +640,26 @@ static void user_async_info_handler(Monitor *mon, const mon_cmd_t *cmd) } } +static const char* do_info_sub_args_type(const QDict *qdict) +{ + const mon_cmd_t *cmd; + const char *item = qdict_get_try_str(qdict, "item"); + + if (!item) { + return NULL; + } + for (cmd = info_cmds; cmd->name != NULL; cmd++) { + if (compare_cmd(item, cmd->name)) { + break; + } + } + + if (cmd->name == NULL) { + return NULL; + } + return cmd->args_type; +} + static void do_info(Monitor *mon, const QDict *qdict) { const mon_cmd_t *cmd; @@ -669,7 +689,11 @@ static void do_info(Monitor *mon, const QDict *qdict) qobject_decref(info_data); } } else { - cmd->mhandler.info(mon); + if (cmd->params != NULL && cmd->params[0] != 0) { + cmd->mhandler.cmd(mon, qdict); + } else { + cmd->mhandler.info(mon); + } } return; @@ -2586,10 +2610,10 @@ static const mon_cmd_t info_cmds[] = { }, { .name = "qtree", - .args_type = "", - .params = "", - .help = "show device tree", - .mhandler.info = do_info_qtree, + .args_type = "id:s?", + .params = "device", + .help = "show device tree (optional root bus/device)", + .mhandler.cmd = do_info_qtree, }, { .name = "qdm",