block: New bdrv_next()
authorMarkus Armbruster <armbru@redhat.com>
Wed, 2 Jun 2010 16:55:20 +0000 (18:55 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 15 Jun 2010 07:41:59 +0000 (09:41 +0200)
This is a more flexible alternative to bdrv_iterate().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c
block.h

diff --git a/block.c b/block.c
index df2d3a6e8cd2f77c10305fce8f12b92122dab069..383d59fb0ae4ac54cc592842bd1b7a7e536a2ccf 100644 (file)
--- a/block.c
+++ b/block.c
@@ -1330,6 +1330,14 @@ BlockDriverState *bdrv_find(const char *name)
     return NULL;
 }
 
+BlockDriverState *bdrv_next(BlockDriverState *bs)
+{
+    if (!bs) {
+        return QTAILQ_FIRST(&bdrv_states);
+    }
+    return QTAILQ_NEXT(bs, list);
+}
+
 void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs), void *opaque)
 {
     BlockDriverState *bs;
diff --git a/block.h b/block.h
index 1f69cbd7c78ef888239fd666b51a4e4c425fa438..9df9b38f1510adc102d2995416add76df916af09 100644 (file)
--- a/block.h
+++ b/block.h
@@ -168,6 +168,7 @@ void bdrv_set_change_cb(BlockDriverState *bs,
                         void (*change_cb)(void *opaque), void *opaque);
 void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size);
 BlockDriverState *bdrv_find(const char *name);
+BlockDriverState *bdrv_next(BlockDriverState *bs);
 void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs),
                   void *opaque);
 int bdrv_is_encrypted(BlockDriverState *bs);