Similar to bdrv_next, this traverses through graph_bdrv_states. Will be useful to enumerate all the named nodes.
Signed-off-by: Fam Zheng <f...@redhat.com> --- block.c | 8 ++++++++ include/block/block.h | 1 + 2 files changed, 9 insertions(+) diff --git a/block.c b/block.c index 88f6d9b..c92a913 100644 --- a/block.c +++ b/block.c @@ -3775,6 +3775,14 @@ bool bdrv_chain_contains(BlockDriverState *top, BlockDriverState *base) return top != NULL; } +BlockDriverState *bdrv_next_node(BlockDriverState *bs) +{ + if (!bs) { + return QTAILQ_FIRST(&graph_bdrv_states); + } + return QTAILQ_NEXT(bs, node_list); +} + BlockDriverState *bdrv_next(BlockDriverState *bs) { if (!bs) { diff --git a/include/block/block.h b/include/block/block.h index 341054d..25acd81 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -365,6 +365,7 @@ BlockDriverState *bdrv_lookup_bs(const char *device, const char *node_name, Error **errp); bool bdrv_chain_contains(BlockDriverState *top, BlockDriverState *base); +BlockDriverState *bdrv_next_node(BlockDriverState *bs); BlockDriverState *bdrv_next(BlockDriverState *bs); int bdrv_is_encrypted(BlockDriverState *bs); int bdrv_key_required(BlockDriverState *bs); -- 1.9.3