@@ -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);
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 <mreitz@redhat.com> --- block/block-backend.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)