[PATCH RFC 06/15] util/iova-tree: g_tree_foreach wrapper
Connor Kite <[email protected]> Thu, 23 Jul 2026 15:30:05 -0700
| Newsgroups | dev.linux.lists.virtio-fs,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <[email protected]> |
Add a wrapper to iova-tree to call g_tree_foreach. Provies a means to execute some function on each node of the iova-tree. Signed-off-by: Connor Kite <[email protected]> --- include/qemu/iova-tree.h | 13 +++++++++++++ util/iova-tree.c | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/include/qemu/iova-tree.h b/include/qemu/iova-tree.h index 14e82a22d5..4d77f4dc57 100644 --- a/include/qemu/iova-tree.h +++ b/include/qemu/iova-tree.h @@ -161,4 +161,17 @@ int iova_tree_alloc_map(IOVATree *tree, DMAMap *map, hwaddr iova_begin, */ void iova_tree_destroy(IOVATree *tree); +/** + * iova_tree_foreach: + * + * @tree: the iova tree to traverse + * @func: the function called at every node. A true return value ends traversal + * @data: an argument passed to func + * + * Wrapper to call g_tree_foreach on underlying g_tree + * + * Return: None + */ +void iova_tree_foreach(IOVATree *tree, GTraverseFunc func, gpointer data); + #endif diff --git a/util/iova-tree.c b/util/iova-tree.c index 5b0c95ff15..2239bb6ae1 100644 --- a/util/iova-tree.c +++ b/util/iova-tree.c @@ -303,3 +303,8 @@ int gpa_tree_insert(IOVATree *tree, const DMAMap *map) return IOVA_OK; } + +void iova_tree_foreach(IOVATree *tree, GTraverseFunc func, gpointer data) +{ + g_tree_foreach(tree->tree, func, data); +} -- 2.43.0