On 2026/07/24 7:30, Connor Kite wrote:
Add a wrapper to vhost-iova-tree that calls iova_tree_foreach on the
underlying iova_map. This provides a means to execute some function on
each node of the tree.
Signed-off-by: Connor Kite <[email protected]>
---
hw/virtio/vhost-iova-tree.c | 15 +++++++++++++++
hw/virtio/vhost-iova-tree.h | 3 +++
2 files changed, 18 insertions(+)
diff --git a/hw/virtio/vhost-iova-tree.c b/hw/virtio/vhost-iova-tree.c
index fa4147b773..d8206379bf 100644
--- a/hw/virtio/vhost-iova-tree.c
+++ b/hw/virtio/vhost-iova-tree.c
@@ -189,3 +189,18 @@ void vhost_iova_tree_remove_gpa(VhostIOVATree *iova_tree,
DMAMap map)
iova_tree_remove(iova_tree->gpa_iova_map, map);
iova_tree_remove(iova_tree->iova_map, map);
}
+
+
+/**
+ * Traverse through the iova tree in sorted order
+ *
+ * @tree: The VhostIOVATree
+ * @func: Function called at every node. A false return value ends traversal
GTraverseFunc stops traversal on true, but this says false ends traversal.
+ * @data: An argument passed to func
+ */
+void vhost_iova_tree_foreach(VhostIOVATree *tree,
+ GTraverseFunc func,
+ gpointer data)
+{
+ iova_tree_foreach(tree->iova_map, func, data);
+}
diff --git a/hw/virtio/vhost-iova-tree.h b/hw/virtio/vhost-iova-tree.h
index 08f63b61cd..f3b7c48cb9 100644
--- a/hw/virtio/vhost-iova-tree.h
+++ b/hw/virtio/vhost-iova-tree.h
@@ -29,5 +29,8 @@ const DMAMap *vhost_iova_tree_find_gpa(const VhostIOVATree
*iova_tree,
int vhost_iova_tree_map_alloc_gpa(VhostIOVATree *iova_tree, DMAMap *map,
hwaddr taddr);
void vhost_iova_tree_remove_gpa(VhostIOVATree *iova_tree, DMAMap map);
+void vhost_iova_tree_foreach(VhostIOVATree *tree, GTraverseFunc func,
+ gpointer data);
+
Here is an extra blank line.
Regards,
Akihiko Odaki
#endif