@@ -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 */
@@ -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 {