diff options
author | Max Reitz <mreitz@redhat.com> | 2016-03-16 19:54:43 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2016-03-17 15:47:56 +0100 |
commit | 26260580349e0369858f03f46ebaf9e31c2a780f (patch) | |
tree | 4ae85d7b2c2a9e07eb5a1b058da9c2aa7308375a | |
parent | 981f4f578e6a0dfb2d02384941ea17f7ea1a14ec (diff) | |
download | qemu-26260580349e0369858f03f46ebaf9e31c2a780f.zip |
block: Rewrite bdrv_next()
Instead of using the bdrv_states list, iterate over all the
BlockDriverStates attached to BlockBackends, and over all the
monitor-owned BDSs afterwards (except for those attached to a BB).
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r-- | block.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -2969,12 +2969,23 @@ BlockDriverState *bdrv_next_node(BlockDriverState *bs) return QTAILQ_NEXT(bs, node_list); } +/* Iterates over all top-level BlockDriverStates, i.e. BDSs that are owned by + * the monitor or attached to a BlockBackend */ BlockDriverState *bdrv_next(BlockDriverState *bs) { - if (!bs) { - return QTAILQ_FIRST(&bdrv_states); + if (!bs || bs->blk) { + bs = blk_next_root_bs(bs); + if (bs) { + return bs; + } } - return QTAILQ_NEXT(bs, device_list); + + /* Ignore all BDSs that are attached to a BlockBackend here; they have been + * handled by the above block already */ + do { + bs = bdrv_next_monitor_owned(bs); + } while (bs && bs->blk); + return bs; } const char *bdrv_get_node_name(const BlockDriverState *bs) |