From: "Andreas Färber" <afaerber@suse.de>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [Qemu-devel] [PATCH 07/23] qdev: kill off DeviceInfo list
Date: Tue, 31 Jan 2012 14:51:36 +0100 [thread overview]
Message-ID: <4F27F1E8.8060103@suse.de> (raw)
In-Reply-To: <1327957741-5842-7-git-send-email-aliguori@us.ibm.com>
Am 30.01.2012 22:08, schrieb Anthony Liguori:
> Teach the various bits of code that need to walk through available devices to
> do so via QOM.
>
> Signed-off-by: Anthony Liguori
(Email missing.)
NACK. This introduces broken code, see below.
> bool qdev_exists(const char *name)
> {
> - return !!qdev_find_info(NULL, name);
> + return !!object_class_by_name(name);
> }
Minor nit: I'd find object_class_by_name(name) != NULL easier to read
than double negation.
> @@ -245,17 +213,28 @@ DeviceState *qdev_try_create(BusState *bus, const char *name)
> return qdev_create_from_info(bus, name);
> }
>
> -static void qdev_print_devinfo(DeviceInfo *info)
> +static void qdev_print_devinfo(ObjectClass *klass, void *opaque)
> {
> - error_printf("name \"%s\", bus %s",
> - info->name, info->bus_info->name);
> - if (info->alias) {
> - error_printf(", alias \"%s\"", info->alias);
> + DeviceClass *dc;
> + bool *show_no_user = opaque;
Due to this...
> +
> + dc = (DeviceClass *)object_class_dynamic_cast(klass, TYPE_DEVICE);
...and this, ...
> +
> + if (!dc || (show_no_user && !*show_no_user && dc->no_user)) {
> + return;
> }
> - if (info->desc) {
> - error_printf(", desc \"%s\"", info->desc);
> +
> + error_printf("name \"%s\"", object_class_get_name(klass));
> + if (dc->bus_info) {
> + error_printf(", bus %s", dc->bus_info->name);
> }
> - if (info->no_user) {
> + if (dc->alias) {
> + error_printf(", alias \"%s\"", dc->alias);
> + }
> + if (dc->desc) {
> + error_printf(", desc \"%s\"", dc->desc);
> + }
> + if (dc->no_user) {
> error_printf(", no-user");
> }
> error_printf("\n");
> @@ -279,17 +258,14 @@ static int set_property(const char *name, const char *value, void *opaque)
> int qdev_device_help(QemuOpts *opts)
> {
> const char *driver;
> - DeviceInfo *info;
> Property *prop;
> + ObjectClass *klass;
> + DeviceClass *info;
>
> driver = qemu_opt_get(opts, "driver");
> if (driver && !strcmp(driver, "?")) {
> - for (info = device_info_list; info != NULL; info = info->next) {
> - if (info->no_user) {
> - continue; /* not available, don't show */
> - }
> - qdev_print_devinfo(info);
> - }
> + bool show_no_user = false;
> + object_class_foreach(qdev_print_devinfo, &show_no_user);
This...
> return 1;
> }
>
> @@ -297,10 +273,11 @@ int qdev_device_help(QemuOpts *opts)
> return 0;
> }
>
> - info = qdev_find_info(NULL, driver);
> - if (!info) {
> + klass = object_class_by_name(driver);
> + if (!klass) {
> return 0;
> }
> + info = DEVICE_CLASS(klass);
>
> for (prop = info->props; prop && prop->name; prop++) {
> /*
> @@ -312,14 +289,14 @@ int qdev_device_help(QemuOpts *opts)
> if (!prop->info->parse) {
> continue; /* no way to set it, don't show */
> }
> - error_printf("%s.%s=%s\n", info->name, prop->name,
> + error_printf("%s.%s=%s\n", driver, prop->name,
> prop->info->legacy_name ?: prop->info->name);
> }
> for (prop = info->bus_info->props; prop && prop->name; prop++) {
> if (!prop->info->parse) {
> continue; /* no way to set it, don't show */
> }
> - error_printf("%s.%s=%s\n", info->name, prop->name,
> + error_printf("%s.%s=%s\n", driver, prop->name,
> prop->info->legacy_name ?: prop->info->name);
> }
> return 1;
> @@ -1085,11 +1062,7 @@ void do_info_qtree(Monitor *mon)
>
> void do_info_qdm(Monitor *mon)
> {
> - DeviceInfo *info;
> -
> - for (info = device_info_list; info != NULL; info = info->next) {
> - qdev_print_devinfo(info);
> - }
> + object_class_foreach(qdev_print_devinfo, NULL);
...and this is broken, as pointed out before:
http://patchwork.ozlabs.org/patch/138396/
Easiest would be to reorder 11/23 before this one so that we don't
introduce a broken, bloated user of foreach in the first place.
Otherwise looking good.
Andreas
> }
>
> int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
next prev parent reply other threads:[~2012-01-31 13:54 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-30 21:08 [Qemu-devel] [PATCH 01/23] usb-hid: simplify class initialization a bit Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 03/23] qdev: make DeviceInfo private Anthony Liguori
2012-01-30 22:31 ` Andreas Färber
2012-01-30 21:08 ` [Qemu-devel] [PATCH 04/23] qdev: remove info from class Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 05/23] qdev: allow classes to overload qdev functions Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 06/23] qdev: refactor device creation to allow bus_info to be set only in class Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 07/23] qdev: kill off DeviceInfo list Anthony Liguori
2012-01-31 13:51 ` Andreas Färber [this message]
2012-01-30 21:08 ` [Qemu-devel] [PATCH 08/23] qdev: register all types natively through QEMU Object Model Anthony Liguori
2012-01-30 22:29 ` Peter Maydell
2012-01-30 22:43 ` Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 09/23] qdev: kill of DeviceInfo Anthony Liguori
2012-01-31 13:34 ` Andreas Färber
2012-02-01 19:46 ` Peter Maydell
2012-02-01 19:56 ` Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 10/23] qdev: remove baked in notion of aliases Anthony Liguori
2012-01-31 7:44 ` Paolo Bonzini
2012-01-30 21:08 ` [Qemu-devel] [PATCH 11/23] qom: allow object_class_foreach to take additional parameters to refine search Anthony Liguori
2012-01-31 13:42 ` Andreas Färber
2012-01-30 21:08 ` [Qemu-devel] [PATCH 12/23] qom: add new command to search for types Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 13/23] qdev: split out common init to instance_init Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 14/23] qdev: refactor away qdev_create_from_info Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 15/23] qdev: split out UI portions into a new function Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 16/23] qdev: nuke qdev_init_chardev() Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 17/23] qom: move properties from qdev to object Anthony Liguori
2012-01-31 7:46 ` Paolo Bonzini
2012-02-01 20:01 ` Anthony Liguori
2012-02-01 20:33 ` Paolo Bonzini
2012-01-30 21:08 ` [Qemu-devel] [PATCH 18/23] qom: accept any compatible type when setting a link property Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 19/23] qdev: implement cleanup logic in finalize Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 20/23] info qdm: do not require a parent_bus to be set Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 21/23] object: sure up reference counting Anthony Liguori
2012-01-31 7:49 ` Paolo Bonzini
2012-02-01 19:47 ` Peter Maydell
2012-02-01 19:55 ` Anthony Liguori
2012-01-30 21:09 ` [Qemu-devel] [PATCH 22/23] container: make a decendent of Object Anthony Liguori
2012-01-31 7:50 ` Paolo Bonzini
2012-01-31 9:21 ` Andreas Färber
2012-01-31 9:31 ` Paolo Bonzini
2012-02-01 19:48 ` Peter Maydell
2012-01-30 21:09 ` [Qemu-devel] [PATCH 23/23] not-for-upstream: fix device_del Anthony Liguori
2012-01-30 21:16 ` [Qemu-devel] [PATCH 00/23] qom: use Type system to register all devices Anthony Liguori
2012-01-30 22:46 ` Anthony Liguori
2012-02-01 19:55 ` Peter Maydell
2012-02-01 20:10 ` Anthony Liguori
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=4F27F1E8.8060103@suse.de \
--to=afaerber@suse.de \
--cc=aliguori@us.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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.