qdev: Use machine_get_container()

Use machine_get_container() whenever applicable across the tree.

Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20241121192202.4155849-11-peterx@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Peter Xu 2024-11-21 14:21:59 -05:00 committed by Philippe Mathieu-Daudé
parent 41fc917728
commit 1c34335844
8 changed files with 12 additions and 15 deletions

View file

@ -121,8 +121,7 @@ void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n,
name ? name : "unnamed-gpio-out", n); name ? name : "unnamed-gpio-out", n);
if (input_pin && !OBJECT(input_pin)->parent) { if (input_pin && !OBJECT(input_pin)->parent) {
/* We need a name for object_property_set_link to work */ /* We need a name for object_property_set_link to work */
object_property_add_child(container_get(qdev_get_machine(), object_property_add_child(machine_get_container("unattached"),
"/unattached"),
"non-qdev-gpio[*]", OBJECT(input_pin)); "non-qdev-gpio[*]", OBJECT(input_pin));
} }
object_property_set_link(OBJECT(dev), propname, object_property_set_link(OBJECT(dev), propname,

View file

@ -476,8 +476,7 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
if (!obj->parent) { if (!obj->parent) {
gchar *name = g_strdup_printf("device[%d]", unattached_count++); gchar *name = g_strdup_printf("device[%d]", unattached_count++);
object_property_add_child(container_get(qdev_get_machine(), object_property_add_child(machine_get_container("unattached"),
"/unattached"),
name, obj); name, obj);
unattached_parent = true; unattached_parent = true;
g_free(name); g_free(name);

View file

@ -65,9 +65,9 @@ void foreach_dynamic_sysbus_device(FindSysbusDeviceFunc *func, void *opaque)
}; };
/* Loop through all sysbus devices that were spawned outside the machine */ /* Loop through all sysbus devices that were spawned outside the machine */
container = container_get(qdev_get_machine(), "/peripheral"); container = machine_get_container("peripheral");
find_sysbus_device(container, &find); find_sysbus_device(container, &find);
container = container_get(qdev_get_machine(), "/peripheral-anon"); container = machine_get_container("peripheral-anon");
find_sysbus_device(container, &find); find_sysbus_device(container, &find);
} }

View file

@ -463,7 +463,7 @@ static int check_fdc(Object *obj, void *opaque)
} }
static const char * const fdc_container_path[] = { static const char * const fdc_container_path[] = {
"/unattached", "/peripheral", "/peripheral-anon" "unattached", "peripheral", "peripheral-anon"
}; };
/* /*
@ -477,7 +477,7 @@ static ISADevice *pc_find_fdc0(void)
CheckFdcState state = { 0 }; CheckFdcState state = { 0 };
for (i = 0; i < ARRAY_SIZE(fdc_container_path); i++) { for (i = 0; i < ARRAY_SIZE(fdc_container_path); i++) {
container = container_get(qdev_get_machine(), fdc_container_path[i]); container = machine_get_container(fdc_container_path[i]);
object_child_foreach(container, check_fdc, &state); object_child_foreach(container, check_fdc, &state);
} }

View file

@ -258,7 +258,7 @@ static void portio_list_add_1(PortioList *piolist,
object_ref(&mrpio->mr); object_ref(&mrpio->mr);
object_unparent(OBJECT(&mrpio->mr)); object_unparent(OBJECT(&mrpio->mr));
if (!piolist->owner) { if (!piolist->owner) {
owner = container_get(qdev_get_machine(), "/unattached"); owner = machine_get_container("unattached");
} else { } else {
owner = piolist->owner; owner = piolist->owner;
} }

View file

@ -1238,7 +1238,7 @@ static void memory_region_do_init(MemoryRegion *mr,
char *name_array = g_strdup_printf("%s[*]", escaped_name); char *name_array = g_strdup_printf("%s[*]", escaped_name);
if (!owner) { if (!owner) {
owner = container_get(qdev_get_machine(), "/unattached"); owner = machine_get_container("unattached");
} }
object_property_add_child(owner, name_array, OBJECT(mr)); object_property_add_child(owner, name_array, OBJECT(mr));

View file

@ -348,7 +348,7 @@ static Object *qdev_get_peripheral(void)
static Object *dev; static Object *dev;
if (dev == NULL) { if (dev == NULL) {
dev = container_get(qdev_get_machine(), "/peripheral"); dev = machine_get_container("peripheral");
} }
return dev; return dev;
@ -359,7 +359,7 @@ static Object *qdev_get_peripheral_anon(void)
static Object *dev; static Object *dev;
if (dev == NULL) { if (dev == NULL) {
dev = container_get(qdev_get_machine(), "/peripheral-anon"); dev = machine_get_container("peripheral-anon");
} }
return dev; return dev;
@ -1100,7 +1100,7 @@ static GSList *qdev_build_hotpluggable_device_list(Object *peripheral)
static void peripheral_device_del_completion(ReadLineState *rs, static void peripheral_device_del_completion(ReadLineState *rs,
const char *str) const char *str)
{ {
Object *peripheral = container_get(qdev_get_machine(), "/peripheral"); Object *peripheral = machine_get_container("peripheral");
GSList *list, *item; GSList *list, *item;
list = qdev_build_hotpluggable_device_list(peripheral); list = qdev_build_hotpluggable_device_list(peripheral);

View file

@ -2137,8 +2137,7 @@ static void qemu_create_machine(QDict *qdict)
object_property_add_child(object_get_root(), "machine", object_property_add_child(object_get_root(), "machine",
OBJECT(current_machine)); OBJECT(current_machine));
qemu_create_machine_containers(OBJECT(current_machine)); qemu_create_machine_containers(OBJECT(current_machine));
object_property_add_child(container_get(OBJECT(current_machine), object_property_add_child(machine_get_container("unattached"),
"/unattached"),
"sysbus", OBJECT(sysbus_get_default())); "sysbus", OBJECT(sysbus_get_default()));
if (machine_class->minimum_page_bits) { if (machine_class->minimum_page_bits) {