From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:52228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFkuL-000485-9j for qemu-devel@nongnu.org; Thu, 05 Apr 2012 07:31:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SFku9-00071u-V0 for qemu-devel@nongnu.org; Thu, 05 Apr 2012 07:31:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFku9-00071d-N8 for qemu-devel@nongnu.org; Thu, 05 Apr 2012 07:31:05 -0400 Message-ID: <4F7D8271.9000203@redhat.com> Date: Thu, 05 Apr 2012 13:30:57 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <4F732C0F.8030005@redhat.com> <1333624906-7870-1-git-send-email-afaerber@suse.de> In-Reply-To: <1333624906-7870-1-git-send-email-afaerber@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] qom: Refine container_get() to allow using a custom root List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= Cc: qemu-devel@nongnu.org, Anthony Liguori Il 05/04/2012 13:21, Andreas F=C3=A4rber ha scritto: > Specify the root to search from as argument. This avoids hardcoding > "/machine" in some places and makes it more flexible. >=20 > Signed-off-by: Andreas F=C3=A4rber > Cc: Paolo Bonzini > Cc: Anthony Liguori Looks good, thanks. Paolo > --- > hw/qdev-monitor.c | 4 ++-- > hw/qdev.c | 7 ++++--- > include/qemu/object.h | 3 ++- > qom/container.c | 4 ++-- > 4 files changed, 10 insertions(+), 8 deletions(-) >=20 > diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c > index 4783366..67f296b 100644 > --- a/hw/qdev-monitor.c > +++ b/hw/qdev-monitor.c > @@ -180,7 +180,7 @@ static Object *qdev_get_peripheral(void) > static Object *dev; > =20 > if (dev =3D=3D NULL) { > - dev =3D container_get("/machine/peripheral"); > + dev =3D container_get(qdev_get_machine(), "/peripheral"); > } > =20 > return dev; > @@ -191,7 +191,7 @@ static Object *qdev_get_peripheral_anon(void) > static Object *dev; > =20 > if (dev =3D=3D NULL) { > - dev =3D container_get("/machine/peripheral-anon"); > + dev =3D container_get(qdev_get_machine(), "/peripheral-anon"); > } > =20 > return dev; > diff --git a/hw/qdev.c b/hw/qdev.c > index 0d3c0fc..efa4c5d 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -157,8 +157,9 @@ int qdev_init(DeviceState *dev) > static int unattached_count =3D 0; > gchar *name =3D g_strdup_printf("device[%d]", unattached_count= ++); > =20 > - object_property_add_child(container_get("/machine/unattached")= , name, > - OBJECT(dev), NULL); > + object_property_add_child(container_get(qdev_get_machine(), > + "/unattached"), > + name, OBJECT(dev), NULL); > g_free(name); > } > =20 > @@ -673,7 +674,7 @@ Object *qdev_get_machine(void) > static Object *dev; > =20 > if (dev =3D=3D NULL) { > - dev =3D container_get("/machine"); > + dev =3D container_get(object_get_root(), "/machine"); > } > =20 > return dev; > diff --git a/include/qemu/object.h b/include/qemu/object.h > index a675937..ca1649c 100644 > --- a/include/qemu/object.h > +++ b/include/qemu/object.h > @@ -905,6 +905,7 @@ void object_property_add_str(Object *obj, const cha= r *name, > =20 > /** > * container_get: > + * @root: root of the #path, e.g., object_get_root() > * @path: path to the container > * > * Return a container object whose path is @path. Create more contain= ers > @@ -912,7 +913,7 @@ void object_property_add_str(Object *obj, const cha= r *name, > * > * Returns: the container object. > */ > -Object *container_get(const char *path); > +Object *container_get(Object *root, const char *path); > =20 > =20 > #endif > diff --git a/qom/container.c b/qom/container.c > index 67e9e8a..c9940ab 100644 > --- a/qom/container.c > +++ b/qom/container.c > @@ -25,7 +25,7 @@ static void container_register_types(void) > type_register_static(&container_info); > } > =20 > -Object *container_get(const char *path) > +Object *container_get(Object *root, const char *path) > { > Object *obj, *child; > gchar **parts; > @@ -33,7 +33,7 @@ Object *container_get(const char *path) > =20 > parts =3D g_strsplit(path, "/", 0); > assert(parts !=3D NULL && parts[0] !=3D NULL && !parts[0][0]); > - obj =3D object_get_root(); > + obj =3D root; > =20 > for (i =3D 1; parts[i] !=3D NULL; i++, obj =3D child) { > child =3D object_resolve_path_component(obj, parts[i]);