[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 16/29] block: Add blk_next_root_bs()
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 16/29] block: Add blk_next_root_bs() |
Date: |
Thu, 17 Mar 2016 16:56:29 +0100 |
From: Max Reitz <address@hidden>
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>
Signed-off-by: Kevin Wolf <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);
--
1.8.3.1
- [Qemu-devel] [PULL 01/29] block: Fix qemu_root_bds_opts.head initialisation, (continued)
- [Qemu-devel] [PULL 01/29] block: Fix qemu_root_bds_opts.head initialisation, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 05/29] block: Add blk_commit_all(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 02/29] block: Fix memory leak in hmp_drive_add_node(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 04/29] block: Use blk_next() in block-backend.c, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 07/29] qapi: Drop QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 09/29] blockdev: Rename blk_backends, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 08/29] block: Drop BB name from bad option error, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 06/29] block: Use blk_{commit, flush}_all() consistently, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 10/29] blockdev: Add list of all BlockBackends, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 11/29] blockdev: Separate BB name management, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 16/29] block: Add blk_next_root_bs(),
Kevin Wolf <=
- [Qemu-devel] [PULL 13/29] blockdev: Remove blk_hide_on_behalf_of_hmp_drive_del(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 15/29] block: Add bdrv_next_monitor_owned(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 17/29] block: Rewrite bdrv_next(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 14/29] block: Move some bdrv_*_all() functions to BB, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 12/29] blockdev: Split monitor reference from BB creation, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 19/29] block: Remove bdrv_states list, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 21/29] block: Use blk_co_preadv() for blk_read(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 18/29] block: Use bdrv_next() instead of bdrv_states, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 22/29] block: Use blk_co_pwritev() for blk_write(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 23/29] block: Pull up blk_read_unthrottled() implementation, Kevin Wolf, 2016/03/17