Received: from eggs.gnu.org ([2001:4830:134:3::10]:41092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEiqW-0002a7-MM for qemu-devel@nongnu.org; Fri, 23 Jan 2015 13:20:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEiqV-0000uc-8D for qemu-devel@nongnu.org; Fri, 23 Jan 2015 13:20:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39202) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEiqU-0000u2-TK for qemu-devel@nongnu.org; Fri, 23 Jan 2015 13:20:39 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0NIKbXP032284 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 23 Jan 2015 13:20:38 -0500 From: Kevin Wolf Date: Fri, 23 Jan 2015 19:20:17 +0100 Message-Id: <1422037218-31855-12-git-send-email-kwolf@redhat.com> In-Reply-To: <1422037218-31855-1-git-send-email-kwolf@redhat.com> References: <1422037218-31855-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 11/12] block: vhdx - force FileOffsetMB field to '0' for certain block states List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com From: Jeff Cody 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 Reviewed-by: Max Reitz Message-id: a9fe92f53f07e6ab1693811e4312c0d1e958500b.1421787566.git.jcody@redhat.com Signed-off-by: Max Reitz --- 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