In get_whole_cluster, the offset is not aligned, to cluster when reading from backing_hd. So if it's the first write to child and the offset is not the cluster boundary, data is copied from parent at a wrong position.
Signed-off-by: Fam Zheng <famc...@gmail.com> --- block/vmdk.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 9442794..f787528 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -489,6 +489,8 @@ static int get_whole_cluster(BlockDriverState *bs, if (!vmdk_is_cid_valid(bs, extent)) return -1; + // floor offset to cluster + offset -= offset % (extent->cluster_sectors * 512); ret = bdrv_read(bs->backing_hd, offset >> 9, whole_grain, extent->cluster_sectors); if (ret < 0) {