tools: qemu: Add patches to support adapter_type and monolithicFlat
[openwrt/staging/mkresin.git] / tools / qemu / patches / 0003-VMDK-bugfix-align-offset-to-cluster-in-get_whole_clu.patch
1 From 66922efc83a670178b208dec2f5123ec85fb6ba3 Mon Sep 17 00:00:00 2001
2 From: Fam Zheng <famcool@gmail.com>
3 Date: Tue, 12 Jul 2011 19:56:29 +0800
4 Subject: [PATCH 03/12] VMDK: bugfix, align offset to cluster in
5 get_whole_cluster
6
7 In get_whole_cluster, the offset is not aligned to cluster when reading
8 from backing_hd. When the first write to child is not at the cluster
9 boundary, wrong address data from parent is copied to child.
10
11 Signed-off-by: Fam Zheng <famcool@gmail.com>
12 Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 ---
15 block/vmdk.c | 8 +++++---
16 1 file changed, 5 insertions(+), 3 deletions(-)
17
18 --- a/block/vmdk.c
19 +++ b/block/vmdk.c
20 @@ -514,21 +514,23 @@ static int get_whole_cluster(BlockDriver
21 /* 128 sectors * 512 bytes each = grain size 64KB */
22 uint8_t whole_grain[extent->cluster_sectors * 512];
23
24 - // we will be here if it's first write on non-exist grain(cluster).
25 - // try to read from parent image, if exist
26 + /* we will be here if it's first write on non-exist grain(cluster).
27 + * try to read from parent image, if exist */
28 if (bs->backing_hd) {
29 int ret;
30
31 if (!vmdk_is_cid_valid(bs))
32 return -1;
33
34 + /* floor offset to cluster */
35 + offset -= offset % (extent->cluster_sectors * 512);
36 ret = bdrv_read(bs->backing_hd, offset >> 9, whole_grain,
37 extent->cluster_sectors);
38 if (ret < 0) {
39 return -1;
40 }
41
42 - //Write grain only into the active image
43 + /* Write grain only into the active image */
44 ret = bdrv_write(extent->file, cluster_offset, whole_grain,
45 extent->cluster_sectors);
46 if (ret < 0) {