[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 04/11] block: add helper function to find the act
From: |
Jeff Cody |
Subject: |
[Qemu-devel] [PATCH v2 04/11] block: add helper function to find the active layer of any BDS |
Date: |
Tue, 27 May 2014 10:28:34 -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.
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 b72fe4e..577d4f1 100644
--- a/block.c
+++ b/block.c
@@ -4379,6 +4379,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 4dc68be..a978e0d 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -293,6 +293,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 v2 00/11] Modify block jobs to use node-names, Jeff Cody, 2014/05/27
- [Qemu-devel] [PATCH v2 01/11] block: Auto-generate node_names for each BDS entry, Jeff Cody, 2014/05/27
- [Qemu-devel] [PATCH v2 02/11] block: add helper function to determine if a BDS is in a chain, Jeff Cody, 2014/05/27
- [Qemu-devel] [PATCH v2 03/11] block: Add overlay BDS pointer into the BlockDriverState struct, Jeff Cody, 2014/05/27
- [Qemu-devel] [PATCH v2 04/11] block: add helper function to find the active layer of any BDS,
Jeff Cody <=
- [Qemu-devel] [PATCH v2 05/11] block: simplify bdrv_find_base(), Jeff Cody, 2014/05/27
- [Qemu-devel] [PATCH v2 06/11] block: make 'top' argument to block-commit optional, Jeff Cody, 2014/05/27
- [Qemu-devel] [PATCH v2 08/11] block: extend block-commit to accept a string for the backing file, Jeff Cody, 2014/05/27
- [Qemu-devel] [PATCH v2 07/11] block: Accept node-name arguments for block-commit, Jeff Cody, 2014/05/27