* [Qemu-devel] [PATCH 02/12] VMDK: bugfix, align offset to cluster in get_whole_cluster
@ 2011-06-04 0:40 Fam Zheng
0 siblings, 0 replies; only message in thread
From: Fam Zheng @ 2011-06-04 0:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi, Christoph Hellwig
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 <famcool@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) {
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-06-04 0:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-04 0:40 [Qemu-devel] [PATCH 02/12] VMDK: bugfix, align offset to cluster in get_whole_cluster Fam Zheng
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).