From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:32987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RsE9s-0002xt-EJ for qemu-devel@nongnu.org; Tue, 31 Jan 2012 08:54:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RsE9k-00026P-E3 for qemu-devel@nongnu.org; Tue, 31 Jan 2012 08:54:04 -0500 Received: from cantor2.suse.de ([195.135.220.15]:46672 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RsE9k-00026D-4w for qemu-devel@nongnu.org; Tue, 31 Jan 2012 08:53:56 -0500 Message-ID: <4F27F1E8.8060103@suse.de> Date: Tue, 31 Jan 2012 14:51:36 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1327957741-5842-1-git-send-email-aliguori@us.ibm.com> <1327957741-5842-7-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1327957741-5842-7-git-send-email-aliguori@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 07/23] qdev: kill off DeviceInfo list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Paolo Bonzini , qemu-devel@nongnu.org, Peter Maydell Am 30.01.2012 22:08, schrieb Anthony Liguori: > Teach the various bits of code that need to walk through available devi= ces to > do so via QOM. >=20 > 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) !=3D 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); > } > =20 > -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 =3D opaque; Due to this... > + > + dc =3D (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 c= har *value, void *opaque) > int qdev_device_help(QemuOpts *opts) > { > const char *driver; > - DeviceInfo *info; > Property *prop; > + ObjectClass *klass; > + DeviceClass *info; > =20 > driver =3D qemu_opt_get(opts, "driver"); > if (driver && !strcmp(driver, "?")) { > - for (info =3D device_info_list; info !=3D NULL; info =3D info-= >next) { > - if (info->no_user) { > - continue; /* not available, don't show */ > - } > - qdev_print_devinfo(info); > - } > + bool show_no_user =3D false; > + object_class_foreach(qdev_print_devinfo, &show_no_user); This... > return 1; > } > =20 > @@ -297,10 +273,11 @@ int qdev_device_help(QemuOpts *opts) > return 0; > } > =20 > - info =3D qdev_find_info(NULL, driver); > - if (!info) { > + klass =3D object_class_by_name(driver); > + if (!klass) { > return 0; > } > + info =3D DEVICE_CLASS(klass); > =20 > for (prop =3D 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=3D%s\n", info->name, prop->name, > + error_printf("%s.%s=3D%s\n", driver, prop->name, > prop->info->legacy_name ?: prop->info->name); > } > for (prop =3D 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=3D%s\n", info->name, prop->name, > + error_printf("%s.%s=3D%s\n", driver, prop->name, > prop->info->legacy_name ?: prop->info->name); > } > return 1; > @@ -1085,11 +1062,7 @@ void do_info_qtree(Monitor *mon) > =20 > void do_info_qdm(Monitor *mon) > { > - DeviceInfo *info; > - > - for (info =3D device_info_list; info !=3D NULL; info =3D info->nex= t) { > - 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 > } > =20 > int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data= ) --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg