[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 14/17] block: Add blk_next_root_bs()
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v4 14/17] block: Add blk_next_root_bs() |
Date: |
Wed, 16 Mar 2016 19:54:42 +0100 |
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: Max Reitz <address@hidden>
---
block/block-backend.c | 24 ++++++++++++++++++++++++
include/sysemu/block-backend.h | 1 +
2 files changed, 25 insertions(+)
diff --git a/block/block-backend.c b/block/block-backend.c
index b3c3d39..7818aa2 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -250,6 +250,30 @@ BlockBackend *blk_next(BlockBackend *blk)
}
/*
+ * 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
* the given @name acting as the handle for the monitor.
* Strictly for use by blockdev.c.
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index 60c4b07..d839bff 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -70,6 +70,7 @@ void blk_remove_all_bs(void);
const char *blk_name(BlockBackend *blk);
BlockBackend *blk_by_name(const char *name);
BlockBackend *blk_next(BlockBackend *blk);
+BlockDriverState *blk_next_root_bs(BlockDriverState *bs);
bool monitor_add_blk(BlockBackend *blk, const char *name, Error **errp);
void monitor_remove_blk(BlockBackend *blk);
--
2.7.3
- [Qemu-devel] [PATCH v4 02/17] block: Use blk_next() in block-backend.c, (continued)
- [Qemu-devel] [PATCH v4 02/17] block: Use blk_next() in block-backend.c, Max Reitz, 2016/03/16
- [Qemu-devel] [PATCH v4 06/17] block: Drop BB name from bad option error, Max Reitz, 2016/03/16
- [Qemu-devel] [PATCH v4 04/17] block: Use blk_{commit, flush}_all() consistently, Max Reitz, 2016/03/16
- [Qemu-devel] [PATCH v4 07/17] blockdev: Rename blk_backends, Max Reitz, 2016/03/16
- [Qemu-devel] [PATCH v4 08/17] blockdev: Add list of all BlockBackends, Max Reitz, 2016/03/16
- [Qemu-devel] [PATCH v4 09/17] blockdev: Separate BB name management, Max Reitz, 2016/03/16
- [Qemu-devel] [PATCH v4 05/17] qapi: Drop QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, Max Reitz, 2016/03/16
- [Qemu-devel] [PATCH v4 13/17] block: Add bdrv_next_monitor_owned(), Max Reitz, 2016/03/16
- [Qemu-devel] [PATCH v4 10/17] blockdev: Split monitor reference from BB creation, Max Reitz, 2016/03/16
- [Qemu-devel] [PATCH v4 11/17] blockdev: Remove blk_hide_on_behalf_of_hmp_drive_del(), Max Reitz, 2016/03/16
- [Qemu-devel] [PATCH v4 14/17] block: Add blk_next_root_bs(),
Max Reitz <=
- [Qemu-devel] [PATCH v4 12/17] block: Move some bdrv_*_all() functions to BB, Max Reitz, 2016/03/16
- [Qemu-devel] [PATCH v4 15/17] block: Rewrite bdrv_next(), Max Reitz, 2016/03/16
- [Qemu-devel] [PATCH v4 16/17] block: Use bdrv_next() instead of bdrv_states, Max Reitz, 2016/03/16
- [Qemu-devel] [PATCH v4 17/17] block: Remove bdrv_states list, Max Reitz, 2016/03/16
- Re: [Qemu-devel] [PATCH v4 00/17] blockdev: Further BlockBackend work, Kevin Wolf, 2016/03/17