[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 12/14] block: Rewrite bdrv_next()
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v3 12/14] block: Rewrite bdrv_next() |
Date: |
Tue, 16 Feb 2016 19:08:24 +0100 |
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 <address@hidden>
---
block.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/block.c b/block.c
index 5eac9a3..f3597ac 100644
--- a/block.c
+++ b/block.c
@@ -2979,12 +2979,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)
--
2.7.1
- Re: [Qemu-devel] [PATCH v3 08/14] blockdev: Remove blk_hide_on_behalf_of_hmp_drive_del(), (continued)
- [Qemu-devel] [PATCH v3 05/14] block: Add blk_commit_all(), Max Reitz, 2016/02/16
- [Qemu-devel] [PATCH v3 09/14] block: Move some bdrv_*_all() functions to BB, Max Reitz, 2016/02/16
- [Qemu-devel] [PATCH v3 07/14] blockdev: Add list of monitor-owned BlockBackends, Max Reitz, 2016/02/16
- [Qemu-devel] [PATCH v3 10/14] block: Add bdrv_next_monitor_owned(), Max Reitz, 2016/02/16
- [Qemu-devel] [PATCH v3 11/14] block: Add blk_next_root_bs(), Max Reitz, 2016/02/16
- [Qemu-devel] [PATCH v3 12/14] block: Rewrite bdrv_next(),
Max Reitz <=
- [Qemu-devel] [PATCH v3 13/14] block: Use bdrv_next() instead of bdrv_states, Max Reitz, 2016/02/16
- [Qemu-devel] [PATCH v3 14/14] block: Remove bdrv_states list, Max Reitz, 2016/02/16
- Re: [Qemu-devel] [PATCH v3 00/14] blockdev: Further BlockBackend work, Kevin Wolf, 2016/02/17