aboutsummaryrefslogtreecommitdiff
path: root/qom
diff options
context:
space:
mode:
authorPeter Xu <peterx@redhat.com>2024-11-21 14:21:56 -0500
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2024-12-20 17:44:56 +0100
commit5cfd38a2e7d531f45607944ceb34eee5bf2c0ab5 (patch)
tree62e255d4101eb4272de3d50863ecdcdf5a5dcc18 /qom
parent7c03a17c8da54d30727b9bb4558cc298aaaaa99b (diff)
downloadqemu-5cfd38a2e7d531f45607944ceb34eee5bf2c0ab5.zip
qemu-5cfd38a2e7d531f45607944ceb34eee5bf2c0ab5.tar.gz
qemu-5cfd38a2e7d531f45607944ceb34eee5bf2c0ab5.tar.bz2
qom: Create system containers explicitly
Always explicitly create QEMU system containers upfront. Root containers will be created when trying to fetch the root object the 1st time. They are: /objects /chardevs /backend Machine sub-containers will be created only until machine is being initialized. They are: /machine/unattached /machine/peripheral /machine/peripheral-anon Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20241121192202.4155849-8-peterx@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Diffstat (limited to 'qom')
-rw-r--r--qom/object.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/qom/object.c b/qom/object.c
index c9f8442..b4c52d0 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1729,12 +1729,34 @@ const char *object_property_get_type(Object *obj, const char *name, Error **errp
return prop->type;
}
+static const char *const root_containers[] = {
+ "chardevs",
+ "objects",
+ "backend"
+};
+
+static Object *object_root_initialize(void)
+{
+ Object *root = object_new(TYPE_CONTAINER);
+ int i;
+
+ /*
+ * Create all QEMU system containers. "machine" and its sub-containers
+ * are only created when machine initializes (qemu_create_machine()).
+ */
+ for (i = 0; i < ARRAY_SIZE(root_containers); i++) {
+ object_property_add_new_container(root, root_containers[i]);
+ }
+
+ return root;
+}
+
Object *object_get_root(void)
{
static Object *root;
if (!root) {
- root = object_new(TYPE_CONTAINER);
+ root = object_root_initialize();
}
return root;