All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com
Subject: [Qemu-devel] [PULL 11/12] block: vhdx - force FileOffsetMB field to '0' for certain block states
Date: Fri, 23 Jan 2015 19:20:17 +0100	[thread overview]
Message-ID: <1422037218-31855-12-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1422037218-31855-1-git-send-email-kwolf@redhat.com>

From: Jeff Cody <jcody@redhat.com>

The v1.0.0 spec calls out PAYLOAD_BLOCK_ZERO FileOffsetMB field as being
'reserved'.  In practice, this means that Hyper-V will fail to read a
disk image with PAYLOAD_BLOCK_ZERO block states with a FileOffsetMB
value other than 0.

The other states that indicate a block that is not there
(PAYLOAD_BLOCK_UNDEFINED, PAYLOAD_BLOCK_NOT_PRESENT,
 PAYLOAD_BLOCK_UNMAPPED) have multiple options for what FileOffsetMB may
be set to, and '0' is explicitly called out as an option.

For all the above states, we will also just set the FileOffsetMB value
to 0.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: a9fe92f53f07e6ab1693811e4312c0d1e958500b.1421787566.git.jcody@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/vhdx.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/block/vhdx.c b/block/vhdx.c
index 06f2b1a..bb3ed45 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -1174,7 +1174,18 @@ static void vhdx_update_bat_table_entry(BlockDriverState *bs, BDRVVHDXState *s,
 {
     /* The BAT entry is a uint64, with 44 bits for the file offset in units of
      * 1MB, and 3 bits for the block state. */
-    s->bat[sinfo->bat_idx]  = sinfo->file_offset;
+    if ((state == PAYLOAD_BLOCK_ZERO)        ||
+        (state == PAYLOAD_BLOCK_UNDEFINED)   ||
+        (state == PAYLOAD_BLOCK_NOT_PRESENT) ||
+        (state == PAYLOAD_BLOCK_UNMAPPED)) {
+        s->bat[sinfo->bat_idx]  = 0;  /* For PAYLOAD_BLOCK_ZERO, the
+                                         FileOffsetMB field is denoted as
+                                         'reserved' in the v1.0 spec.  If it is
+                                         non-zero, MS Hyper-V will fail to read
+                                         the disk image */
+    } else {
+        s->bat[sinfo->bat_idx]  = sinfo->file_offset;
+    }
 
     s->bat[sinfo->bat_idx] |= state & VHDX_BAT_STATE_BIT_MASK;
 
-- 
1.8.3.1

  parent reply	other threads:[~2015-01-23 18:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23 18:20 [Qemu-devel] [PULL 00/12] Block patches Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 01/12] virtio-blk: Pass req to virtio_blk_handle_scsi_req Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 02/12] virtio-blk: Use blk_aio_ioctl Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 03/12] qcow2: Add two more unalignment checks Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 04/12] iotests: Add tests for more corruption cases Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 05/12] block: vmdk - make ret variable usage clear Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 06/12] block: vmdk - move string allocations from stack to the heap Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 07/12] block: qapi - move string allocation " Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 08/12] block: remove unused variable in bdrv_commit Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 09/12] block: mirror - change string allocation to 2-bytes Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 10/12] block: update string sizes for filename, backing_file, exact_filename Kevin Wolf
2015-01-23 18:20 ` Kevin Wolf [this message]
2015-01-23 18:20 ` [Qemu-devel] [PULL 12/12] iotests: Lower 064's memory usage Kevin Wolf
2015-01-26 10:16 ` [Qemu-devel] [PULL 00/12] Block patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1422037218-31855-12-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.