From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl4Yv-0003Gj-Hk for qemu-devel@nongnu.org; Tue, 18 Dec 2012 16:18:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tl4Yr-0004df-Ov for qemu-devel@nongnu.org; Tue, 18 Dec 2012 16:18:53 -0500 Received: from cantor2.suse.de ([195.135.220.15]:60168 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl4Yr-0004dJ-FT for qemu-devel@nongnu.org; Tue, 18 Dec 2012 16:18:49 -0500 Message-ID: <50D0DDB1.3070704@suse.de> Date: Tue, 18 Dec 2012 22:18:41 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1354740282-20679-1-git-send-email-pbonzini@redhat.com> <1354740282-20679-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1354740282-20679-2-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 01/11] qdev: export and use qbus_init List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org Am 05.12.2012 21:44, schrieb Paolo Bonzini: > BusState subclasses need to do their own allocation because > qbus_create_inplace calls object_initialize (which wipes out the > "free" callback). This patch separates the initialization of the objec= t > (object_initialize) from its insertion in the qdev tree (qbus_realize);= to > do so, it moves the remaining bits of qbus_create_inplace to qbus_reali= ze > and export it as qbus_init. >=20 > Signed-off-by: Paolo Bonzini The code movements look okay, but I wonder if we can resolve the "init" ambivalence somehow? As in instance_init, which is being called internally by object_new() and object_initialize(). You're right that it's not realize either. Maybe qbus_setup()? Andreas > --- > hw/qdev-core.h | 1 + > hw/qdev.c | 18 +++++++----------- > 2 files changed, 8 insertions(+), 11 deletions(-) >=20 > diff --git a/hw/qdev-core.h b/hw/qdev-core.h > index fff7f0f..18f5f73 100644 > --- a/hw/qdev-core.h > +++ b/hw/qdev-core.h > @@ -180,6 +180,7 @@ DeviceState *qdev_find_recursive(BusState *bus, con= st char *id); > typedef int (qbus_walkerfn)(BusState *bus, void *opaque); > typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque); > =20 > +void qbus_init(BusState *bus, DeviceState *parent, const char *name); > void qbus_create_inplace(BusState *bus, const char *typename, > DeviceState *parent, const char *name); > BusState *qbus_create(const char *typename, DeviceState *parent, const= char *name); > diff --git a/hw/qdev.c b/hw/qdev.c > index 788b4da..e758131 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -403,14 +403,16 @@ DeviceState *qdev_find_recursive(BusState *bus, c= onst char *id) > return NULL; > } > =20 > -static void qbus_realize(BusState *bus) > +void qbus_init(BusState *bus, DeviceState *parent, const char *name) > { > const char *typename =3D object_get_typename(OBJECT(bus)); > char *buf; > int i,len; > =20 > - if (bus->name) { > - /* use supplied name */ > + bus->parent =3D parent; > + > + if (name) { > + bus->name =3D g_strdup(name); > } else if (bus->parent && bus->parent->id) { > /* parent device has id -> use it for bus name */ > len =3D strlen(bus->parent->id) + 16; > @@ -443,10 +445,7 @@ void qbus_create_inplace(BusState *bus, const char= *typename, > DeviceState *parent, const char *name) > { > object_initialize(bus, typename); > - > - bus->parent =3D parent; > - bus->name =3D name ? g_strdup(name) : NULL; > - qbus_realize(bus); > + qbus_init(bus, parent, name); > } > =20 > BusState *qbus_create(const char *typename, DeviceState *parent, const= char *name) > @@ -454,10 +453,7 @@ BusState *qbus_create(const char *typename, Device= State *parent, const char *nam > BusState *bus; > =20 > bus =3D BUS(object_new(typename)); > - > - bus->parent =3D parent; > - bus->name =3D name ? g_strdup(name) : NULL; > - qbus_realize(bus); > + qbus_init(bus, parent, name); > =20 > return bus; > } >=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