summary refs log tree commit diff stats
path: root/system/vl.c
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 /system/vl.c
parent7c03a17c8da54d30727b9bb4558cc298aaaaa99b (diff)
downloadfocaccia-qemu-5cfd38a2e7d531f45607944ceb34eee5bf2c0ab5.tar.gz
focaccia-qemu-5cfd38a2e7d531f45607944ceb34eee5bf2c0ab5.zip
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 'system/vl.c')
-rw-r--r--system/vl.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/system/vl.c b/system/vl.c
index 09202b57e7..85fcc8f96e 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -2113,6 +2113,21 @@ static void parse_memory_options(void)
     loc_pop(&loc);
 }
 
+static const char *const machine_containers[] = {
+    "unattached",
+    "peripheral",
+    "peripheral-anon"
+};
+
+static void qemu_create_machine_containers(Object *machine)
+{
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(machine_containers); i++) {
+        object_property_add_new_container(machine, machine_containers[i]);
+    }
+}
+
 static void qemu_create_machine(QDict *qdict)
 {
     MachineClass *machine_class = select_machine(qdict, &error_fatal);
@@ -2121,6 +2136,7 @@ static void qemu_create_machine(QDict *qdict)
     current_machine = MACHINE(object_new_with_class(OBJECT_CLASS(machine_class)));
     object_property_add_child(object_get_root(), "machine",
                               OBJECT(current_machine));
+    qemu_create_machine_containers(OBJECT(current_machine));
     object_property_add_child(container_get(OBJECT(current_machine),
                                             "/unattached"),
                               "sysbus", OBJECT(sysbus_get_default()));