qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 07/12] block/dmg: set virtual size to a non-z


From: John Snow
Subject: Re: [Qemu-devel] [PATCH v2 07/12] block/dmg: set virtual size to a non-zero value
Date: Wed, 07 Jan 2015 13:07:12 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0



On 01/06/2015 12:48 PM, Peter Wu wrote:
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 <address@hidden>
---
  v2: fixed typo in commit message (s/mish/koly/)
---
  block/dmg.c | 8 ++++++++
  1 file changed, 8 insertions(+)

diff --git a/block/dmg.c b/block/dmg.c
index 1a0fa0e..57feb1b 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -453,6 +453,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);


You may want to adjust the commit message here to reflect the information in your new cover letter regarding the bug in dmg2img, but that's not worth re-spinning for.

Reviewed-by: John Snow <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]