[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 04/12] block: add helper function to find the act
From: |
Jeff Cody |
Subject: |
[Qemu-devel] [PATCH v3 04/12] block: add helper function to find the active layer of any BDS |
Date: |
Fri, 30 May 2014 13:35:22 -0400 |
This helper function will find the active (top-most) layer of a
specified BDS. This returns either the active layer, or NULL if
the passed BDS is NULL.
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Jeff Cody <address@hidden>
---
block.c | 10 ++++++++++
include/block/block.h | 1 +
2 files changed, 11 insertions(+)
diff --git a/block.c b/block.c
index 588046e..7eb3279 100644
--- a/block.c
+++ b/block.c
@@ -4388,6 +4388,16 @@ BlockDriverState *bdrv_find_base(BlockDriverState *bs)
return curr_bs;
}
+/* Given a BDS, searches for the active layer. If
+ * active layer cannot be found, returns NULL */
+BlockDriverState *bdrv_find_active(BlockDriverState *bs)
+{
+ while (bs && bs->overlay) {
+ bs = bs->overlay;
+ }
+ return bs;
+}
+
/**************************************************************/
/* async I/Os */
diff --git a/include/block/block.h b/include/block/block.h
index dff5403..c82d89a 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -294,6 +294,7 @@ int bdrv_drop_intermediate(BlockDriverState *active,
BlockDriverState *top,
BlockDriverState *bdrv_find_overlay(BlockDriverState *active,
BlockDriverState *bs);
BlockDriverState *bdrv_find_base(BlockDriverState *bs);
+BlockDriverState *bdrv_find_active(BlockDriverState *bs);
typedef struct BdrvCheckResult {
--
1.8.3.1
- [Qemu-devel] [PATCH v3 00/12] Modify block jobs to use node-names, Jeff Cody, 2014/05/30
- [Qemu-devel] [PATCH v3 01/12] block: Auto-generate node_names for each BDS entry, Jeff Cody, 2014/05/30
- [Qemu-devel] [PATCH v3 02/12] block: add helper function to determine if a BDS is in a chain, Jeff Cody, 2014/05/30
- [Qemu-devel] [PATCH v3 03/12] block: Add overlay BDS pointer into the BlockDriverState struct, Jeff Cody, 2014/05/30
- [Qemu-devel] [PATCH v3 04/12] block: add helper function to find the active layer of any BDS,
Jeff Cody <=
- [Qemu-devel] [PATCH v3 05/12] block: simplify bdrv_find_base(), Jeff Cody, 2014/05/30
- [Qemu-devel] [PATCH v3 06/12] block: make 'top' argument to block-commit optional, Jeff Cody, 2014/05/30
- [Qemu-devel] [PATCH v3 07/12] block: Accept node-name arguments for block-commit, Jeff Cody, 2014/05/30
- [Qemu-devel] [PATCH v3 08/12] block: extend block-commit to accept a string for the backing file, Jeff Cody, 2014/05/30
- [Qemu-devel] [PATCH v3 10/12] block: add backing-file option to block-stream, Jeff Cody, 2014/05/30
- [Qemu-devel] [PATCH v3 09/12] block: add ability for block-stream to use node-name, Jeff Cody, 2014/05/30
- [Qemu-devel] [PATCH v3 11/12] block: Add QMP documentation for block-stream, Jeff Cody, 2014/05/30