提交 981f4f57 编写于 作者: M Max Reitz 提交者: Kevin Wolf

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: NMax Reitz <mreitz@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 262b4e8f
...@@ -249,6 +249,30 @@ BlockBackend *blk_next(BlockBackend *blk) ...@@ -249,6 +249,30 @@ BlockBackend *blk_next(BlockBackend *blk)
: QTAILQ_FIRST(&monitor_block_backends); : QTAILQ_FIRST(&monitor_block_backends);
} }
/*
* 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 * Add a BlockBackend into the list of backends referenced by the monitor, with
* the given @name acting as the handle for the monitor. * the given @name acting as the handle for the monitor.
......
...@@ -70,6 +70,7 @@ void blk_remove_all_bs(void); ...@@ -70,6 +70,7 @@ void blk_remove_all_bs(void);
const char *blk_name(BlockBackend *blk); const char *blk_name(BlockBackend *blk);
BlockBackend *blk_by_name(const char *name); BlockBackend *blk_by_name(const char *name);
BlockBackend *blk_next(BlockBackend *blk); BlockBackend *blk_next(BlockBackend *blk);
BlockDriverState *blk_next_root_bs(BlockDriverState *bs);
bool monitor_add_blk(BlockBackend *blk, const char *name, Error **errp); bool monitor_add_blk(BlockBackend *blk, const char *name, Error **errp);
void monitor_remove_blk(BlockBackend *blk); void monitor_remove_blk(BlockBackend *blk);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册