aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-05-08 16:51:41 +0200
committerKevin Wolf <kwolf@redhat.com>2012-05-10 10:32:12 +0200
commite023b2e244ddcc25308309d20c6bfd037897b10c (patch)
tree154bfaea2368cfcbb39a2d2610dd9019510a14ff /block.c
parent93e9eb6808c886f5f1c903b7ced1eed65de2ba39 (diff)
block: fix snapshot on QED
QED's opaque data includes a pointer back to the BlockDriverState. This breaks when bdrv_append shuffles data between bs_new and bs_top. To avoid this, add a "rebind" function that tells the driver about the new relationship between the BlockDriverState and its opaque. The patch also adds rebind to VVFAT for completeness, even though it is not used with live snapshots. Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/block.c b/block.c
index 3db84cd241..87600a54dd 100644
--- a/block.c
+++ b/block.c
@@ -949,6 +949,13 @@ void bdrv_make_anon(BlockDriverState *bs)
bs->device_name[0] = '\0';
}
+static void bdrv_rebind(BlockDriverState *bs)
+{
+ if (bs->drv && bs->drv->bdrv_rebind) {
+ bs->drv->bdrv_rebind(bs);
+ }
+}
+
/*
* Add new bs contents at the top of an image chain while the chain is
* live, while keeping required fields on the top layer.
@@ -1037,6 +1044,9 @@ void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top)
bs_new->slice_time = 0;
bs_new->slice_start = 0;
bs_new->slice_end = 0;
+
+ bdrv_rebind(bs_new);
+ bdrv_rebind(bs_top);
}
void bdrv_delete(BlockDriverState *bs)