qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 02/12] VMDK: bugfix, align offset to cluster in get_


From: Fam Zheng
Subject: [Qemu-devel] [PATCH 02/12] VMDK: bugfix, align offset to cluster in get_whole_cluster
Date: Sat, 4 Jun 2011 08:40:41 +0800

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 <address@hidden>
---
 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) {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]