summary refs log tree commit diff stats
path: root/hw/core/qdev.c
diff options
context:
space:
mode:
authorPeter Xu <peterx@redhat.com>2024-11-21 14:21:58 -0500
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2025-01-09 18:16:24 +0100
commit41fc91772841c93c218df78d7e359cb2cd00dff5 (patch)
tree3338137939c1d32cdb3648582f8ec59e03dedd87 /hw/core/qdev.c
parent63450f322bf76faab7add3def89815d9198492dc (diff)
downloadfocaccia-qemu-41fc91772841c93c218df78d7e359cb2cd00dff5.tar.gz
focaccia-qemu-41fc91772841c93c218df78d7e359cb2cd00dff5.zip
qdev: Add machine_get_container()
Add a helper to fetch machine containers.  Add some sanity check around.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-ID: <20241121192202.4155849-10-peterx@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'hw/core/qdev.c')
-rw-r--r--hw/core/qdev.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 48bc9a7b9c..9abc4e8322 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -828,6 +828,17 @@ Object *qdev_get_machine(void)
     return dev;
 }
 
+Object *machine_get_container(const char *name)
+{
+    Object *container, *machine;
+
+    machine = qdev_get_machine();
+    container = object_resolve_path_component(machine, name);
+    assert(object_dynamic_cast(container, TYPE_CONTAINER));
+
+    return container;
+}
+
 char *qdev_get_human_name(DeviceState *dev)
 {
     g_assert(dev != NULL);