[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/8] block: helper function, to find the base image
From: |
Jeff Cody |
Subject: |
[Qemu-devel] [PATCH 5/8] block: helper function, to find the base image of a chain |
Date: |
Fri, 14 Sep 2012 09:41:10 -0400 |
This is a simple helper function, that will return the base image
of a given image chain.
Signed-off-by: Jeff Cody <address@hidden>
---
block.c | 16 ++++++++++++++++
block.h | 1 +
2 files changed, 17 insertions(+)
diff --git a/block.c b/block.c
index 9549eca..f19c1dd 100644
--- a/block.c
+++ b/block.c
@@ -3113,6 +3113,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)
diff --git a/block.h b/block.h
index 54a074d..c256211 100644
--- a/block.h
+++ b/block.h
@@ -213,6 +213,7 @@ int bdrv_drop_intermediate(BlockDriverState *active,
BlockDriverState *top,
BlockDriverState *base);
BlockDriverState *bdrv_find_overlay(BlockDriverState *active,
BlockDriverState *bs);
+BlockDriverState *bdrv_find_base(BlockDriverState *bs);
typedef struct BdrvCheckResult {
int corruptions;
--
1.7.11.4
- [Qemu-devel] [PATCH 3/8] blockdev: rename block_stream_cb to a generic block_job_cb, (continued)
- [Qemu-devel] [PATCH 3/8] blockdev: rename block_stream_cb to a generic block_job_cb, Jeff Cody, 2012/09/14
- [Qemu-devel] [PATCH 4/8] qerror: new error for live block commit, QERR_TOP_NOT_FOUND, Jeff Cody, 2012/09/14
- [Qemu-devel] [PATCH 6/8] QAPI: add command for live block commit, 'block-commit', Jeff Cody, 2012/09/14
- [Qemu-devel] [PATCH 8/8] block: after creating a live snapshot, make old image read-only, Jeff Cody, 2012/09/14
- [Qemu-devel] [PATCH 1/8] block: add support functions for live commit, to find and delete images., Jeff Cody, 2012/09/14
- [Qemu-devel] [PATCH 5/8] block: helper function, to find the base image of a chain,
Jeff Cody <=
- [Qemu-devel] [PATCH 7/8] qemu-iotests: add initial tests for live block commit, Jeff Cody, 2012/09/14