Permalink
Browse files

HVM-641 fix regression introduced between qemu 0.12.5 and 0.13.0 whic…

…h broke qemu-img for vmdk4 images.

In versions previous to 0.13.0 this code used lseek to seek to offset
and read instead of pread.  The lseek only happened when offset was >=0
with the change to pread the logic for checking whether offset was
negative was lost which broke vmdk4 support.  This offset check here
will have the same result as the old (working) code.

The upstream qemu commit that broke this functionality was:

    commit 4899d10d142e97eea8f64141a3507b2ee1a64f52
    Author: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
    Date:   Mon Apr 19 13:34:11 2010 +0100

and the code has been confirmed to still be broken in qemu 0.15.0rc0
  • Loading branch information...
1 parent 6a1ac56 commit 0ab4c4028b301554eb52a23d9c89fc735f4bc844 @joshwilsdon joshwilsdon committed Sep 8, 2011
Showing with 10 additions and 0 deletions.
  1. +10 −0 block/raw-posix.c
View
@@ -262,6 +262,16 @@ static int raw_pread_aligned(BlockDriverState *bs, int64_t offset,
if (ret < 0)
return ret;
+ /*
+ * In versions previous to 0.13.0 this code used lseek to seek to offset
+ * and read instead of pread. The lseek only happened when offset was >=0
+ * with the change to pread the logic for checking whether offset was
+ * negative was lost which broke vmdk4 support. This offset check here
+ * will have the same result as the old (working) code.
+ */
+ if (offset < 0)
+ offset = 0;
+
ret = pread(s->fd, buf, count, offset);
if (ret == count)
return ret;

0 comments on commit 0ab4c40

Please sign in to comment.