From patchwork Mon May 31 12:41:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 54089 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 22283B7D67 for ; Mon, 31 May 2010 22:56:21 +1000 (EST) Received: from localhost ([127.0.0.1]:59515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJ4XJ-0003Le-Sa for incoming@patchwork.ozlabs.org; Mon, 31 May 2010 08:56:10 -0400 Received: from [140.186.70.92] (port=41803 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJ4Hk-0006Rn-Gj for qemu-devel@nongnu.org; Mon, 31 May 2010 08:40:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OJ4Hj-0007Lj-31 for qemu-devel@nongnu.org; Mon, 31 May 2010 08:40:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28494) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OJ4Hi-0007Lc-Q0 for qemu-devel@nongnu.org; Mon, 31 May 2010 08:40:03 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4VCe2dQ019580 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 31 May 2010 08:40:02 -0400 Received: from localhost (dhcp1-88.pnq.redhat.com [10.65.193.88]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4VCe0uJ009860; Mon, 31 May 2010 08:40:01 -0400 From: Amit Shah To: qemu list Date: Mon, 31 May 2010 18:11:31 +0530 Message-Id: <383cd43ef87e1a699648301657902d3fe20f2ec5.1275309375.git.amit.shah@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Amit Shah , Juan Quintela , Markus Armbruster , Gerd Hoffmann Subject: [Qemu-devel] [PATCH 5/5] qdev: Add new '-device help' option, shows all devices and properties 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 The new '-device help' option shows all the devices that are registered with qdev and prints out all the properties each device has, along with the description for each property. This is useful in creating automatic documentation for all the options that we have and support. Signed-off-by: Amit Shah --- hw/qdev.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 89ba986..4be2f66 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -151,7 +151,7 @@ static int set_property(const char *name, const char *value, void *opaque) return 0; } -static int show_device_props(const char *driver) +static int show_device_props(const char *driver, const char *prefix) { DeviceInfo *info; Property *prop; @@ -161,6 +161,10 @@ static int show_device_props(const char *driver) return 0; } + if (!prefix) { + prefix = ""; + } + for (prop = info->props; prop && prop->name; prop++) { /* * TODO Properties without a parser are just for dirty hacks. @@ -171,7 +175,7 @@ static int show_device_props(const char *driver) if (!prop->info->parse) { continue; /* no way to set it, don't show */ } - error_printf("%s.%s=%s, %s\n", info->name, prop->name, + error_printf("%s%s.%s=%s, %s\n", prefix, info->name, prop->name, prop->info->name, prop->desc ?: ""); } return 1; @@ -183,12 +187,15 @@ int qdev_device_help(QemuOpts *opts) DeviceInfo *info; driver = qemu_opt_get(opts, "driver"); - if (driver && !strcmp(driver, "?")) { + if (driver && (!strcmp(driver, "?") || !strcmp(driver, "help"))) { for (info = device_info_list; info != NULL; info = info->next) { if (info->no_user) { continue; /* not available, don't show */ } qdev_print_devinfo(info); + if (!strcmp(driver, "help")) { + show_device_props(info->name, "\t"); + } } return 1; } @@ -197,7 +204,7 @@ int qdev_device_help(QemuOpts *opts) return 0; } - return show_device_props(driver); + return show_device_props(driver, NULL); } DeviceState *qdev_device_add(QemuOpts *opts)