diff options
author | Josh Wilsdon <josh@wilsdon.ca> | 2011-09-08 04:39:43 +0000 |
---|---|---|
committer | Josh Wilsdon <josh@wilsdon.ca> | 2011-09-08 04:41:48 +0000 |
commit | 0ab4c4028b301554eb52a23d9c89fc735f4bc844 (patch) | |
tree | c08f5707e357b9a0b33ea0bc1e4cdee093ccefe7 | |
parent | 6a1ac561ef0389adc6e6df141b24f7a9600b9fc2 (diff) | |
download | illumos-kvm-cmd-0ab4c4028b301554eb52a23d9c89fc735f4bc844.tar.gz |
HVM-641 fix regression introduced between qemu 0.12.5 and 0.13.0 which 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
-rw-r--r-- | block/raw-posix.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/block/raw-posix.c b/block/raw-posix.c index a95c8d4..4c7936f 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -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; |