diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-12-25 15:48:20 +0100 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2014-12-26 22:34:11 +0100 |
commit | c8f5a654dd99cdbdeba271dcf28d2f72a9a03ec5 (patch) | |
tree | 77f29601086a475b9c55797ab5dd9fb604a4957b | |
parent | 14ee1471ef93792473175809ac439a4feeb451c4 (diff) | |
download | qemu-c8f5a654dd99cdbdeba271dcf28d2f72a9a03ec5.tar.gz |
block/dmg: set virtual size to a non-zero value
Right now the virtual size is always reported as zero which makes it
impossible to convert between formats.
After this patch, the number of sectors will be read from the BLXX
("mish") header.
To verify the behavior, the output of `dmg2img foo.dmg foo.img` was
compared against `qemu-img convert -f dmg -O raw foo.dmg foo.raw`. The
tests showed that the file contents are exactly the same, except that
QEMU creates a slightly larger file (it matches the total sectors
count).
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
-rw-r--r-- | block/dmg.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/block/dmg.c b/block/dmg.c index c03ea01b6a..984997f0d9 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -430,6 +430,14 @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags, if (ret < 0) { goto fail; } + ret = read_uint64(bs, offset + 0x1ec, (uint64_t *)&bs->total_sectors); + if (ret < 0) { + goto fail; + } + if (bs->total_sectors < 0) { + ret = -EINVAL; + goto fail; + } if (rsrc_fork_offset != 0 && rsrc_fork_length != 0) { ret = dmg_read_resource_fork(bs, &ds, rsrc_fork_offset, rsrc_fork_length); |