qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 1/4] block: Add bdrv_next_node


From: Fam Zheng
Subject: [Qemu-devel] [PATCH v2 1/4] block: Add bdrv_next_node
Date: Fri, 31 Oct 2014 11:32:54 +0800

Similar to bdrv_next, this traverses through graph_bdrv_states. Will be
useful to enumerate all the named nodes.

Signed-off-by: Fam Zheng <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]