aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorJeff Cody <jcody@redhat.com>2012-09-27 13:29:15 -0400
committerKevin Wolf <kwolf@redhat.com>2012-09-28 18:23:44 +0200
commit79fac5680d3680c9fb43d14a8d4e39ced25530f8 (patch)
treef3f04e78df6c336f55c8d0fccc1847540fffc2de /block.c
parent9abf2dbaf6ae990c498ec0245986bddcd6b013ea (diff)
downloadqemu-79fac5680d3680c9fb43d14a8d4e39ced25530f8.zip
qemu-79fac5680d3680c9fb43d14a8d4e39ced25530f8.tar.gz
qemu-79fac5680d3680c9fb43d14a8d4e39ced25530f8.tar.bz2
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: Jeff Cody <jcody@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/block.c b/block.c
index 54209a5..d7a6d14 100644
--- a/block.c
+++ b/block.c
@@ -3117,6 +3117,22 @@ int bdrv_get_backing_file_depth(BlockDriverState *bs)
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
char *get_human_readable_size(char *buf, int buf_size, int64_t size)