From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WB5V7-0001Yi-3W for qemu-devel@nongnu.org; Wed, 05 Feb 2014 11:39:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WB5Uy-0004Cl-Lz for qemu-devel@nongnu.org; Wed, 05 Feb 2014 11:39:01 -0500 Received: from mail-qa0-x22a.google.com ([2607:f8b0:400d:c00::22a]:36692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WB5Uy-0004Cf-Hk for qemu-devel@nongnu.org; Wed, 05 Feb 2014 11:38:52 -0500 Received: by mail-qa0-f42.google.com with SMTP id k4so916540qaq.1 for ; Wed, 05 Feb 2014 08:38:52 -0800 (PST) Sender: Paolo Bonzini Message-ID: <52F26915.3090104@redhat.com> Date: Wed, 05 Feb 2014 17:38:45 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1391609340-11023-1-git-send-email-afaerber@suse.de> In-Reply-To: <1391609340-11023-1-git-send-email-afaerber@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Peter Crosthwaite Il 05/02/2014 15:09, Andreas Färber 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) == NULL) { > + oc = object_class_by_name(type); > + if (oc == NULL) { > return NULL; > } > + dc = DEVICE_CLASS(oc); > dev = DEVICE(object_new(type)); > if (!dev) { > return NULL; > } > > - if (!bus) { > + if (!bus && dc->bus_type && strcmp(dc->bus_type, "System") == 0) { Should you check instead if dev is-a TYPE_SYSBUS_DEVICE? Does this also leave the nand device out of info qtree, or is it still dumped? Paolo > bus = sysbus_get_default(); > } > > - qdev_set_parent_bus(dev, bus); > - object_unref(OBJECT(dev)); > + if (bus != NULL) { > + qdev_set_parent_bus(dev, bus); > + object_unref(OBJECT(dev)); > + } > return dev; > } > >