From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoVYn-0004ao-CM for qemu-devel@nongnu.org; Tue, 10 Jul 2012 04:12:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SoVYl-0003le-EN for qemu-devel@nongnu.org; Tue, 10 Jul 2012 04:12:40 -0400 Received: from cantor2.suse.de ([195.135.220.15]:51472 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoVYl-0003lV-4K for qemu-devel@nongnu.org; Tue, 10 Jul 2012 04:12:39 -0400 Message-ID: <4FFBE3F0.3040300@suse.de> Date: Tue, 10 Jul 2012 10:12:32 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1341900967-4344-1-git-send-email-qemulist@gmail.com> <1341900967-4344-2-git-send-email-qemulist@gmail.com> In-Reply-To: <1341900967-4344-2-git-send-email-qemulist@gmail.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/5] qdev: introduce qdev_create_kid(Object *parent, const char *type) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Ping Fan Cc: Blue Swirl , Jan Kiszka , qemu-devel@nongnu.org, Anthony Liguori Am 10.07.2012 08:16, schrieb Liu Ping Fan: > DeviceState can be created as kid of DeviceState/CPUState, not neccesar= y > attached to bus. This will be helpful to simulate the real hardware > submodule which sits inside package. >=20 > Signed-off-by: Liu Ping Fan > --- > hw/qdev.c | 28 ++++++++++++++++++++++++++++ > hw/qdev.h | 1 + > 2 files changed, 29 insertions(+), 0 deletions(-) >=20 > diff --git a/hw/qdev.c b/hw/qdev.c > index af54467..d2100a1 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -26,6 +26,7 @@ > this API directly. */ > =20 > #include "net.h" > +#include "qemu/cpu.h" > #include "qdev.h" > #include "sysemu.h" > #include "error.h" > @@ -145,6 +146,33 @@ DeviceState *qdev_try_create(BusState *bus, const = char *type) > return dev; > } > =20 > +DeviceState *qdev_create_kid(Object *parent, const char *type) > +{ > + DeviceState *dev; > + assert(parent); > + > + if (object_class_by_name(type) =3D=3D NULL) { > + return NULL; > + } > + > + if (object_is_type_str(parent, TYPE_BUS)) { This is only introduced in patch 2, no? Andreas > + return qdev_create(BUS(parent), type); > + } > + > + if (!object_is_type_str(parent, TYPE_DEVICE) > + || !object_is_type_str(parent, TYPE_CPU)) { > + return NULL; > + } > + > + dev =3D DEVICE(object_new(type)); > + if (!dev) { > + return NULL; > + } > + object_property_add_child(OBJECT(parent), type, OBJECT(dev), NULL)= ; > + > + return dev; > +} > + > /* Initialize a device. Device properties should be set before callin= g > this function. IRQs and MMIO regions should be connected/mapped af= ter > calling this function. > diff --git a/hw/qdev.h b/hw/qdev.h > index f4683dc..aecc69e 100644 > --- a/hw/qdev.h > +++ b/hw/qdev.h > @@ -154,6 +154,7 @@ typedef struct GlobalProperty { > =20 > DeviceState *qdev_create(BusState *bus, const char *name); > DeviceState *qdev_try_create(BusState *bus, const char *name); > +DeviceState *qdev_create_kid(Object *parent, const char *type); > bool qdev_exists(const char *name); > int qdev_device_help(QemuOpts *opts); > DeviceState *qdev_device_add(QemuOpts *opts); >=20 --=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