root / block / vhdx.h @ cc84d90f
History | View | Annotate | Download (14.8 kB)
1 | 203cdba3 | Jeff Cody | /*
|
---|---|---|---|
2 | 203cdba3 | Jeff Cody | * Block driver for Hyper-V VHDX Images
|
3 | 203cdba3 | Jeff Cody | *
|
4 | 203cdba3 | Jeff Cody | * Copyright (c) 2013 Red Hat, Inc.,
|
5 | 203cdba3 | Jeff Cody | *
|
6 | 203cdba3 | Jeff Cody | * Authors:
|
7 | 203cdba3 | Jeff Cody | * Jeff Cody <jcody@redhat.com>
|
8 | 203cdba3 | Jeff Cody | *
|
9 | 203cdba3 | Jeff Cody | * This is based on the "VHDX Format Specification v0.95", published 4/12/2012
|
10 | 203cdba3 | Jeff Cody | * by Microsoft:
|
11 | 203cdba3 | Jeff Cody | * https://www.microsoft.com/en-us/download/details.aspx?id=29681
|
12 | 203cdba3 | Jeff Cody | *
|
13 | 203cdba3 | Jeff Cody | * This work is licensed under the terms of the GNU LGPL, version 2 or later.
|
14 | 203cdba3 | Jeff Cody | * See the COPYING.LIB file in the top-level directory.
|
15 | 203cdba3 | Jeff Cody | *
|
16 | 203cdba3 | Jeff Cody | */
|
17 | 203cdba3 | Jeff Cody | |
18 | 203cdba3 | Jeff Cody | #ifndef BLOCK_VHDX_H
|
19 | 203cdba3 | Jeff Cody | #define BLOCK_VHDX_H
|
20 | 203cdba3 | Jeff Cody | |
21 | 203cdba3 | Jeff Cody | /* Structures and fields present in the VHDX file */
|
22 | 203cdba3 | Jeff Cody | |
23 | 203cdba3 | Jeff Cody | /* The header section has the following blocks,
|
24 | 203cdba3 | Jeff Cody | * each block is 64KB:
|
25 | 203cdba3 | Jeff Cody | *
|
26 | 203cdba3 | Jeff Cody | * _____________________________________________________________________________
|
27 | 203cdba3 | Jeff Cody | * | File Id. | Header 1 | Header 2 | Region Table | Reserved (768KB) |
|
28 | 203cdba3 | Jeff Cody | * |----------|---------------|------------|--------------|--------------------|
|
29 | 203cdba3 | Jeff Cody | * | | | | | |
|
30 | 203cdba3 | Jeff Cody | * 0.........64KB...........128KB........192KB..........256KB................1MB
|
31 | 203cdba3 | Jeff Cody | */
|
32 | 203cdba3 | Jeff Cody | |
33 | 203cdba3 | Jeff Cody | #define VHDX_HEADER_BLOCK_SIZE (64*1024) |
34 | 203cdba3 | Jeff Cody | |
35 | 203cdba3 | Jeff Cody | #define VHDX_FILE_ID_OFFSET 0 |
36 | 203cdba3 | Jeff Cody | #define VHDX_HEADER1_OFFSET (VHDX_HEADER_BLOCK_SIZE*1) |
37 | 203cdba3 | Jeff Cody | #define VHDX_HEADER2_OFFSET (VHDX_HEADER_BLOCK_SIZE*2) |
38 | 203cdba3 | Jeff Cody | #define VHDX_REGION_TABLE_OFFSET (VHDX_HEADER_BLOCK_SIZE*3) |
39 | 203cdba3 | Jeff Cody | |
40 | 203cdba3 | Jeff Cody | |
41 | 203cdba3 | Jeff Cody | /*
|
42 | 203cdba3 | Jeff Cody | * A note on the use of MS-GUID fields. For more details on the GUID,
|
43 | 203cdba3 | Jeff Cody | * please see: https://en.wikipedia.org/wiki/Globally_unique_identifier.
|
44 | 203cdba3 | Jeff Cody | *
|
45 | 203cdba3 | Jeff Cody | * The VHDX specification only states that these are MS GUIDs, and which
|
46 | 203cdba3 | Jeff Cody | * bytes are data1-data4. It makes no mention of what algorithm should be used
|
47 | 203cdba3 | Jeff Cody | * to generate the GUID, nor what standard. However, looking at the specified
|
48 | 203cdba3 | Jeff Cody | * known GUID fields, it appears the GUIDs are:
|
49 | 203cdba3 | Jeff Cody | * Standard/DCE GUID type (noted by 10b in the MSB of byte 0 of .data4)
|
50 | 203cdba3 | Jeff Cody | * Random algorithm (noted by 0x4XXX for .data3)
|
51 | 203cdba3 | Jeff Cody | */
|
52 | 203cdba3 | Jeff Cody | |
53 | 203cdba3 | Jeff Cody | /* ---- HEADER SECTION STRUCTURES ---- */
|
54 | 203cdba3 | Jeff Cody | |
55 | 203cdba3 | Jeff Cody | /* These structures are ones that are defined in the VHDX specification
|
56 | 203cdba3 | Jeff Cody | * document */
|
57 | 203cdba3 | Jeff Cody | |
58 | 203cdba3 | Jeff Cody | typedef struct VHDXFileIdentifier { |
59 | 203cdba3 | Jeff Cody | uint64_t signature; /* "vhdxfile" in ASCII */
|
60 | 203cdba3 | Jeff Cody | uint16_t creator[256]; /* optional; utf-16 string to identify |
61 | 203cdba3 | Jeff Cody | the vhdx file creator. Diagnotistic
|
62 | 203cdba3 | Jeff Cody | only */
|
63 | 203cdba3 | Jeff Cody | } VHDXFileIdentifier; |
64 | 203cdba3 | Jeff Cody | |
65 | 203cdba3 | Jeff Cody | |
66 | 203cdba3 | Jeff Cody | /* the guid is a 16 byte unique ID - the definition for this used by
|
67 | 203cdba3 | Jeff Cody | * Microsoft is not just 16 bytes though - it is a structure that is defined,
|
68 | 203cdba3 | Jeff Cody | * so we need to follow it here so that endianness does not trip us up */
|
69 | 203cdba3 | Jeff Cody | |
70 | 203cdba3 | Jeff Cody | typedef struct MSGUID { |
71 | 203cdba3 | Jeff Cody | uint32_t data1; |
72 | 203cdba3 | Jeff Cody | uint16_t data2; |
73 | 203cdba3 | Jeff Cody | uint16_t data3; |
74 | 203cdba3 | Jeff Cody | uint8_t data4[8];
|
75 | 203cdba3 | Jeff Cody | } MSGUID; |
76 | 203cdba3 | Jeff Cody | |
77 | 203cdba3 | Jeff Cody | #define guid_eq(a, b) \
|
78 | 203cdba3 | Jeff Cody | (memcmp(&(a), &(b), sizeof(MSGUID)) == 0) |
79 | 203cdba3 | Jeff Cody | |
80 | 203cdba3 | Jeff Cody | #define VHDX_HEADER_SIZE (4*1024) /* although the vhdx_header struct in disk |
81 | 203cdba3 | Jeff Cody | is only 582 bytes, for purposes of crc
|
82 | 203cdba3 | Jeff Cody | the header is the first 4KB of the 64KB
|
83 | 203cdba3 | Jeff Cody | block */
|
84 | 203cdba3 | Jeff Cody | |
85 | 203cdba3 | Jeff Cody | /* The full header is 4KB, although the actual header data is much smaller.
|
86 | 203cdba3 | Jeff Cody | * But for the checksum calculation, it is over the entire 4KB structure,
|
87 | 203cdba3 | Jeff Cody | * not just the defined portion of it */
|
88 | 203cdba3 | Jeff Cody | typedef struct QEMU_PACKED VHDXHeader { |
89 | 203cdba3 | Jeff Cody | uint32_t signature; /* "head" in ASCII */
|
90 | 203cdba3 | Jeff Cody | uint32_t checksum; /* CRC-32C hash of the whole header */
|
91 | 203cdba3 | Jeff Cody | uint64_t sequence_number; /* Seq number of this header. Each
|
92 | 203cdba3 | Jeff Cody | VHDX file has 2 of these headers,
|
93 | 203cdba3 | Jeff Cody | and only the header with the highest
|
94 | 203cdba3 | Jeff Cody | sequence number is valid */
|
95 | 203cdba3 | Jeff Cody | MSGUID file_write_guid; /* 128 bit unique identifier. Must be
|
96 | 203cdba3 | Jeff Cody | updated to new, unique value before
|
97 | 203cdba3 | Jeff Cody | the first modification is made to
|
98 | 203cdba3 | Jeff Cody | file */
|
99 | 203cdba3 | Jeff Cody | MSGUID data_write_guid; /* 128 bit unique identifier. Must be
|
100 | 203cdba3 | Jeff Cody | updated to new, unique value before
|
101 | 203cdba3 | Jeff Cody | the first modification is made to
|
102 | 203cdba3 | Jeff Cody | visible data. Visbile data is
|
103 | 203cdba3 | Jeff Cody | defined as:
|
104 | 203cdba3 | Jeff Cody | - system & user metadata
|
105 | 203cdba3 | Jeff Cody | - raw block data
|
106 | 203cdba3 | Jeff Cody | - disk size
|
107 | 203cdba3 | Jeff Cody | - any change that will
|
108 | 203cdba3 | Jeff Cody | cause the virtual disk
|
109 | 203cdba3 | Jeff Cody | sector read to differ
|
110 | 203cdba3 | Jeff Cody | |
111 | 203cdba3 | Jeff Cody | This does not need to change if
|
112 | 203cdba3 | Jeff Cody | blocks are re-arranged */
|
113 | 203cdba3 | Jeff Cody | MSGUID log_guid; /* 128 bit unique identifier. If zero,
|
114 | 203cdba3 | Jeff Cody | there is no valid log. If non-zero,
|
115 | 203cdba3 | Jeff Cody | log entries with this guid are
|
116 | 203cdba3 | Jeff Cody | valid. */
|
117 | 203cdba3 | Jeff Cody | uint16_t log_version; /* version of the log format. Mustn't be
|
118 | 203cdba3 | Jeff Cody | zero, unless log_guid is also zero */
|
119 | 203cdba3 | Jeff Cody | uint16_t version; /* version of th evhdx file. Currently,
|
120 | 203cdba3 | Jeff Cody | only supported version is "1" */
|
121 | 203cdba3 | Jeff Cody | uint32_t log_length; /* length of the log. Must be multiple
|
122 | 203cdba3 | Jeff Cody | of 1MB */
|
123 | 203cdba3 | Jeff Cody | uint64_t log_offset; /* byte offset in the file of the log.
|
124 | 203cdba3 | Jeff Cody | Must also be a multiple of 1MB */
|
125 | 203cdba3 | Jeff Cody | } VHDXHeader; |
126 | 203cdba3 | Jeff Cody | |
127 | 203cdba3 | Jeff Cody | /* Header for the region table block */
|
128 | 203cdba3 | Jeff Cody | typedef struct QEMU_PACKED VHDXRegionTableHeader { |
129 | 203cdba3 | Jeff Cody | uint32_t signature; /* "regi" in ASCII */
|
130 | 203cdba3 | Jeff Cody | uint32_t checksum; /* CRC-32C hash of the 64KB table */
|
131 | 203cdba3 | Jeff Cody | uint32_t entry_count; /* number of valid entries */
|
132 | 203cdba3 | Jeff Cody | uint32_t reserved; |
133 | 203cdba3 | Jeff Cody | } VHDXRegionTableHeader; |
134 | 203cdba3 | Jeff Cody | |
135 | 203cdba3 | Jeff Cody | /* Individual region table entry. There may be a maximum of 2047 of these
|
136 | 203cdba3 | Jeff Cody | *
|
137 | 203cdba3 | Jeff Cody | * There are two known region table properties. Both are required.
|
138 | 203cdba3 | Jeff Cody | * BAT (block allocation table): 2DC27766F62342009D64115E9BFD4A08
|
139 | 203cdba3 | Jeff Cody | * Metadata: 8B7CA20647904B9AB8FE575F050F886E
|
140 | 203cdba3 | Jeff Cody | */
|
141 | 203cdba3 | Jeff Cody | #define VHDX_REGION_ENTRY_REQUIRED 0x01 /* if set, parser must understand |
142 | 203cdba3 | Jeff Cody | this entry in order to open
|
143 | 203cdba3 | Jeff Cody | file */
|
144 | 203cdba3 | Jeff Cody | typedef struct QEMU_PACKED VHDXRegionTableEntry { |
145 | 203cdba3 | Jeff Cody | MSGUID guid; /* 128-bit unique identifier */
|
146 | 203cdba3 | Jeff Cody | uint64_t file_offset; /* offset of the object in the file.
|
147 | 203cdba3 | Jeff Cody | Must be multiple of 1MB */
|
148 | 203cdba3 | Jeff Cody | uint32_t length; /* length, in bytes, of the object */
|
149 | 203cdba3 | Jeff Cody | uint32_t data_bits; |
150 | 203cdba3 | Jeff Cody | } VHDXRegionTableEntry; |
151 | 203cdba3 | Jeff Cody | |
152 | 203cdba3 | Jeff Cody | |
153 | 203cdba3 | Jeff Cody | /* ---- LOG ENTRY STRUCTURES ---- */
|
154 | 203cdba3 | Jeff Cody | #define VHDX_LOG_HDR_SIZE 64 |
155 | 203cdba3 | Jeff Cody | typedef struct QEMU_PACKED VHDXLogEntryHeader { |
156 | 203cdba3 | Jeff Cody | uint32_t signature; /* "loge" in ASCII */
|
157 | 203cdba3 | Jeff Cody | uint32_t checksum; /* CRC-32C hash of the 64KB table */
|
158 | 203cdba3 | Jeff Cody | uint32_t entry_length; /* length in bytes, multiple of 1MB */
|
159 | 203cdba3 | Jeff Cody | uint32_t tail; /* byte offset of first log entry of a
|
160 | 203cdba3 | Jeff Cody | seq, where this entry is the last
|
161 | 203cdba3 | Jeff Cody | entry */
|
162 | 203cdba3 | Jeff Cody | uint64_t sequence_number; /* incremented with each log entry.
|
163 | 203cdba3 | Jeff Cody | May not be zero. */
|
164 | 203cdba3 | Jeff Cody | uint32_t descriptor_count; /* number of descriptors in this log
|
165 | 203cdba3 | Jeff Cody | entry, must be >= 0 */
|
166 | 203cdba3 | Jeff Cody | uint32_t reserved; |
167 | 203cdba3 | Jeff Cody | MSGUID log_guid; /* value of the log_guid from
|
168 | 203cdba3 | Jeff Cody | vhdx_header. If not found in
|
169 | 203cdba3 | Jeff Cody | vhdx_header, it is invalid */
|
170 | 203cdba3 | Jeff Cody | uint64_t flushed_file_offset; /* see spec for full details - this
|
171 | 52f35022 | Stefan Weil | should be vhdx file size in bytes */
|
172 | 203cdba3 | Jeff Cody | uint64_t last_file_offset; /* size in bytes that all allocated
|
173 | 203cdba3 | Jeff Cody | file structures fit into */
|
174 | 203cdba3 | Jeff Cody | } VHDXLogEntryHeader; |
175 | 203cdba3 | Jeff Cody | |
176 | 203cdba3 | Jeff Cody | #define VHDX_LOG_DESC_SIZE 32 |
177 | 203cdba3 | Jeff Cody | |
178 | 203cdba3 | Jeff Cody | typedef struct QEMU_PACKED VHDXLogDescriptor { |
179 | 203cdba3 | Jeff Cody | uint32_t signature; /* "zero" or "desc" in ASCII */
|
180 | 203cdba3 | Jeff Cody | union {
|
181 | 203cdba3 | Jeff Cody | uint32_t reserved; /* zero desc */
|
182 | 203cdba3 | Jeff Cody | uint32_t trailing_bytes; /* data desc: bytes 4092-4096 of the
|
183 | 203cdba3 | Jeff Cody | data sector */
|
184 | 203cdba3 | Jeff Cody | }; |
185 | 203cdba3 | Jeff Cody | union {
|
186 | 203cdba3 | Jeff Cody | uint64_t zero_length; /* zero desc: length of the section to
|
187 | 203cdba3 | Jeff Cody | zero */
|
188 | 203cdba3 | Jeff Cody | uint64_t leading_bytes; /* data desc: bytes 0-7 of the data
|
189 | 203cdba3 | Jeff Cody | sector */
|
190 | 203cdba3 | Jeff Cody | }; |
191 | 203cdba3 | Jeff Cody | uint64_t file_offset; /* file offset to write zeros - multiple
|
192 | 203cdba3 | Jeff Cody | of 4kB */
|
193 | 203cdba3 | Jeff Cody | uint64_t sequence_number; /* must match same field in
|
194 | 203cdba3 | Jeff Cody | vhdx_log_entry_header */
|
195 | 203cdba3 | Jeff Cody | } VHDXLogDescriptor; |
196 | 203cdba3 | Jeff Cody | |
197 | 203cdba3 | Jeff Cody | typedef struct QEMU_PACKED VHDXLogDataSector { |
198 | 203cdba3 | Jeff Cody | uint32_t data_signature; /* "data" in ASCII */
|
199 | 203cdba3 | Jeff Cody | uint32_t sequence_high; /* 4 MSB of 8 byte sequence_number */
|
200 | 203cdba3 | Jeff Cody | uint8_t data[4084]; /* raw data, bytes 8-4091 (inclusive). |
201 | 203cdba3 | Jeff Cody | see the data descriptor field for the
|
202 | 203cdba3 | Jeff Cody | other mising bytes */
|
203 | 203cdba3 | Jeff Cody | uint32_t sequence_low; /* 4 LSB of 8 byte sequence_number */
|
204 | 203cdba3 | Jeff Cody | } VHDXLogDataSector; |
205 | 203cdba3 | Jeff Cody | |
206 | 203cdba3 | Jeff Cody | |
207 | 203cdba3 | Jeff Cody | |
208 | 203cdba3 | Jeff Cody | /* block states - different state values depending on whether it is a
|
209 | 203cdba3 | Jeff Cody | * payload block, or a sector block. */
|
210 | 203cdba3 | Jeff Cody | |
211 | 203cdba3 | Jeff Cody | #define PAYLOAD_BLOCK_NOT_PRESENT 0 |
212 | 203cdba3 | Jeff Cody | #define PAYLOAD_BLOCK_UNDEFINED 1 |
213 | 203cdba3 | Jeff Cody | #define PAYLOAD_BLOCK_ZERO 2 |
214 | 203cdba3 | Jeff Cody | #define PAYLOAD_BLOCK_UNMAPPED 5 |
215 | 203cdba3 | Jeff Cody | #define PAYLOAD_BLOCK_FULL_PRESENT 6 |
216 | 203cdba3 | Jeff Cody | #define PAYLOAD_BLOCK_PARTIALLY_PRESENT 7 |
217 | 203cdba3 | Jeff Cody | |
218 | 203cdba3 | Jeff Cody | #define SB_BLOCK_NOT_PRESENT 0 |
219 | 203cdba3 | Jeff Cody | #define SB_BLOCK_PRESENT 6 |
220 | 203cdba3 | Jeff Cody | |
221 | 203cdba3 | Jeff Cody | /* per the spec */
|
222 | 203cdba3 | Jeff Cody | #define VHDX_MAX_SECTORS_PER_BLOCK (1<<23) |
223 | 203cdba3 | Jeff Cody | |
224 | 203cdba3 | Jeff Cody | /* upper 44 bits are the file offset in 1MB units lower 3 bits are the state
|
225 | 203cdba3 | Jeff Cody | other bits are reserved */
|
226 | 203cdba3 | Jeff Cody | #define VHDX_BAT_STATE_BIT_MASK 0x07 |
227 | 203cdba3 | Jeff Cody | #define VHDX_BAT_FILE_OFF_BITS (64-44) |
228 | 203cdba3 | Jeff Cody | typedef uint64_t VHDXBatEntry;
|
229 | 203cdba3 | Jeff Cody | |
230 | 203cdba3 | Jeff Cody | /* ---- METADATA REGION STRUCTURES ---- */
|
231 | 203cdba3 | Jeff Cody | |
232 | 203cdba3 | Jeff Cody | #define VHDX_METADATA_ENTRY_SIZE 32 |
233 | 203cdba3 | Jeff Cody | #define VHDX_METADATA_MAX_ENTRIES 2047 /* not including the header */ |
234 | 203cdba3 | Jeff Cody | #define VHDX_METADATA_TABLE_MAX_SIZE \
|
235 | 203cdba3 | Jeff Cody | (VHDX_METADATA_ENTRY_SIZE * (VHDX_METADATA_MAX_ENTRIES+1))
|
236 | 203cdba3 | Jeff Cody | typedef struct QEMU_PACKED VHDXMetadataTableHeader { |
237 | 203cdba3 | Jeff Cody | uint64_t signature; /* "metadata" in ASCII */
|
238 | 203cdba3 | Jeff Cody | uint16_t reserved; |
239 | 203cdba3 | Jeff Cody | uint16_t entry_count; /* number table entries. <= 2047 */
|
240 | 203cdba3 | Jeff Cody | uint32_t reserved2[5];
|
241 | 203cdba3 | Jeff Cody | } VHDXMetadataTableHeader; |
242 | 203cdba3 | Jeff Cody | |
243 | 203cdba3 | Jeff Cody | #define VHDX_META_FLAGS_IS_USER 0x01 /* max 1024 entries */ |
244 | 203cdba3 | Jeff Cody | #define VHDX_META_FLAGS_IS_VIRTUAL_DISK 0x02 /* virtual disk metadata if set, |
245 | 203cdba3 | Jeff Cody | otherwise file metdata */
|
246 | 203cdba3 | Jeff Cody | #define VHDX_META_FLAGS_IS_REQUIRED 0x04 /* parse must understand this |
247 | 203cdba3 | Jeff Cody | entry to open the file */
|
248 | 203cdba3 | Jeff Cody | typedef struct QEMU_PACKED VHDXMetadataTableEntry { |
249 | 203cdba3 | Jeff Cody | MSGUID item_id; /* 128-bit identifier for metadata */
|
250 | 203cdba3 | Jeff Cody | uint32_t offset; /* byte offset of the metadata. At
|
251 | 203cdba3 | Jeff Cody | least 64kB. Relative to start of
|
252 | 203cdba3 | Jeff Cody | metadata region */
|
253 | 203cdba3 | Jeff Cody | /* note: if length = 0, so is offset */
|
254 | 203cdba3 | Jeff Cody | uint32_t length; /* length of metadata. <= 1MB. */
|
255 | 203cdba3 | Jeff Cody | uint32_t data_bits; /* least-significant 3 bits are flags, the
|
256 | 203cdba3 | Jeff Cody | rest are reserved (see above) */
|
257 | 203cdba3 | Jeff Cody | uint32_t reserved2; |
258 | 203cdba3 | Jeff Cody | } VHDXMetadataTableEntry; |
259 | 203cdba3 | Jeff Cody | |
260 | 203cdba3 | Jeff Cody | #define VHDX_PARAMS_LEAVE_BLOCKS_ALLOCED 0x01 /* Do not change any blocks to |
261 | 203cdba3 | Jeff Cody | be BLOCK_NOT_PRESENT.
|
262 | 203cdba3 | Jeff Cody | If set indicates a fixed
|
263 | 203cdba3 | Jeff Cody | size VHDX file */
|
264 | 203cdba3 | Jeff Cody | #define VHDX_PARAMS_HAS_PARENT 0x02 /* has parent / backing file */ |
265 | 203cdba3 | Jeff Cody | typedef struct QEMU_PACKED VHDXFileParameters { |
266 | 203cdba3 | Jeff Cody | uint32_t block_size; /* size of each payload block, always
|
267 | 203cdba3 | Jeff Cody | power of 2, <= 256MB and >= 1MB. */
|
268 | 203cdba3 | Jeff Cody | uint32_t data_bits; /* least-significant 2 bits are flags, the rest
|
269 | 203cdba3 | Jeff Cody | are reserved (see above) */
|
270 | 203cdba3 | Jeff Cody | } VHDXFileParameters; |
271 | 203cdba3 | Jeff Cody | |
272 | 203cdba3 | Jeff Cody | typedef struct QEMU_PACKED VHDXVirtualDiskSize { |
273 | 203cdba3 | Jeff Cody | uint64_t virtual_disk_size; /* Size of the virtual disk, in bytes.
|
274 | 203cdba3 | Jeff Cody | Must be multiple of the sector size,
|
275 | 203cdba3 | Jeff Cody | max of 64TB */
|
276 | 203cdba3 | Jeff Cody | } VHDXVirtualDiskSize; |
277 | 203cdba3 | Jeff Cody | |
278 | 203cdba3 | Jeff Cody | typedef struct QEMU_PACKED VHDXPage83Data { |
279 | 203cdba3 | Jeff Cody | MSGUID page_83_data[16]; /* unique id for scsi devices that |
280 | 203cdba3 | Jeff Cody | support page 0x83 */
|
281 | 203cdba3 | Jeff Cody | } VHDXPage83Data; |
282 | 203cdba3 | Jeff Cody | |
283 | 203cdba3 | Jeff Cody | typedef struct QEMU_PACKED VHDXVirtualDiskLogicalSectorSize { |
284 | 203cdba3 | Jeff Cody | uint32_t logical_sector_size; /* virtual disk sector size (in bytes).
|
285 | 203cdba3 | Jeff Cody | Can only be 512 or 4096 bytes */
|
286 | 203cdba3 | Jeff Cody | } VHDXVirtualDiskLogicalSectorSize; |
287 | 203cdba3 | Jeff Cody | |
288 | 203cdba3 | Jeff Cody | typedef struct QEMU_PACKED VHDXVirtualDiskPhysicalSectorSize { |
289 | 203cdba3 | Jeff Cody | uint32_t physical_sector_size; /* physical sector size (in bytes).
|
290 | 203cdba3 | Jeff Cody | Can only be 512 or 4096 bytes */
|
291 | 203cdba3 | Jeff Cody | } VHDXVirtualDiskPhysicalSectorSize; |
292 | 203cdba3 | Jeff Cody | |
293 | 203cdba3 | Jeff Cody | typedef struct QEMU_PACKED VHDXParentLocatorHeader { |
294 | 203cdba3 | Jeff Cody | MSGUID locator_type[16]; /* type of the parent virtual disk. */ |
295 | 203cdba3 | Jeff Cody | uint16_t reserved; |
296 | 203cdba3 | Jeff Cody | uint16_t key_value_count; /* number of key/value pairs for this
|
297 | 203cdba3 | Jeff Cody | locator */
|
298 | 203cdba3 | Jeff Cody | } VHDXParentLocatorHeader; |
299 | 203cdba3 | Jeff Cody | |
300 | 203cdba3 | Jeff Cody | /* key and value strings are UNICODE strings, UTF-16 LE encoding, no NULs */
|
301 | 203cdba3 | Jeff Cody | typedef struct QEMU_PACKED VHDXParentLocatorEntry { |
302 | 203cdba3 | Jeff Cody | uint32_t key_offset; /* offset in metadata for key, > 0 */
|
303 | 203cdba3 | Jeff Cody | uint32_t value_offset; /* offset in metadata for value, >0 */
|
304 | 203cdba3 | Jeff Cody | uint16_t key_length; /* length of entry key, > 0 */
|
305 | 203cdba3 | Jeff Cody | uint16_t value_length; /* length of entry value, > 0 */
|
306 | 203cdba3 | Jeff Cody | } VHDXParentLocatorEntry; |
307 | 203cdba3 | Jeff Cody | |
308 | 203cdba3 | Jeff Cody | |
309 | 203cdba3 | Jeff Cody | /* ----- END VHDX SPECIFICATION STRUCTURES ---- */
|
310 | 203cdba3 | Jeff Cody | |
311 | e8d4e5ff | Jeff Cody | |
312 | e8d4e5ff | Jeff Cody | uint32_t vhdx_checksum_calc(uint32_t crc, uint8_t *buf, size_t size, |
313 | e8d4e5ff | Jeff Cody | int crc_offset);
|
314 | e8d4e5ff | Jeff Cody | |
315 | e8d4e5ff | Jeff Cody | bool vhdx_checksum_is_valid(uint8_t *buf, size_t size, int crc_offset); |
316 | e8d4e5ff | Jeff Cody | |
317 | e8d4e5ff | Jeff Cody | |
318 | e8d4e5ff | Jeff Cody | static void leguid_to_cpus(MSGUID *guid) |
319 | e8d4e5ff | Jeff Cody | { |
320 | e8d4e5ff | Jeff Cody | le32_to_cpus(&guid->data1); |
321 | e8d4e5ff | Jeff Cody | le16_to_cpus(&guid->data2); |
322 | e8d4e5ff | Jeff Cody | le16_to_cpus(&guid->data3); |
323 | e8d4e5ff | Jeff Cody | } |
324 | e8d4e5ff | Jeff Cody | |
325 | 203cdba3 | Jeff Cody | #endif |