static Object *dev;
if (dev == NULL) {
- dev = container_get("/machine/peripheral");
+ dev = container_get(qdev_get_machine(), "/peripheral");
}
return dev;
static Object *dev;
if (dev == NULL) {
- dev = container_get("/machine/peripheral-anon");
+ dev = container_get(qdev_get_machine(), "/peripheral-anon");
}
return 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);
}
static Object *dev;
if (dev == NULL) {
- dev = container_get("/machine");
+ dev = container_get(object_get_root(), "/machine");
}
return dev;
/**
* 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 containers
*
* Returns: the container object.
*/
-Object *container_get(const char *path);
+Object *container_get(Object *root, const char *path);
#endif
type_register_static(&container_info);
}
-Object *container_get(const char *path)
+Object *container_get(Object *root, const char *path)
{
Object *obj, *child;
gchar **parts;
parts = g_strsplit(path, "/", 0);
assert(parts != NULL && parts[0] != NULL && !parts[0][0]);
- obj = object_get_root();
+ obj = root;
for (i = 1; parts[i] != NULL; i++, obj = child) {
child = object_resolve_path_component(obj, parts[i]);