summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2016-03-16 19:54:42 +0100
committerKevin Wolf <kwolf@redhat.com>2016-03-17 15:47:56 +0100
commit981f4f578e6a0dfb2d02384941ea17f7ea1a14ec (patch)
treec2a89e54572c80acd4dc92d634a166b6249a6246 /block
parent262b4e8f74dfd5ea9159aa98dcd705158b12e8ed (diff)
downloadqemu-981f4f578e6a0dfb2d02384941ea17f7ea1a14ec.zip
block: Add blk_next_root_bs()
This function iterates over all BDSs attached to a BB. We are going to need it when rewriting bdrv_next() so it no longer uses bdrv_states. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/block-backend.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/block/block-backend.c b/block/block-backend.c
index b3c3d39db8..7818aa2634 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -250,6 +250,30 @@ BlockBackend *blk_next(BlockBackend *blk)
}
/*
+ * Iterates over all BlockDriverStates which are attached to a BlockBackend.
+ * This function is for use by bdrv_next().
+ *
+ * @bs must be NULL or a BDS that is attached to a BB.
+ */
+BlockDriverState *blk_next_root_bs(BlockDriverState *bs)
+{
+ BlockBackend *blk;
+
+ if (bs) {
+ assert(bs->blk);
+ blk = bs->blk;
+ } else {
+ blk = NULL;
+ }
+
+ do {
+ blk = blk_all_next(blk);
+ } while (blk && !blk->bs);
+
+ return blk ? blk->bs : NULL;
+}
+
+/*
* Add a BlockBackend into the list of backends referenced by the monitor, with
* the given @name acting as the handle for the monitor.
* Strictly for use by blockdev.c.