提交 79fac568 编写于 作者: J Jeff Cody 提交者: Kevin Wolf

block: helper function, to find the base image of a chain

This is a simple helper function, that will return the base image
of a given image chain.
Signed-off-by: NJeff Cody <jcody@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 9abf2dba
...@@ -3117,6 +3117,22 @@ int bdrv_get_backing_file_depth(BlockDriverState *bs) ...@@ -3117,6 +3117,22 @@ int bdrv_get_backing_file_depth(BlockDriverState *bs)
return 1 + bdrv_get_backing_file_depth(bs->backing_hd); return 1 + bdrv_get_backing_file_depth(bs->backing_hd);
} }
BlockDriverState *bdrv_find_base(BlockDriverState *bs)
{
BlockDriverState *curr_bs = NULL;
if (!bs) {
return NULL;
}
curr_bs = bs;
while (curr_bs->backing_hd) {
curr_bs = curr_bs->backing_hd;
}
return curr_bs;
}
#define NB_SUFFIXES 4 #define NB_SUFFIXES 4
char *get_human_readable_size(char *buf, int buf_size, int64_t size) char *get_human_readable_size(char *buf, int buf_size, int64_t size)
......
...@@ -207,6 +207,7 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top, ...@@ -207,6 +207,7 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top,
BlockDriverState *base); BlockDriverState *base);
BlockDriverState *bdrv_find_overlay(BlockDriverState *active, BlockDriverState *bdrv_find_overlay(BlockDriverState *active,
BlockDriverState *bs); BlockDriverState *bs);
BlockDriverState *bdrv_find_base(BlockDriverState *bs);
typedef struct BdrvCheckResult { typedef struct BdrvCheckResult {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册