The application belongs to the technical field of computer
virtualization storage, and provides a method and
system for detecting the integrity of a qcow2 virtual
disk image file. The qcow2 file header is read, basic
metadata is parsed, and the physical offset of the
data cluster corresponding to the starting position of the virtual disk in the qcow2 file is automatically calculated. The data of a sector at the physical offset is read as a
master boot record (MBR), and MBR
parsing information is obtained. Whether the virtual disk uses a GPT partition scheme is determined according to the MBR. The GPT region is automatically located, parsed and verified, and GPT
parsing information is obtained. The
parsing information, check information and integrity detection information are summarized and output. The application can penetrate the mapping layer of the qcow2 format, directly locate and read the MBR or GPT region of the virtual disk, automatically complete structure parsing, CRC check and integrity judgment, and output the detection result in a clear form.