[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 03/22] block: vhdx - account for identical header sec
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 03/22] block: vhdx - account for identical header sections |
Date: |
Mon, 19 May 2014 16:22:21 +0200 |
From: Jeff Cody <address@hidden>
The VHDX spec v1.00 declares that "a header is current if it is the only
valid header or if it is valid and its SequenceNumber field is greater
than the other header’s SequenceNumber field. The parser must only use
data from the current header. If there is no current header, then the
VHDX file is corrupt."
However, the Disk2VHD tool from Microsoft creates a VHDX image file that
has 2 identical headers, including matching checksums and matching
sequence numbers. Likely, as a shortcut the tool is just writing the
header twice, for the active and inactive headers, during the image
creation. Technically, this should be considered a corrupt VHDX file
(at least per the 1.00 spec, and that is how we currently treat it).
But in order to accomodate images created with Disk2VHD, we can safely
create an exception for this case. If we find identical sequence
numbers, then we check the VHDXHeader-sized chunks of each 64KB header
sections (we won't rely just on the crc32c to indicate the headers are
the same). If they are identical, then we go ahead and use the first
one.
Reported-by: Nerijus Baliūnas <address@hidden>
Signed-off-by: Jeff Cody <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/vhdx.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/block/vhdx.c b/block/vhdx.c
index 509baaf..353c74d 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -473,7 +473,14 @@ static void vhdx_parse_header(BlockDriverState *bs,
BDRVVHDXState *s,
} else if (h2_seq > h1_seq) {
s->curr_header = 1;
} else {
- goto fail;
+ /* The Microsoft Disk2VHD tool will create 2 identical
+ * headers, with identical sequence numbers. If the headers are
+ * identical, don't consider the file corrupt */
+ if (!memcmp(header1, header2, sizeof(VHDXHeader))) {
+ s->curr_header = 0;
+ } else {
+ goto fail;
+ }
}
}
--
1.8.3.1
- [Qemu-devel] [PULL 00/22] Block patches, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 02/22] Remove g_sequence_lookup from qemu-img help function, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 05/22] qdict: Add qdict_join(), Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 06/22] check-qdict: Add test for qdict_join(), Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 04/22] block: add test for vhdx image created by Disk2VHD, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 01/22] block: Fix bdrv_is_allocated() for short backing files, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 03/22] block: vhdx - account for identical header sections,
Kevin Wolf <=
- [Qemu-devel] [PULL 08/22] iotests: Add test for the JSON protocol, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 09/22] qemu-iotests: Fix core dump suppression in test 039, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 07/22] block: Allow JSON filenames, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 10/22] qemu-iotests: Fix blkdebug in VM drive in 030, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 14/22] curl: Add usage documentation, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 12/22] curl: Remove broken parsing of options from url, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 11/22] curl: Fix build when curl_multi_socket_action isn't available, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 15/22] qcow1: Make padding in the header explicit, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 16/22] qcow1: Check maximum cluster size, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 13/22] curl: Add sslverify option, Kevin Wolf, 2014/05/19