aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorBenoƮt Canet <benoit.canet@gmail.com>2012-08-02 10:22:47 +0200
committerLuiz Capitulino <lcapitulino@redhat.com>2012-08-03 10:10:38 -0300
commitf198fd1c9aedaae2fa78eb94e236e95ce4f2aedd (patch)
tree3511fe358de0c41a09d8105cb3c5a39375f0568f /block.c
parente0d45df7a5794b6821d2f8893a7f343109debab9 (diff)
block: create bdrv_get_backing_file_depth()
Create bdrv_get_backing_file_depth() in order to be able to show in QMP and HMP how many ancestors backing an image a block device have. Signed-off-by: Benoit Canet <benoit@irqsave.net> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/block.c b/block.c
index b38940bf85..1206bba84d 100644
--- a/block.c
+++ b/block.c
@@ -2754,6 +2754,19 @@ BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs,
return NULL;
}
+int bdrv_get_backing_file_depth(BlockDriverState *bs)
+{
+ if (!bs->drv) {
+ return 0;
+ }
+
+ if (!bs->backing_hd) {
+ return 0;
+ }
+
+ return 1 + bdrv_get_backing_file_depth(bs->backing_hd);
+}
+
#define NB_SUFFIXES 4
char *get_human_readable_size(char *buf, int buf_size, int64_t size)