* [Qemu-devel] [PATCH v2] Replace calls to object_child_foreach() with object_child_foreach_recursive()
@ 2019-04-01 15:40 Ernest Esene
2019-04-03 12:26 ` Stefan Hajnoczi
0 siblings, 1 reply; 2+ messages in thread
From: Ernest Esene @ 2019-04-01 15:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Stefan Hajnoczi, Paolo Bonzini
[-- Attachment #1: Type: text/plain, Size: 3890 bytes --]
Replace calls to object_child_foreach() with object_child_foreach_recursive()
when applicable: nvdimm_device_list, nmi_monitor_handle,
find_sysbus_device,
pc_dimm_slot2bitmap, build_dimm_list.
Signed-off-by: Ernest Esene <eroken1@gmail.com>
---
v2:
* applied changes suggested by Paolo
---
hw/acpi/nvdimm.c | 4 +---
hw/core/sysbus.c | 11 ++++-------
hw/mem/pc-dimm.c | 3 +--
hw/virtio/virtio-balloon.c | 3 +--
4 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
index 9fdad6dc3f..36ff075a42 100644
--- a/hw/acpi/nvdimm.c
+++ b/hw/acpi/nvdimm.c
@@ -40,8 +40,6 @@ static int nvdimm_device_list(Object *obj, void *opaque)
if (object_dynamic_cast(obj, TYPE_NVDIMM)) {
*list = g_slist_append(*list, DEVICE(obj));
}
-
- object_child_foreach(obj, nvdimm_device_list, opaque);
return 0;
}
@@ -56,7 +54,7 @@ static GSList *nvdimm_get_device_list(void)
{
GSList *list = NULL;
- object_child_foreach(qdev_get_machine(), nvdimm_device_list, &list);
+ object_child_foreach_recursive(qdev_get_machine(), nvdimm_device_list, &list);
return list;
}
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index 307cf90a51..3d0bf47a04 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -41,13 +41,10 @@ static int find_sysbus_device(Object *obj, void *opaque)
dev = object_dynamic_cast(obj, TYPE_SYS_BUS_DEVICE);
sbdev = (SysBusDevice *)dev;
- if (!sbdev) {
- /* Container, traverse it for children */
- return object_child_foreach(obj, find_sysbus_device, opaque);
+ if (sbdev) {
+ find->func(sbdev, find->opaque);
}
- find->func(sbdev, find->opaque);
-
return 0;
}
@@ -65,9 +62,9 @@ void foreach_dynamic_sysbus_device(FindSysbusDeviceFunc *func, void *opaque)
/* Loop through all sysbus devices that were spawened outside the machine */
container = container_get(qdev_get_machine(), "/peripheral");
- find_sysbus_device(container, &find);
+ object_child_foreach_recursive(container, find_sysbus_device, &find);
container = container_get(qdev_get_machine(), "/peripheral-anon");
- find_sysbus_device(container, &find);
+ object_child_foreach_recursive(container, find_sysbus_device, &find);
}
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 19b9c0f406..6eaac49a22 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -84,7 +84,6 @@ static int pc_dimm_slot2bitmap(Object *obj, void *opaque)
}
}
- object_child_foreach(obj, pc_dimm_slot2bitmap, opaque);
return 0;
}
@@ -100,7 +99,7 @@ static int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp)
}
bitmap = bitmap_new(max_slots);
- object_child_foreach(qdev_get_machine(), pc_dimm_slot2bitmap, bitmap);
+ object_child_foreach_recursive(qdev_get_machine(), pc_dimm_slot2bitmap, bitmap);
/* check if requested slot is not occupied */
if (hint) {
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 2112874055..7945637077 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -649,7 +649,6 @@ static int build_dimm_list(Object *obj, void *opaque)
}
}
- object_child_foreach(obj, build_dimm_list, opaque);
return 0;
}
@@ -658,7 +657,7 @@ static ram_addr_t get_current_ram_size(void)
GSList *list = NULL, *item;
ram_addr_t size = ram_size;
- build_dimm_list(qdev_get_machine(), &list);
+ object_child_foreach_recursive(qdev_get_machine(), build_dimm_list, &list);
for (item = list; item; item = g_slist_next(item)) {
Object *obj = OBJECT(item->data);
if (!strcmp(object_get_typename(obj), TYPE_PC_DIMM)) {
--
2.14.2
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH v2] Replace calls to object_child_foreach() with object_child_foreach_recursive()
2019-04-01 15:40 [Qemu-devel] [PATCH v2] Replace calls to object_child_foreach() with object_child_foreach_recursive() Ernest Esene
@ 2019-04-03 12:26 ` Stefan Hajnoczi
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2019-04-03 12:26 UTC (permalink / raw)
To: Ernest Esene; +Cc: qemu-devel, Paolo Bonzini
[-- Attachment #1: Type: text/plain, Size: 667 bytes --]
On Mon, Apr 01, 2019 at 04:40:28PM +0100, Ernest Esene wrote:
> Replace calls to object_child_foreach() with object_child_foreach_recursive()
> when applicable: nvdimm_device_list, nmi_monitor_handle,
> find_sysbus_device,
> pc_dimm_slot2bitmap, build_dimm_list.
>
> Signed-off-by: Ernest Esene <eroken1@gmail.com>
>
> ---
> v2:
> * applied changes suggested by Paolo
> ---
> hw/acpi/nvdimm.c | 4 +---
> hw/core/sysbus.c | 11 ++++-------
> hw/mem/pc-dimm.c | 3 +--
> hw/virtio/virtio-balloon.c | 3 +--
> 4 files changed, 7 insertions(+), 14 deletions(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-03 12:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-01 15:40 [Qemu-devel] [PATCH v2] Replace calls to object_child_foreach() with object_child_foreach_recursive() Ernest Esene
2019-04-03 12:26 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).