Message ID | 1414559044-14501-2-git-send-email-famz@redhat.com |
---|---|
State | New |
Headers | show |
On 2014-10-29 at 06:04, Fam Zheng wrote: > Similar to bdrv_next, this traverses through graph_bdrv_states. Will be > useful to enumerate all the named nodes. > > Signed-off-by: Fam Zheng <famz@redhat.com> > --- > block.c | 8 ++++++++ > include/block/block.h | 1 + > 2 files changed, 9 insertions(+) You could reuse this for bdrv_named_nodes_list(), but that's optional. Reviewed-by: Max Reitz <mreitz@redhat.com>
On 10/28/2014 11:04 PM, Fam Zheng wrote: > Similar to bdrv_next, this traverses through graph_bdrv_states. Will be > useful to enumerate all the named nodes. > > Signed-off-by: Fam Zheng <famz@redhat.com> > --- > block.c | 8 ++++++++ > include/block/block.h | 1 + > 2 files changed, 9 insertions(+) > Reviewed-by: Eric Blake <eblake@redhat.com>
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);
Similar to bdrv_next, this traverses through graph_bdrv_states. Will be useful to enumerate all the named nodes. Signed-off-by: Fam Zheng <famz@redhat.com> --- block.c | 8 ++++++++ include/block/block.h | 1 + 2 files changed, 9 insertions(+)