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>
This commit is contained in:
parent
7c03a17c8d
commit
5cfd38a2e7
3 changed files with 39 additions and 4 deletions
24
qom/object.c
24
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue