[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/11] qdev: Use machine_get_container()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 06/11] qdev: Use machine_get_container() |
Date: |
Thu, 9 Jan 2025 18:19:43 +0100 |
From: Peter Xu <peterx@redhat.com>
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>
---
hw/core/gpio.c | 3 +--
hw/core/qdev.c | 3 +--
hw/core/sysbus.c | 4 ++--
hw/i386/pc.c | 4 ++--
system/ioport.c | 2 +-
system/memory.c | 2 +-
system/qdev-monitor.c | 6 +++---
system/vl.c | 3 +--
8 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/hw/core/gpio.c b/hw/core/gpio.c
index 80d07a6ec99..6e32a8eec61 100644
--- a/hw/core/gpio.c
+++ b/hw/core/gpio.c
@@ -121,8 +121,7 @@ void qdev_connect_gpio_out_named(DeviceState *dev, const
char *name, int n,
name ? name : "unnamed-gpio-out", n);
if (input_pin && !OBJECT(input_pin)->parent) {
/* We need a name for object_property_set_link to work */
- object_property_add_child(container_get(qdev_get_machine(),
- "/unattached"),
+ object_property_add_child(machine_get_container("unattached"),
"non-qdev-gpio[*]", OBJECT(input_pin));
}
object_property_set_link(OBJECT(dev), propname,
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 9abc4e8322f..82bbdcb654e 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -476,8 +476,7 @@ static void device_set_realized(Object *obj, bool value,
Error **errp)
if (!obj->parent) {
gchar *name = g_strdup_printf("device[%d]", unattached_count++);
- object_property_add_child(container_get(qdev_get_machine(),
- "/unattached"),
+ object_property_add_child(machine_get_container("unattached"),
name, obj);
unattached_parent = true;
g_free(name);
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index e64d99c8edf..9355849ff0a 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -65,9 +65,9 @@ void foreach_dynamic_sysbus_device(FindSysbusDeviceFunc
*func, void *opaque)
};
/* 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);
- container = container_get(qdev_get_machine(), "/peripheral-anon");
+ container = machine_get_container("peripheral-anon");
find_sysbus_device(container, &find);
}
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 71118765884..9334b033f65 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -463,7 +463,7 @@ static int check_fdc(Object *obj, void *opaque)
}
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 };
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);
}
diff --git a/system/ioport.c b/system/ioport.c
index fd551d0375e..55c2a752396 100644
--- a/system/ioport.c
+++ b/system/ioport.c
@@ -258,7 +258,7 @@ static void portio_list_add_1(PortioList *piolist,
object_ref(&mrpio->mr);
object_unparent(OBJECT(&mrpio->mr));
if (!piolist->owner) {
- owner = container_get(qdev_get_machine(), "/unattached");
+ owner = machine_get_container("unattached");
} else {
owner = piolist->owner;
}
diff --git a/system/memory.c b/system/memory.c
index 78e17e0efa8..b17b5538ffa 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -1238,7 +1238,7 @@ static void memory_region_do_init(MemoryRegion *mr,
char *name_array = g_strdup_printf("%s[*]", escaped_name);
if (!owner) {
- owner = container_get(qdev_get_machine(), "/unattached");
+ owner = machine_get_container("unattached");
}
object_property_add_child(owner, name_array, OBJECT(mr));
diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
index 6a38b567876..23043b1e0d5 100644
--- a/system/qdev-monitor.c
+++ b/system/qdev-monitor.c
@@ -348,7 +348,7 @@ static Object *qdev_get_peripheral(void)
static Object *dev;
if (dev == NULL) {
- dev = container_get(qdev_get_machine(), "/peripheral");
+ dev = machine_get_container("peripheral");
}
return dev;
@@ -359,7 +359,7 @@ static Object *qdev_get_peripheral_anon(void)
static Object *dev;
if (dev == NULL) {
- dev = container_get(qdev_get_machine(), "/peripheral-anon");
+ dev = machine_get_container("peripheral-anon");
}
return dev;
@@ -1100,7 +1100,7 @@ static GSList *qdev_build_hotpluggable_device_list(Object
*peripheral)
static void peripheral_device_del_completion(ReadLineState *rs,
const char *str)
{
- Object *peripheral = container_get(qdev_get_machine(), "/peripheral");
+ Object *peripheral = machine_get_container("peripheral");
GSList *list, *item;
list = qdev_build_hotpluggable_device_list(peripheral);
diff --git a/system/vl.c b/system/vl.c
index 3c5bd36d7d7..ed1623b26b9 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -2137,8 +2137,7 @@ static void qemu_create_machine(QDict *qdict)
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"),
+ object_property_add_child(machine_get_container("unattached"),
"sysbus", OBJECT(sysbus_get_default()));
if (machine_class->minimum_page_bits) {
--
2.47.1
- [PULL 00/11] QOM / QDev patches for 2025-01-09, Philippe Mathieu-Daudé, 2025/01/09
- [PULL 01/11] hw/pci: Use -1 as the default value for rombar, Philippe Mathieu-Daudé, 2025/01/09
- [PULL 02/11] qdev: Remove opts member, Philippe Mathieu-Daudé, 2025/01/09
- [PULL 03/11] qdev: Implement qdev_create_fake_machine() for user emulation, Philippe Mathieu-Daudé, 2025/01/09
- [PULL 04/11] qdev: Make qdev_get_machine() not use container_get(), Philippe Mathieu-Daudé, 2025/01/09
- [PULL 05/11] qdev: Add machine_get_container(), Philippe Mathieu-Daudé, 2025/01/09
- [PULL 06/11] qdev: Use machine_get_container(),
Philippe Mathieu-Daudé <=
- [PULL 07/11] qom: Add object_get_container(), Philippe Mathieu-Daudé, 2025/01/09
- [PULL 08/11] qom: Use object_get_container(), Philippe Mathieu-Daudé, 2025/01/09
- [PULL 09/11] qom: Remove container_get(), Philippe Mathieu-Daudé, 2025/01/09
- [PULL 10/11] qom: remove unused InterfaceInfo::concrete_class field, Philippe Mathieu-Daudé, 2025/01/09
- [PULL 11/11] system: Inline machine_containers[] in qemu_create_machine_containers(), Philippe Mathieu-Daudé, 2025/01/09