VMDK Support: Probing Mono-Flat
Adding monolithic flat format support into vmdk driver, probe is the simplest and very first point.
BlockDriver.bdrv_probe
is an operation that tests if a target file is a
recognized format by the driver. It returns an int value reporting the
probability. Current vmdk driver reads first 4 bytes of the file and compares
them with two magics, this means only single-sparse with embedded descriptor is
recognized.
Mono-flat is different. The data file is a plain binary with the identical size of represented device, just like a ‘raw‘ format. Besides it is a descriptor file, a text file that describes properties of the image. An example:
# Disk DescriptorFile
version=1
encoding="GBK"
CID=fffffffe
parentCID=ffffffff
isNativeSnapshot="no"
createType="monolithicFlat"
# Extent description
RW 10485760 FLAT "mono-flat-flat.vmdk" 0
# The Disk Data Base
#DDB
ddb.virtualHWVersion = "7"
ddb.longContentID = "2b36576c81b9d468fef11601fffffffe"
ddb.uuid = "60 00 C2 9c 97 97 f2 b8-1d d3 20 ef 16 49 d8 b8"
ddb.geometry.cylinders = "10402"
ddb.geometry.heads = "16"
ddb.geometry.sectors = "63"
ddb.adapterType = "ide"
For very basic probe, createType
and RW 10485760 FLAT “mono-flat-flat.vmdk”
0
lines give enough information. createType
is monolithicFlat
and there is
a FLAT extent description, the driver can accept the format.
As an optional check, we can also verify the extent size is big enough, or test reading/writing the extent file.