aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2010-01-12 12:55:17 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2010-01-13 17:14:15 -0600
commit756e6736a12a46330d9532d5f861ba15b38886d8 (patch)
treeb8b36409fef483b90fe9a79384aab38e3ea07dd2 /block.c
parentb783e409bf17b92f4af8dc5d6bd040d0092f33e0 (diff)
block: Add bdrv_change_backing_file
Introduce the functions needed to change the backing file of an image. The function is implemented for qcow2. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/block.c b/block.c
index 994109e0b9..c7bc83773a 100644
--- a/block.c
+++ b/block.c
@@ -597,6 +597,26 @@ int bdrv_commit(BlockDriverState *bs)
return 0;
}
+/*
+ * Return values:
+ * 0 - success
+ * -EINVAL - backing format specified, but no file
+ * -ENOSPC - can't update the backing file because no space is left in the
+ * image file header
+ * -ENOTSUP - format driver doesn't support changing the backing file
+ */
+int bdrv_change_backing_file(BlockDriverState *bs,
+ const char *backing_file, const char *backing_fmt)
+{
+ BlockDriver *drv = bs->drv;
+
+ if (drv->bdrv_change_backing_file != NULL) {
+ return drv->bdrv_change_backing_file(bs, backing_file, backing_fmt);
+ } else {
+ return -ENOTSUP;
+ }
+}
+
static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,
size_t size)
{