]> Git Repo - qemu.git/commitdiff
block/dmg: set virtual size to a non-zero value
authorPeter Wu <[email protected]>
Tue, 6 Jan 2015 17:48:10 +0000 (18:48 +0100)
committerKevin Wolf <[email protected]>
Fri, 6 Feb 2015 16:24:21 +0000 (17:24 +0100)
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 trailer
("koly" block).

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 <[email protected]>
Reviewed-by: John Snow <[email protected]>
Message-id: 1420566495[email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
block/dmg.c

index a78506ad77a718904430798c87d75b46a69c156b..a33c131a9ff9d4a345ed56d35a37a376d5c7ae61 100644 (file)
@@ -452,6 +452,14 @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
         ret = -EINVAL;
         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_length != 0) {
         ret = dmg_read_resource_fork(bs, &ds,
                                      rsrc_fork_offset, rsrc_fork_length);
This page took 0.026762 seconds and 4 git commands to generate.