]> git.proxmox.com Git - mirror_qemu.git/blame - qom/container.c
hw/arm/exynos4210: Include missing 'exec/tswap.h' header
[mirror_qemu.git] / qom / container.c
CommitLineData
8b45d447
AL
1/*
2 * Device Container
3 *
4 * Copyright IBM, Corp. 2012
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
11 */
12
9bbc853b 13#include "qemu/osdep.h"
14cccb61 14#include "qom/object.h"
1de7afc9 15#include "qemu/module.h"
8b45d447 16
8c43a6f0 17static const TypeInfo container_info = {
8b45d447 18 .name = "container",
8b45d447
AL
19 .parent = TYPE_OBJECT,
20};
21
83f7d43a 22static void container_register_types(void)
8b45d447
AL
23{
24 type_register_static(&container_info);
25}
26
dfe47e70 27Object *container_get(Object *root, const char *path)
a612b2a6
PB
28{
29 Object *obj, *child;
ddfb0baa 30 char **parts;
a612b2a6
PB
31 int i;
32
33 parts = g_strsplit(path, "/", 0);
34 assert(parts != NULL && parts[0] != NULL && !parts[0][0]);
dfe47e70 35 obj = root;
a612b2a6
PB
36
37 for (i = 1; parts[i] != NULL; i++, obj = child) {
38 child = object_resolve_path_component(obj, parts[i]);
39 if (!child) {
40 child = object_new("container");
d2623129 41 object_property_add_child(obj, parts[i], child);
f8df5f92 42 object_unref(child);
a612b2a6
PB
43 }
44 }
45
f156f238
SW
46 g_strfreev(parts);
47
a612b2a6
PB
48 return obj;
49}
50
51
83f7d43a 52type_init(container_register_types)