Skip to content

Commit 1c34335

Browse files
xzpeterphilmd
authored andcommitted
qdev: Use machine_get_container()
Use machine_get_container() whenever applicable across the tree. Signed-off-by: Peter Xu <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Message-ID: <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Richard Henderson <[email protected]>
1 parent 41fc917 commit 1c34335

File tree

8 files changed

+12
-15
lines changed

8 files changed

+12
-15
lines changed

hw/core/gpio.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n,
121121
name ? name : "unnamed-gpio-out", n);
122122
if (input_pin && !OBJECT(input_pin)->parent) {
123123
/* We need a name for object_property_set_link to work */
124-
object_property_add_child(container_get(qdev_get_machine(),
125-
"/unattached"),
124+
object_property_add_child(machine_get_container("unattached"),
126125
"non-qdev-gpio[*]", OBJECT(input_pin));
127126
}
128127
object_property_set_link(OBJECT(dev), propname,

hw/core/qdev.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,7 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
476476
if (!obj->parent) {
477477
gchar *name = g_strdup_printf("device[%d]", unattached_count++);
478478

479-
object_property_add_child(container_get(qdev_get_machine(),
480-
"/unattached"),
479+
object_property_add_child(machine_get_container("unattached"),
481480
name, obj);
482481
unattached_parent = true;
483482
g_free(name);

hw/core/sysbus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ void foreach_dynamic_sysbus_device(FindSysbusDeviceFunc *func, void *opaque)
6565
};
6666

6767
/* Loop through all sysbus devices that were spawned outside the machine */
68-
container = container_get(qdev_get_machine(), "/peripheral");
68+
container = machine_get_container("peripheral");
6969
find_sysbus_device(container, &find);
70-
container = container_get(qdev_get_machine(), "/peripheral-anon");
70+
container = machine_get_container("peripheral-anon");
7171
find_sysbus_device(container, &find);
7272
}
7373

hw/i386/pc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ static int check_fdc(Object *obj, void *opaque)
463463
}
464464

465465
static const char * const fdc_container_path[] = {
466-
"/unattached", "/peripheral", "/peripheral-anon"
466+
"unattached", "peripheral", "peripheral-anon"
467467
};
468468

469469
/*
@@ -477,7 +477,7 @@ static ISADevice *pc_find_fdc0(void)
477477
CheckFdcState state = { 0 };
478478

479479
for (i = 0; i < ARRAY_SIZE(fdc_container_path); i++) {
480-
container = container_get(qdev_get_machine(), fdc_container_path[i]);
480+
container = machine_get_container(fdc_container_path[i]);
481481
object_child_foreach(container, check_fdc, &state);
482482
}
483483

system/ioport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ static void portio_list_add_1(PortioList *piolist,
258258
object_ref(&mrpio->mr);
259259
object_unparent(OBJECT(&mrpio->mr));
260260
if (!piolist->owner) {
261-
owner = container_get(qdev_get_machine(), "/unattached");
261+
owner = machine_get_container("unattached");
262262
} else {
263263
owner = piolist->owner;
264264
}

system/memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ static void memory_region_do_init(MemoryRegion *mr,
12381238
char *name_array = g_strdup_printf("%s[*]", escaped_name);
12391239

12401240
if (!owner) {
1241-
owner = container_get(qdev_get_machine(), "/unattached");
1241+
owner = machine_get_container("unattached");
12421242
}
12431243

12441244
object_property_add_child(owner, name_array, OBJECT(mr));

system/qdev-monitor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static Object *qdev_get_peripheral(void)
348348
static Object *dev;
349349

350350
if (dev == NULL) {
351-
dev = container_get(qdev_get_machine(), "/peripheral");
351+
dev = machine_get_container("peripheral");
352352
}
353353

354354
return dev;
@@ -359,7 +359,7 @@ static Object *qdev_get_peripheral_anon(void)
359359
static Object *dev;
360360

361361
if (dev == NULL) {
362-
dev = container_get(qdev_get_machine(), "/peripheral-anon");
362+
dev = machine_get_container("peripheral-anon");
363363
}
364364

365365
return dev;
@@ -1100,7 +1100,7 @@ static GSList *qdev_build_hotpluggable_device_list(Object *peripheral)
11001100
static void peripheral_device_del_completion(ReadLineState *rs,
11011101
const char *str)
11021102
{
1103-
Object *peripheral = container_get(qdev_get_machine(), "/peripheral");
1103+
Object *peripheral = machine_get_container("peripheral");
11041104
GSList *list, *item;
11051105

11061106
list = qdev_build_hotpluggable_device_list(peripheral);

system/vl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,8 +2137,7 @@ static void qemu_create_machine(QDict *qdict)
21372137
object_property_add_child(object_get_root(), "machine",
21382138
OBJECT(current_machine));
21392139
qemu_create_machine_containers(OBJECT(current_machine));
2140-
object_property_add_child(container_get(OBJECT(current_machine),
2141-
"/unattached"),
2140+
object_property_add_child(machine_get_container("unattached"),
21422141
"sysbus", OBJECT(sysbus_get_default()));
21432142

21442143
if (machine_class->minimum_page_bits) {

0 commit comments

Comments
 (0)