xref: /openbmc/qemu/docs/interop/parallels.rst (revision 1bc0fc0a)
1*1bc0fc0aSPeter MaydellParallels Expandable Image File Format
2*1bc0fc0aSPeter Maydell======================================
3*1bc0fc0aSPeter Maydell
4*1bc0fc0aSPeter Maydell..
5*1bc0fc0aSPeter Maydell   Copyright (c) 2015 Denis Lunev
6*1bc0fc0aSPeter Maydell   Copyright (c) 2015 Vladimir Sementsov-Ogievskiy
7*1bc0fc0aSPeter Maydell
8*1bc0fc0aSPeter Maydell   This work is licensed under the terms of the GNU GPL, version 2 or later.
9*1bc0fc0aSPeter Maydell   See the COPYING file in the top-level directory.
10*1bc0fc0aSPeter Maydell
11*1bc0fc0aSPeter Maydell
12*1bc0fc0aSPeter MaydellA Parallels expandable image file consists of three consecutive parts:
13*1bc0fc0aSPeter Maydell
14*1bc0fc0aSPeter Maydell* header
15*1bc0fc0aSPeter Maydell* BAT
16*1bc0fc0aSPeter Maydell* data area
17*1bc0fc0aSPeter Maydell
18*1bc0fc0aSPeter MaydellAll numbers in a Parallels expandable image are stored in little-endian byte
19*1bc0fc0aSPeter Maydellorder.
20*1bc0fc0aSPeter Maydell
21*1bc0fc0aSPeter Maydell
22*1bc0fc0aSPeter MaydellDefinitions
23*1bc0fc0aSPeter Maydell-----------
24*1bc0fc0aSPeter Maydell
25*1bc0fc0aSPeter MaydellSector
26*1bc0fc0aSPeter Maydell  A 512-byte data chunk.
27*1bc0fc0aSPeter Maydell
28*1bc0fc0aSPeter MaydellCluster
29*1bc0fc0aSPeter Maydell  A data chunk of the size specified in the image header.
30*1bc0fc0aSPeter Maydell  Currently, the default size is 1MiB (2048 sectors). In previous
31*1bc0fc0aSPeter Maydell  versions, cluster sizes of 63 sectors, 256 and 252 kilobytes were used.
32*1bc0fc0aSPeter Maydell
33*1bc0fc0aSPeter MaydellBAT
34*1bc0fc0aSPeter Maydell  Block Allocation Table, an entity that contains information for
35*1bc0fc0aSPeter Maydell  guest-to-host I/O data address translation.
36*1bc0fc0aSPeter Maydell
37*1bc0fc0aSPeter MaydellHeader
38*1bc0fc0aSPeter Maydell------
39*1bc0fc0aSPeter Maydell
40*1bc0fc0aSPeter MaydellThe header is placed at the start of an image and contains the following
41*1bc0fc0aSPeter Maydellfields::
42*1bc0fc0aSPeter Maydell
43*1bc0fc0aSPeter Maydell Bytes:
44*1bc0fc0aSPeter Maydell   0 - 15:    magic
45*1bc0fc0aSPeter Maydell              Must contain "WithoutFreeSpace" or "WithouFreSpacExt".
46*1bc0fc0aSPeter Maydell
47*1bc0fc0aSPeter Maydell  16 - 19:    version
48*1bc0fc0aSPeter Maydell              Must be 2.
49*1bc0fc0aSPeter Maydell
50*1bc0fc0aSPeter Maydell  20 - 23:    heads
51*1bc0fc0aSPeter Maydell              Disk geometry parameter for guest.
52*1bc0fc0aSPeter Maydell
53*1bc0fc0aSPeter Maydell  24 - 27:    cylinders
54*1bc0fc0aSPeter Maydell              Disk geometry parameter for guest.
55*1bc0fc0aSPeter Maydell
56*1bc0fc0aSPeter Maydell  28 - 31:    tracks
57*1bc0fc0aSPeter Maydell              Cluster size, in sectors.
58*1bc0fc0aSPeter Maydell
59*1bc0fc0aSPeter Maydell  32 - 35:    nb_bat_entries
60*1bc0fc0aSPeter Maydell              Disk size, in clusters (BAT size).
61*1bc0fc0aSPeter Maydell
62*1bc0fc0aSPeter Maydell  36 - 43:    nb_sectors
63*1bc0fc0aSPeter Maydell              Disk size, in sectors.
64*1bc0fc0aSPeter Maydell
65*1bc0fc0aSPeter Maydell              For "WithoutFreeSpace" images:
66*1bc0fc0aSPeter Maydell              Only the lowest 4 bytes are used. The highest 4 bytes must be
67*1bc0fc0aSPeter Maydell              cleared in this case.
68*1bc0fc0aSPeter Maydell
69*1bc0fc0aSPeter Maydell              For "WithouFreSpacExt" images, there are no such
70*1bc0fc0aSPeter Maydell              restrictions.
71*1bc0fc0aSPeter Maydell
72*1bc0fc0aSPeter Maydell  44 - 47:    in_use
73*1bc0fc0aSPeter Maydell              Set to 0x746F6E59 when the image is opened by software in R/W
74*1bc0fc0aSPeter Maydell              mode; set to 0x312e3276 when the image is closed.
75*1bc0fc0aSPeter Maydell
76*1bc0fc0aSPeter Maydell              A zero in this field means that the image was opened by an old
77*1bc0fc0aSPeter Maydell              version of the software that doesn't support Format Extension
78*1bc0fc0aSPeter Maydell              (see below).
79*1bc0fc0aSPeter Maydell
80*1bc0fc0aSPeter Maydell              Other values are not allowed.
81*1bc0fc0aSPeter Maydell
82*1bc0fc0aSPeter Maydell  48 - 51:    data_off
83*1bc0fc0aSPeter Maydell              An offset, in sectors, from the start of the file to the start of
84*1bc0fc0aSPeter Maydell              the data area.
85*1bc0fc0aSPeter Maydell
86*1bc0fc0aSPeter Maydell              For "WithoutFreeSpace" images:
87*1bc0fc0aSPeter Maydell              - If data_off is zero, the offset is calculated as the end of BAT
88*1bc0fc0aSPeter Maydell                table plus some padding to ensure sector size alignment.
89*1bc0fc0aSPeter Maydell              - If data_off is non-zero, the offset should be aligned to sector
90*1bc0fc0aSPeter Maydell                size. However it is recommended to align it to cluster size for
91*1bc0fc0aSPeter Maydell                newly created images.
92*1bc0fc0aSPeter Maydell
93*1bc0fc0aSPeter Maydell              For "WithouFreSpacExt" images:
94*1bc0fc0aSPeter Maydell              data_off must be non-zero and aligned to cluster size.
95*1bc0fc0aSPeter Maydell
96*1bc0fc0aSPeter Maydell  52 - 55:    flags
97*1bc0fc0aSPeter Maydell              Miscellaneous flags.
98*1bc0fc0aSPeter Maydell
99*1bc0fc0aSPeter Maydell              Bit 0: Empty Image bit. If set, the image should be
100*1bc0fc0aSPeter Maydell                     considered clear.
101*1bc0fc0aSPeter Maydell
102*1bc0fc0aSPeter Maydell              Bits 1-31: Unused.
103*1bc0fc0aSPeter Maydell
104*1bc0fc0aSPeter Maydell  56 - 63:    ext_off
105*1bc0fc0aSPeter Maydell              Format Extension offset, an offset, in sectors, from the start of
106*1bc0fc0aSPeter Maydell              the file to the start of the Format Extension Cluster.
107*1bc0fc0aSPeter Maydell
108*1bc0fc0aSPeter Maydell              ext_off must meet the same requirements as cluster offsets
109*1bc0fc0aSPeter Maydell              defined by BAT entries (see below).
110*1bc0fc0aSPeter Maydell
111*1bc0fc0aSPeter MaydellBAT
112*1bc0fc0aSPeter Maydell---
113*1bc0fc0aSPeter Maydell
114*1bc0fc0aSPeter MaydellBAT is placed immediately after the image header. In the file, BAT is a
115*1bc0fc0aSPeter Maydellcontiguous array of 32-bit unsigned little-endian integers with
116*1bc0fc0aSPeter Maydell``(bat_entries * 4)`` bytes size.
117*1bc0fc0aSPeter Maydell
118*1bc0fc0aSPeter MaydellEach BAT entry contains an offset from the start of the file to the
119*1bc0fc0aSPeter Maydellcorresponding cluster. The offset set in clusters for ``WithouFreSpacExt``
120*1bc0fc0aSPeter Maydellimages and in sectors for ``WithoutFreeSpace`` images.
121*1bc0fc0aSPeter Maydell
122*1bc0fc0aSPeter MaydellIf a BAT entry is zero, the corresponding cluster is not allocated and should
123*1bc0fc0aSPeter Maydellbe considered as filled with zeroes.
124*1bc0fc0aSPeter Maydell
125*1bc0fc0aSPeter MaydellCluster offsets specified by BAT entries must meet the following requirements:
126*1bc0fc0aSPeter Maydell
127*1bc0fc0aSPeter Maydell- the value must not be lower than data offset (provided by ``header.data_off``
128*1bc0fc0aSPeter Maydell  or calculated as specified above)
129*1bc0fc0aSPeter Maydell- the value must be lower than the desired file size
130*1bc0fc0aSPeter Maydell- the value must be unique among all BAT entries
131*1bc0fc0aSPeter Maydell- the result of ``(cluster offset - data offset)`` must be aligned to
132*1bc0fc0aSPeter Maydell  cluster size
133*1bc0fc0aSPeter Maydell
134*1bc0fc0aSPeter MaydellData Area
135*1bc0fc0aSPeter Maydell---------
136*1bc0fc0aSPeter Maydell
137*1bc0fc0aSPeter MaydellThe data area is an area from the data offset (provided by ``header.data_off``
138*1bc0fc0aSPeter Maydellor calculated as specified above) to the end of the file. It represents a
139*1bc0fc0aSPeter Maydellcontiguous array of clusters. Most of them are allocated by the BAT, some may
140*1bc0fc0aSPeter Maydellbe allocated by the ``ext_off`` field in the header while other may be
141*1bc0fc0aSPeter Maydellallocated by extensions. All clusters allocated by ``ext_off`` and extensions
142*1bc0fc0aSPeter Maydellshould meet the same requirements as clusters specified by BAT entries.
143*1bc0fc0aSPeter Maydell
144*1bc0fc0aSPeter Maydell
145*1bc0fc0aSPeter MaydellFormat Extension
146*1bc0fc0aSPeter Maydell----------------
147*1bc0fc0aSPeter Maydell
148*1bc0fc0aSPeter MaydellThe Format Extension is an area 1 cluster in size that provides additional
149*1bc0fc0aSPeter Maydellformat features. This cluster is addressed by the ext_off field in the header.
150*1bc0fc0aSPeter MaydellThe format of the Format Extension area is the following::
151*1bc0fc0aSPeter Maydell
152*1bc0fc0aSPeter Maydell   0 -  7:    magic
153*1bc0fc0aSPeter Maydell              Must be 0xAB234CEF23DCEA87
154*1bc0fc0aSPeter Maydell
155*1bc0fc0aSPeter Maydell   8 - 23:    m_CheckSum
156*1bc0fc0aSPeter Maydell              The MD5 checksum of the entire Header Extension cluster except
157*1bc0fc0aSPeter Maydell              the first 24 bytes.
158*1bc0fc0aSPeter Maydell
159*1bc0fc0aSPeter MaydellThe above are followed by feature sections or "extensions". The last
160*1bc0fc0aSPeter Maydellextension must be "End of features" (see below).
161*1bc0fc0aSPeter Maydell
162*1bc0fc0aSPeter MaydellEach feature section has the following format::
163*1bc0fc0aSPeter Maydell
164*1bc0fc0aSPeter Maydell   0 -  7:    magic
165*1bc0fc0aSPeter Maydell              The identifier of the feature:
166*1bc0fc0aSPeter Maydell              0x0000000000000000 - End of features
167*1bc0fc0aSPeter Maydell              0x20385FAE252CB34A - Dirty bitmap
168*1bc0fc0aSPeter Maydell
169*1bc0fc0aSPeter Maydell   8 - 15:    flags
170*1bc0fc0aSPeter Maydell              External flags for extension:
171*1bc0fc0aSPeter Maydell
172*1bc0fc0aSPeter Maydell              Bit 0: NECESSARY
173*1bc0fc0aSPeter Maydell                     If the software cannot load the extension (due to an
174*1bc0fc0aSPeter Maydell                     unknown magic number or error), the file should not be
175*1bc0fc0aSPeter Maydell                     changed. If this flag is unset and there is an error on
176*1bc0fc0aSPeter Maydell                     loading the extension, said extension should be dropped.
177*1bc0fc0aSPeter Maydell
178*1bc0fc0aSPeter Maydell              Bit 1: TRANSIT
179*1bc0fc0aSPeter Maydell                     If there is an unknown extension with this flag set,
180*1bc0fc0aSPeter Maydell                     said extension should be left as is.
181*1bc0fc0aSPeter Maydell
182*1bc0fc0aSPeter Maydell              If neither NECESSARY nor TRANSIT are set, the extension should be
183*1bc0fc0aSPeter Maydell              dropped.
184*1bc0fc0aSPeter Maydell
185*1bc0fc0aSPeter Maydell  16 - 19:    data_size
186*1bc0fc0aSPeter Maydell              The size of the following feature data, in bytes.
187*1bc0fc0aSPeter Maydell
188*1bc0fc0aSPeter Maydell  20 - 23:    unused32
189*1bc0fc0aSPeter Maydell              Align header to 8 bytes boundary.
190*1bc0fc0aSPeter Maydell
191*1bc0fc0aSPeter Maydell  variable:   data (data_size bytes)
192*1bc0fc0aSPeter Maydell
193*1bc0fc0aSPeter MaydellThe above is followed by padding to the next 8 bytes boundary, then the
194*1bc0fc0aSPeter Maydellnext extension starts.
195*1bc0fc0aSPeter Maydell
196*1bc0fc0aSPeter MaydellThe last extension must be "End of features" with all the fields set to 0.
197*1bc0fc0aSPeter Maydell
198*1bc0fc0aSPeter Maydell
199*1bc0fc0aSPeter MaydellDirty bitmaps feature
200*1bc0fc0aSPeter Maydell---------------------
201*1bc0fc0aSPeter Maydell
202*1bc0fc0aSPeter MaydellThis feature provides a way of storing dirty bitmaps in the image. The fields
203*1bc0fc0aSPeter Maydellof its data area are::
204*1bc0fc0aSPeter Maydell
205*1bc0fc0aSPeter Maydell   0 -  7:    size
206*1bc0fc0aSPeter Maydell              The bitmap size, should be equal to disk size in sectors.
207*1bc0fc0aSPeter Maydell
208*1bc0fc0aSPeter Maydell   8 - 23:    id
209*1bc0fc0aSPeter Maydell              An identifier for backup consistency checking.
210*1bc0fc0aSPeter Maydell
211*1bc0fc0aSPeter Maydell  24 - 27:    granularity
212*1bc0fc0aSPeter Maydell              Bitmap granularity, in sectors. I.e., the number of sectors
213*1bc0fc0aSPeter Maydell              corresponding to one bit of the bitmap. Granularity must be
214*1bc0fc0aSPeter Maydell              a power of 2.
215*1bc0fc0aSPeter Maydell
216*1bc0fc0aSPeter Maydell  28 - 31:    l1_size
217*1bc0fc0aSPeter Maydell              The number of entries in the L1 table of the bitmap.
218*1bc0fc0aSPeter Maydell
219*1bc0fc0aSPeter Maydell  variable:   L1 offset table (l1_table), size: 8 * l1_size bytes
220*1bc0fc0aSPeter Maydell
221*1bc0fc0aSPeter MaydellThe dirty bitmap described by this feature extension is stored in a set of
222*1bc0fc0aSPeter Maydellclusters inside the Parallels image file. The offsets of these clusters are
223*1bc0fc0aSPeter Maydellsaved in the L1 offset table specified by the feature extension. Each L1 table
224*1bc0fc0aSPeter Maydellentry is a 64 bit integer as described below:
225*1bc0fc0aSPeter Maydell
226*1bc0fc0aSPeter MaydellGiven an offset in bytes into the bitmap data, corresponding L1 entry is::
227*1bc0fc0aSPeter Maydell
228*1bc0fc0aSPeter Maydell    l1_table[offset / cluster_size]
229*1bc0fc0aSPeter Maydell
230*1bc0fc0aSPeter MaydellIf an L1 table entry is 0, all bits in the corresponding cluster of the bitmap
231*1bc0fc0aSPeter Maydellare assumed to be 0.
232*1bc0fc0aSPeter Maydell
233*1bc0fc0aSPeter MaydellIf an L1 table entry is 1, all bits in the corresponding cluster of the bitmap
234*1bc0fc0aSPeter Maydellare assumed to be 1.
235*1bc0fc0aSPeter Maydell
236*1bc0fc0aSPeter MaydellIf an L1 table entry is not 0 or 1, it contains the corresponding cluster
237*1bc0fc0aSPeter Maydelloffset (in 512b sectors). Given an offset in bytes into the bitmap data the
238*1bc0fc0aSPeter Maydelloffset in bytes into the image file can be obtained as follows::
239*1bc0fc0aSPeter Maydell
240*1bc0fc0aSPeter Maydell    offset = l1_table[offset / cluster_size] * 512 + (offset % cluster_size)
241