Patchwork block: write checksum back to footer after check

login
register
mail settings
Submitter Zhang Shengju
Date March 13, 2012, 2:38 p.m.
Message ID <4F5F5BD5.7090705@gmail.com>
Download mbox | patch
Permalink /patch/146416/
State New
Headers show

Comments

Zhang Shengju - March 13, 2012, 2:38 p.m.
After validation check, the 'checksum' is not written back
to footer, which leave it with zero.

This results in errors while loadding it under Microsoft's
Hyper-V environment, and also errors from utilities like
Citrix's vhd-util.

Signed-off-by: Zhang Shengju <sean_zhang@trendmicro.com.cn>
---
 block/vpc.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Kevin Wolf - March 13, 2012, 2:58 p.m.
Am 13.03.2012 15:38, schrieb Zhang Shengju:
> After validation check, the 'checksum' is not written back
> to footer, which leave it with zero.
> 
> This results in errors while loadding it under Microsoft's
> Hyper-V environment, and also errors from utilities like
> Citrix's vhd-util.
> 
> Signed-off-by: Zhang Shengju <sean_zhang@trendmicro.com.cn>

Thanks, applied to the block branch.

Kevin

Patch

diff --git a/block/vpc.c b/block/vpc.c
index 6b4816f..12aecd4 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -189,6 +189,9 @@  static int vpc_open(BlockDriverState *bs, int flags)
         fprintf(stderr, "block-vpc: The header checksum of '%s' is "
             "incorrect.\n", bs->filename);

+    /* Write 'checksum' back to footer, or else will leave it with zero. */
+    footer->checksum = be32_to_cpu(checksum);
+
     // The visible size of a image in Virtual PC depends on the geometry
     // rather than on the size stored in the footer (the size in the footer
     // is too large usually)