From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36216) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WB69q-000488-5E for qemu-devel@nongnu.org; Wed, 05 Feb 2014 12:21:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WB69i-0003Lu-Pq for qemu-devel@nongnu.org; Wed, 05 Feb 2014 12:21:06 -0500 Received: from cantor2.suse.de ([195.135.220.15]:39068 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WB69i-0003Lo-Ie for qemu-devel@nongnu.org; Wed, 05 Feb 2014 12:20:58 -0500 Message-ID: <52F272F7.1080309@suse.de> Date: Wed, 05 Feb 2014 18:20:55 +0100 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1391609340-11023-1-git-send-email-afaerber@suse.de> <52F26915.3090104@redhat.com> <52F26AEB.9040100@suse.de> In-Reply-To: <52F26AEB.9040100@suse.de> 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:46, schrieb Andreas F=C3=A4rber: > 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) { >> >> Should you check instead if dev is-a TYPE_SYSBUS_DEVICE? >=20 > Hmm, that would catch TYPE_SYS_BUS_DEVICE-derived types as well, which > might in theory override bus_type. >=20 > The ugly thing here is the cyclic dependency betwen qdev and sysbus, > therefore no TYPE_SYSTEM_BUS. BTW this patch became optional due to the one-line nand fix (which also does not show the device in legacy info qtree), but I am still in favor of merging this or a variation thereof to avoid future troubles. Andreas >=20 >> Does this also leave the nand device out of info qtree, or is it still >> dumped? >=20 > 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. :) >=20 > Andreas >=20 --=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