[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v3 03/14] block: Add blk_all_next()
From: |
Max Reitz |
Subject: |
[Qemu-block] [PATCH v3 03/14] block: Add blk_all_next() |
Date: |
Tue, 16 Feb 2016 19:08:15 +0100 |
Some places in block/block-backend.c need to iterate over actually all
BlockBackends, so this adds a function to do so. blk_next() in contrast
only iterates over the BlockBackends which are owned by the monitor.
Right now, both do the same, but this will change as of a follow-up
patch.
Signed-off-by: Max Reitz <address@hidden>
---
block/block-backend.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index 2146268..30decb4 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -223,11 +223,21 @@ void blk_unref(BlockBackend *blk)
}
}
+/*
+ * Behaves similarly to blk_next() but iterates over all BlockBackends, even
the
+ * ones which are hidden (i.e. are not referenced by the monitor).
+ */
+static BlockBackend *blk_all_next(BlockBackend *blk)
+{
+ return blk ? QTAILQ_NEXT(blk, link)
+ : QTAILQ_FIRST(&blk_backends);
+}
+
void blk_remove_all_bs(void)
{
- BlockBackend *blk;
+ BlockBackend *blk = NULL;
- QTAILQ_FOREACH(blk, &blk_backends, link) {
+ while ((blk = blk_all_next(blk)) != NULL) {
AioContext *ctx = blk_get_aio_context(blk);
aio_context_acquire(ctx);
--
2.7.1
- [Qemu-block] [PATCH v3 00/14] blockdev: Further BlockBackend work, Max Reitz, 2016/02/16
- [Qemu-block] [PATCH v3 02/14] block: Use blk_next() where appropriate, Max Reitz, 2016/02/16
- [Qemu-block] [PATCH v3 01/14] monitor: Use BB list for BB name completion, Max Reitz, 2016/02/16
- [Qemu-block] [PATCH v3 03/14] block: Add blk_all_next(),
Max Reitz <=
- [Qemu-block] [PATCH v3 05/14] block: Add blk_commit_all(), Max Reitz, 2016/02/16
- [Qemu-block] [PATCH v3 06/14] block: Use blk_{commit, flush}_all() consistently, Max Reitz, 2016/02/16
- [Qemu-block] [PATCH v3 04/14] block: Add blk_name_taken(), Max Reitz, 2016/02/16
- [Qemu-block] [PATCH v3 08/14] blockdev: Remove blk_hide_on_behalf_of_hmp_drive_del(), Max Reitz, 2016/02/16
- [Qemu-block] [PATCH v3 07/14] blockdev: Add list of monitor-owned BlockBackends, Max Reitz, 2016/02/16