From: Markus Armbruster <armbru@redhat.com>
To: Amit Shah <amit.shah@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>,
qemu list <qemu-devel@nongnu.org>,
Juan Quintela <quintela@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 5/5] qdev: Add new '-device help' option, shows all devices and properties
Date: Mon, 07 Jun 2010 16:43:05 +0200 [thread overview]
Message-ID: <m34oheaop2.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <383cd43ef87e1a699648301657902d3fe20f2ec5.1275309375.git.amit.shah@redhat.com> (Amit Shah's message of "Mon, 31 May 2010 18:11:31 +0530")
I like PATCH 1-3/5, but this one needs discussion.
Amit Shah <amit.shah@redhat.com> writes:
> 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 <amit.shah@redhat.com>
> ---
> hw/qdev.c | 15 +++++++++++----
> 1 files changed, 11 insertions(+), 4 deletions(-)
Documentation update missing: qemu-options.hx
> 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 = "";
> + }
> +
Just make the caller pass "" instead of NULL.
> 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;
> }
There is "-device \?" and "-device help", but the user interface
provides no clue about the difference between them.
"-device help" loses when we ever pick up a device model with name
"help". Not that "?" was a particularly smart choice...
Do we really need two kinds of help output? Where the second is
basically the same as "-device FOO,\?" for all FOO? Is that convenience
worth the extra UI complexity?
Doing it in the shell isn't exactly hard:
$ for i in `qemu -device \? 2>&1 | awk -F \" '{ print $2 }'`; do qemu -device $i,\?; done
> @@ -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)
next prev parent reply other threads:[~2010-06-07 14:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-31 12:41 [Qemu-devel] [PATCH 0/5] Add '-device help' output for device params and help text Amit Shah
2010-05-31 12:41 ` [Qemu-devel] [PATCH 1/5] qdev: Add a description field for qdev properties for documentation Amit Shah
2010-05-31 12:41 ` [Qemu-devel] [PATCH 2/5] virtio-serial: Add description fields for qdev properties Amit Shah
2010-05-31 12:41 ` [Qemu-devel] [PATCH 3/5] net.h: Add description fields for qdev properites Amit Shah
2010-05-31 12:41 ` [Qemu-devel] [PATCH 4/5] qdev: Re-arrange code to have device properties shown from own function Amit Shah
2010-05-31 12:41 ` [Qemu-devel] [PATCH 5/5] qdev: Add new '-device help' option, shows all devices and properties Amit Shah
2010-06-07 14:43 ` Markus Armbruster [this message]
2010-06-08 5:13 ` Amit Shah
2010-06-07 16:09 ` [Qemu-devel] [PATCH 0/5] Add '-device help' output for device params and help text Anthony Liguori
2010-06-08 5:21 ` Amit Shah
2010-06-14 16:55 ` Anthony Liguori
2010-06-15 9:17 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m34oheaop2.fsf@blackfin.pond.sub.org \
--to=armbru@redhat.com \
--cc=amit.shah@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.