From: Jeff Cody <jcody@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, pbonzini@redhat.com, eblake@redhat.com
Subject: [Qemu-devel] [PATCH v3 4/6] block: helper function, to find the base image of a chain
Date: Thu, 27 Sep 2012 13:29:15 -0400 [thread overview]
Message-ID: <3c535fe93b21e549496e06e36fba141f155f394c.1348760202.git.jcody@redhat.com> (raw)
In-Reply-To: <cover.1348760202.git.jcody@redhat.com>
In-Reply-To: <cover.1348760202.git.jcody@redhat.com>
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>
---
block.c | 16 ++++++++++++++++
block.h | 1 +
2 files changed, 17 insertions(+)
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)
diff --git a/block.h b/block.h
index 8c9b424..e9249c4 100644
--- a/block.h
+++ b/block.h
@@ -207,6 +207,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 {
--
1.7.11.4
next prev parent reply other threads:[~2012-09-27 17:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-27 17:29 [Qemu-devel] [PATCH v3 0/6] Live block commit Jeff Cody
2012-09-27 17:29 ` [Qemu-devel] [PATCH v3 1/6] block: add support functions for live commit, to find and delete images Jeff Cody
2012-09-27 17:29 ` [Qemu-devel] [PATCH v3 2/6] block: add live block commit functionality Jeff Cody
2012-09-27 17:29 ` [Qemu-devel] [PATCH v3 3/6] blockdev: rename block_stream_cb to a generic block_job_cb Jeff Cody
2012-09-27 17:29 ` Jeff Cody [this message]
2012-09-27 17:29 ` [Qemu-devel] [PATCH v3 5/6] QAPI: add command for live block commit, 'block-commit' Jeff Cody
2012-09-27 17:57 ` Eric Blake
2012-09-27 18:01 ` Jeff Cody
2012-09-27 17:29 ` [Qemu-devel] [PATCH v3 6/6] qemu-iotests: add initial tests for live block commit Jeff Cody
2012-09-27 17:58 ` [Qemu-devel] [PATCH v3 0/6] Live " Eric Blake
2012-09-28 18:23 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3c535fe93b21e549496e06e36fba141f155f394c.1348760202.git.jcody@redhat.com \
--to=jcody@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).