[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/59] qom: Create system containers explicitly
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 09/59] qom: Create system containers explicitly |
Date: |
Fri, 20 Dec 2024 17:15:00 +0100 |
From: Peter Xu <peterx@redhat.com>
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>
---
hw/core/machine.c | 3 ---
qom/object.c | 24 +++++++++++++++++++++++-
system/vl.c | 16 ++++++++++++++++
3 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index d970f753e37..3d734f8c18d 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1229,9 +1229,6 @@ static void machine_initfn(Object *obj)
MachineState *ms = MACHINE(obj);
MachineClass *mc = MACHINE_GET_CLASS(obj);
- container_get(obj, "/peripheral");
- container_get(obj, "/peripheral-anon");
-
ms->dump_guest_core = true;
ms->mem_merge = (QEMU_MADV_MERGEABLE != QEMU_MADV_INVALID);
ms->enable_graphics = true;
diff --git a/qom/object.c b/qom/object.c
index c9f8442b136..b4c52d055d9 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;
diff --git a/system/vl.c b/system/vl.c
index 09202b57e73..85fcc8f96e6 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()));
--
2.47.1
- [PULL 00/59] Accel & exec patches for 2024-12-20, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 02/59] log: Add separate debug option for logging invalid memory accesses, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 01/59] hvf: arm: Ignore writes to CNTP_CTL_EL0, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 03/59] qom: Add TYPE_CONTAINER macro, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 04/59] qom: New object_property_add_new_container(), Philippe Mathieu-Daudé, 2024/12/20
- [PULL 05/59] tests: Fix test-qdev-global-props on anonymous qdev realize(), Philippe Mathieu-Daudé, 2024/12/20
- [PULL 06/59] tests: Explicitly create containers in test_qom_partial_path(), Philippe Mathieu-Daudé, 2024/12/20
- [PULL 07/59] ppc/e500: Avoid abuse of container_get(), Philippe Mathieu-Daudé, 2024/12/20
- [PULL 08/59] hw/ppc: Explicitly create the drc container, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 09/59] qom: Create system containers explicitly,
Philippe Mathieu-Daudé <=
- [PULL 10/59] target/i386/sev: Reduce system specific declarations, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 11/59] include: Rename sysemu/ -> system/, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 12/59] system: Move 'exec/confidential-guest-support.h' to system/, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 13/59] tcg/tci: Include missing 'disas/dis-asm.h' header, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 14/59] accel/tcg: Include missing 'exec/tswap.h' header in translator.c, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 15/59] accel/tcg: Have tlb_vaddr_to_host() use vaddr type, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 16/59] exec/cpu-all: Include missing 'exec/cpu-defs.h' header, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 19/59] linux-user/aarch64: Include missing 'user/abitypes.h' header, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 17/59] exec/cpu-defs: Remove unnecessary headers, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 21/59] target/arm/cpu: Restrict cpu_untagged_addr() to user emulation, Philippe Mathieu-Daudé, 2024/12/20