[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V2 1/3] block: create bdrv_get_backing_file_ancestor
From: |
benoit . canet |
Subject: |
[Qemu-devel] [PATCH V2 1/3] block: create bdrv_get_backing_file_ancestors_count() |
Date: |
Wed, 25 Jul 2012 10:11:39 +0200 |
From: Benoît Canet <address@hidden>
Create bdrv_get_backing_file_ancestors_count() 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 <address@hidden>
---
block.c | 13 +++++++++++++
block.h | 1 +
2 files changed, 14 insertions(+)
diff --git a/block.c b/block.c
index ce7eb8f..03e0860 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_ancestors_count(BlockDriverState *bs)
+{
+ if (!bs->drv) {
+ return 0;
+ }
+
+ if (!bs->backing_hd) {
+ return 0;
+ }
+
+ return 1 + bdrv_get_backing_file_ancestors_count(bs->backing_hd);
+}
+
#define NB_SUFFIXES 4
char *get_human_readable_size(char *buf, int buf_size, int64_t size)
diff --git a/block.h b/block.h
index c89590d..5b1ba2b 100644
--- a/block.h
+++ b/block.h
@@ -174,6 +174,7 @@ int coroutine_fn
bdrv_co_is_allocated_above(BlockDriverState *top,
int nb_sectors, int *pnum);
BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs,
const char *backing_file);
+int bdrv_get_backing_file_ancestors_count(BlockDriverState *bs);
int bdrv_truncate(BlockDriverState *bs, int64_t offset);
int64_t bdrv_getlength(BlockDriverState *bs);
int64_t bdrv_get_allocated_file_size(BlockDriverState *bs);
--
1.7.9.5
[Qemu-devel] [PATCH V2 1/3] block: create bdrv_get_backing_file_ancestors_count(),
benoit . canet <=
[Qemu-devel] [PATCH V2 3/3] hmp: show the backing file ancestors count, benoit . canet, 2012/07/25