qom: Refine container_get() to allow using a custom root

Specify the root to search from as argument. This avoids hardcoding
"/machine" in some places and makes it more flexible.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Andreas Färber 2012-04-05 13:21:46 +02:00 committed by Anthony Liguori
parent 7f3bf92fad
commit dfe47e7029
4 changed files with 10 additions and 8 deletions

View file

@ -158,8 +158,9 @@ int qdev_init(DeviceState *dev)
static int unattached_count = 0;
gchar *name = g_strdup_printf("device[%d]", unattached_count++);
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);
}
@ -677,7 +678,7 @@ Object *qdev_get_machine(void)
static Object *dev;
if (dev == NULL) {
dev = container_get("/machine");
dev = container_get(object_get_root(), "/machine");
}
return dev;