summary refs log tree commit diff stats
path: root/qom/container.c
diff options
context:
space:
mode:
authorPeter Xu <peterx@redhat.com>2024-11-21 14:21:51 -0500
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2024-12-20 17:44:55 +0100
commit6e1e04ef035cf687e868858ab6bd18a177e1b822 (patch)
tree436d5b8b4d26211149de892b163f26134272a29b /qom/container.c
parente469b331cd1bb2a3d4a0b02b37390fd79947e225 (diff)
downloadfocaccia-qemu-6e1e04ef035cf687e868858ab6bd18a177e1b822.tar.gz
focaccia-qemu-6e1e04ef035cf687e868858ab6bd18a177e1b822.zip
qom: New object_property_add_new_container()
To move towards explicit creations of containers, starting that by
providing a helper for creating container objects.

Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20241121192202.4155849-3-peterx@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Diffstat (limited to 'qom/container.c')
-rw-r--r--qom/container.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/qom/container.c b/qom/container.c
index cfec92a944..20ab74b0e8 100644
--- a/qom/container.c
+++ b/qom/container.c
@@ -24,6 +24,16 @@ static void container_register_types(void)
     type_register_static(&container_info);
 }
 
+Object *object_property_add_new_container(Object *obj, const char *name)
+{
+    Object *child = object_new(TYPE_CONTAINER);
+
+    object_property_add_child(obj, name, child);
+    object_unref(child);
+
+    return child;
+}
+
 Object *container_get(Object *root, const char *path)
 {
     Object *obj, *child;
@@ -37,9 +47,7 @@ Object *container_get(Object *root, const char *path)
     for (i = 1; parts[i] != NULL; i++, obj = child) {
         child = object_resolve_path_component(obj, parts[i]);
         if (!child) {
-            child = object_new(TYPE_CONTAINER);
-            object_property_add_child(obj, parts[i], child);
-            object_unref(child);
+            child = object_property_add_new_container(obj, parts[i]);
         }
     }