From: Joao Martins <joao.m.mart...@oracle.com> Add iova_tree_nnodes() which returns the number of nodes in the IOVA tree.
Signed-off-by: Joao Martins <joao.m.mart...@oracle.com> --- include/qemu/iova-tree.h | 11 +++++++++++ util/iova-tree.c | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/include/qemu/iova-tree.h b/include/qemu/iova-tree.h index 8528e5c98f..7bb80783ce 100644 --- a/include/qemu/iova-tree.h +++ b/include/qemu/iova-tree.h @@ -164,4 +164,15 @@ int iova_tree_alloc_map(IOVATree *tree, DMAMap *map, hwaddr iova_begin, */ void iova_tree_destroy(IOVATree *tree); +/** + * iova_tree_nnodes: + * + * @tree: the iova tree to consult + * + * Returns the number of nodes in the iova tree + * + * Return: >=0 for the number of nodes. + */ +gint iova_tree_nnodes(IOVATree *tree); + #endif diff --git a/util/iova-tree.c b/util/iova-tree.c index 536789797e..6141a6229b 100644 --- a/util/iova-tree.c +++ b/util/iova-tree.c @@ -280,3 +280,8 @@ void iova_tree_destroy(IOVATree *tree) g_tree_destroy(tree->tree); g_free(tree); } + +gint iova_tree_nnodes(IOVATree *tree) +{ + return g_tree_nnodes(tree->tree); +} -- 2.26.3