qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: vhdx - force FileOffsetMB field to '0' for certain block states
@ 2015-01-20 21:01 Jeff Cody
  2015-01-22 17:28 ` Max Reitz
  2015-01-23 14:47 ` Max Reitz
  0 siblings, 2 replies; 3+ messages in thread
From: Jeff Cody @ 2015-01-20 21:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, amulya.lokesha, stefanha, mreitz

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>
---
 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.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] block: vhdx - force FileOffsetMB field to '0' for certain block states
  2015-01-20 21:01 [Qemu-devel] [PATCH] block: vhdx - force FileOffsetMB field to '0' for certain block states Jeff Cody
@ 2015-01-22 17:28 ` Max Reitz
  2015-01-23 14:47 ` Max Reitz
  1 sibling, 0 replies; 3+ messages in thread
From: Max Reitz @ 2015-01-22 17:28 UTC (permalink / raw)
  To: Jeff Cody, qemu-devel; +Cc: kwolf, amulya.lokesha, stefanha

On 2015-01-20 at 16:01, Jeff Cody wrote:
> 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>
> ---
>   block/vhdx.c | 13 ++++++++++++-
>   1 file changed, 12 insertions(+), 1 deletion(-)

Reviewed-by: Max Reitz <mreitz@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] block: vhdx - force FileOffsetMB field to '0' for certain block states
  2015-01-20 21:01 [Qemu-devel] [PATCH] block: vhdx - force FileOffsetMB field to '0' for certain block states Jeff Cody
  2015-01-22 17:28 ` Max Reitz
@ 2015-01-23 14:47 ` Max Reitz
  1 sibling, 0 replies; 3+ messages in thread
From: Max Reitz @ 2015-01-23 14:47 UTC (permalink / raw)
  To: Jeff Cody, qemu-devel; +Cc: kwolf, amulya.lokesha, stefanha

On 2015-01-20 at 16:01, Jeff Cody wrote:
> 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>
> ---
>   block/vhdx.c | 13 ++++++++++++-
>   1 file changed, 12 insertions(+), 1 deletion(-)

Thanks, applied to my block tree:

https://github.com/XanClic/qemu/commits/block

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-23 14:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-20 21:01 [Qemu-devel] [PATCH] block: vhdx - force FileOffsetMB field to '0' for certain block states Jeff Cody
2015-01-22 17:28 ` Max Reitz
2015-01-23 14:47 ` Max Reitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).