From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WB5cc-000189-4B for qemu-devel@nongnu.org; Wed, 05 Feb 2014 11:46:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WB5cU-0007CJ-PY for qemu-devel@nongnu.org; Wed, 05 Feb 2014 11:46:46 -0500 Received: from cantor2.suse.de ([195.135.220.15]:38374 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WB5cU-0007CF-IB for qemu-devel@nongnu.org; Wed, 05 Feb 2014 11:46:38 -0500 Message-ID: <52F26AEB.9040100@suse.de> Date: Wed, 05 Feb 2014 17:46:35 +0100 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1391609340-11023-1-git-send-email-afaerber@suse.de> <52F26915.3090104@redhat.com> In-Reply-To: <52F26915.3090104@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] qdev: Fix qdev_try_create() for bus-less devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Peter Crosthwaite Am 05.02.2014 17:38, schrieb Paolo Bonzini: > Il 05/02/2014 15:09, Andreas F=C3=A4rber ha scritto: >> diff --git a/hw/core/qdev.c b/hw/core/qdev.c >> index 82a9123..14c8765 100644 >> --- a/hw/core/qdev.c >> +++ b/hw/core/qdev.c >> @@ -131,21 +131,27 @@ DeviceState *qdev_create(BusState *bus, const >> char *name) >> DeviceState *qdev_try_create(BusState *bus, const char *type) >> { >> DeviceState *dev; >> + ObjectClass *oc; >> + DeviceClass *dc; >> >> - if (object_class_by_name(type) =3D=3D NULL) { >> + oc =3D object_class_by_name(type); >> + if (oc =3D=3D NULL) { >> return NULL; >> } >> + dc =3D DEVICE_CLASS(oc); >> dev =3D DEVICE(object_new(type)); >> if (!dev) { >> return NULL; >> } >> >> - if (!bus) { >> + if (!bus && dc->bus_type && strcmp(dc->bus_type, "System") =3D=3D= 0) { >=20 > Should you check instead if dev is-a TYPE_SYSBUS_DEVICE? Hmm, that would catch TYPE_SYS_BUS_DEVICE-derived types as well, which might in theory override bus_type. The ugly thing here is the cyclic dependency betwen qdev and sysbus, therefore no TYPE_SYSTEM_BUS. > Does this also leave the nand device out of info qtree, or is it still > dumped? As I pointed out several times already, devices that are not on a bus are generally *not* printed by info qtree. It depends on the old qbus concept. Therefore info qtree is not of much use anymore and should be dropped in favor of the qom-list and qom-get operations, which get us all devices and all properties. I had once attached a qom-tree for that and need to put that into a proper patch. Best before the next question pops up. :) Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3=BC= rnberg