Method and system for detecting integrity of qcow2 virtual disk image file

By directly parsing the file header of the qcow2 virtual disk image file, automatically calculating the physical offset, locating and reading the MBR or GPT region, the problem of difficulty in detecting the integrity of qcow2 format virtual machine disk image files in existing technologies is solved, achieving efficient and accurate detection results.

CN121301074BActive Publication Date: 2026-03-20KYLIN CORP
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-11
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

Existing technologies cannot effectively detect the integrity of the MBR and GPT partition tables in qcow2 format virtual machine disk image files, especially when the virtual machine fails to start. Furthermore, existing methods are cumbersome, error-prone, and inefficient.

Method used

By directly reading the file header of the qcow2 virtual disk image file, parsing the basic metadata, automatically calculating the physical offset, directly locating and reading the MBR or GPT region, performing structural parsing and CRC verification, and outputting the detection results.

Benefits of technology

It enables the detection of MBR and GPT integrity without starting a virtual machine, improving detection efficiency and accuracy, simplifying the operation process, and filling the functional gap in image management tools.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121301074B_ABST
    Figure CN121301074B_ABST
Patent Text Reader

Abstract

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.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of computer virtualization storage, and particularly relates to a method and system for detecting integrity of a qcow2 format virtual machine disk image file. BACKGROUND

[0002] With the popularity of cloud computing and virtualization technology, the qcow2 format, as the mainstream disk image format of the QEMU / KVM virtualization platform, is widely used. The qcow2 format maps virtual disk data through multi-level L1 and L2 table structures, realizing advanced functions such as write-time copy, dynamic expansion, and snapshot, but also making the original virtual disk data stored internally no longer linearly continuous as in the raw format image.

[0003] In the process of qcow2 format disk management and system startup, the master boot record (MBR) and the hard disk partition table (MBR partition table or globally unique partition table GPT) are crucial data structures, which record the partition information and startup code of the disk. Once the MBR partition table or GPT partition table is damaged, it will directly cause the virtual machine to fail to start or the data partition to be inaccessible.

[0004] At present, the methods for detecting the integrity of the MBR and hard disk partition table of the qcow2 format virtual machine disk image file all have certain defects, which are described as follows:

[0005] 1. Using internal commands of the virtual machine:

[0006] Such as fdisk -l or parted commands, these methods need to start the virtual machine first, and then the block device information is read by the operating system inside the virtual machine.

[0007] The defect of this method is that when the MBR / GPT is severely damaged and the virtual machine cannot start, this method will completely fail. In addition, they show the results after the operating system kernel parses, not the original disk sector records, and may not expose subtle errors in the underlying data structure.

[0008] 2. Using image management tools:

[0009] Such as the image management tool qemu-img check, which is mainly used to check the consistency and correctness of the metadata (such as L1 / L2 table, reference count) of the qcow2 image file.

[0010] The defect of this method is that the detection range of the image management tool generally stops at the format level of the image file, and does not deeply parse the MBR or GPT data structure of the virtual disk carried inside the image file, so it cannot find logical errors or damage of the virtual disk partition table.

[0011] 3. Manual analysis:

[0012] The skilled person can manually parse the qcow2 format specification, write a script or use a binary editor to first calculate the physical offset of the data cluster where the MBR / GPT of the virtual disk is located in the qcow2 file according to the L1 / L2 table, and then extract the data for verification.

[0013] However, this method is extremely tedious, error-prone, inefficient, and requires high professional technical knowledge of the operator, and cannot be used as a routine operation and maintenance means. SUMMARY

[0014] The purpose of the present application is to provide a method and system for detecting the integrity of a qcow2 virtual disk image file, which 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 verification and integrity judgment, and output the detection results in a clear form.

[0015] In order to achieve the above purpose, the technical scheme of the present application is as follows:

[0016] A method for detecting the integrity of a qcow2 virtual disk image file, comprising:

[0017] S1, reading the file header of the qcow2 virtual disk image file, and parsing the basic metadata including cluster size and L1 table offset;

[0018] S2, automatically calculating the physical offset of the data cluster corresponding to the starting position of the virtual disk in the qcow2 virtual disk image file according to the basic metadata;

[0019] S3, reading the data of a sector from the physical offset as the master boot record MBR for parsing and verification, and obtaining MBR parsing information;

[0020] S4, judging whether the virtual disk uses the GPT partition scheme according to the master boot record MBR, if yes, entering step S5, otherwise entering step S6;

[0021] S5, automatically locating and parsing the GPT region and verifying, and obtaining GPT parsing information;

[0022] S6, summarizing and outputting the parsing information, verification information and integrity detection information.

[0023] Further, step S2 comprises:

[0024] S201, reading the L1 table;

[0025] S202、According to the sector number of the virtual disk, the corresponding L2 table index is calculated, and the corresponding L2 table item is found from the L1 table;

[0026] S203, read the L2 table, and find the corresponding data cluster table item according to the intra-cluster offset;

[0027] S204, analyze the data cluster table item to obtain the actual physical offset of the corresponding data cluster in the qcow2 virtual disk image file.

[0028] Further, the method of parsing and verifying in step S3 comprises:

[0029] S301, parse the master boot record (MBR) structure, including boot code, disk signature, and partition table item;

[0030] S302, verify the integrity of the MBR structure;

[0031] S303, output the MBR parsing information including disk signature, starting sector, size, and type of each partition table.

[0032] Further, the method of verifying the integrity of the MBR structure in step S302 comprises verifying whether the MBR end flag is 0x55AA.

[0033] Further, the method of judging whether the virtual disk uses the GPT partition scheme in step S4 comprises:

[0034] Check the type code of the partition table item in the MBR. If the type code is 0xEE, it indicates that the virtual disk uses the GPT partition scheme.

[0035] Further, step S5 comprises:

[0036] S501, according to the basic metadata, automatically calculate the physical offset of the data cluster corresponding to the GPT header position in the qcow2 virtual disk image file, and read the GPT header data;

[0037] S502, parse the GPT header structure, including GPT signature, version, header size, header CRC32 checksum, main GPT position, backup GPT position, partition table starting LBA, partition table item number and size, and partition table CRC32 checksum;

[0038] S503, recalculate the CRC32 checksum of the GPT header data and compare it with the parsed header CRC32 checksum to verify the integrity of the GPT header data;

[0039] S504, according to the information of the GPT header, locate the partition table region, calculate the physical offset of the partition table region in the qcow2 virtual disk image file, and read the partition table data;

[0040] S505, recalculate the CRC32 check value of the read partition table data, and compare it with the partition table CRC32 check value recorded in the GPT header to verify the integrity of the entire partition table;

[0041] S506, output the GPT analysis information including disk GUID, partition table GUID, unique GUID of each partition, type GUID, start and end LBA, attribute and name.

[0042] Further, the final detection report is summarized and output in step S6, the report shows the GPT analysis information and / or MBR analysis information, CRC check result and integrity status; for the case of check failure or structure abnormality, clear error identification and prompt are carried out.

[0043] Another aspect of the present application also provides a system for detecting the integrity of a qcow2 virtual disk image file, comprising:

[0044] qcow2 analysis engine: reading the file header of the qcow2 virtual disk image file, and analyzing the basic metadata including cluster size and L1 table offset; according to the basic metadata, automatically calculating the physical offset of the data cluster corresponding to the starting position of the virtual disk in the qcow2 virtual disk image file;

[0045] MBR processing module: reading one sector of data from the physical offset as the master boot record MBR for analysis and verification to obtain MBR analysis information;

[0046] GPT processing module: judging whether the virtual disk uses GPT partition scheme according to the master boot record MBR, if yes, automatically positioning the GPT region and performing analysis and verification to obtain GPT analysis information; otherwise, jumping to the output module;

[0047] Output module: summarizing and outputting the analysis information, check information and integrity detection information.

[0048] The present application also provides a computer readable storage medium, the storage medium stores a computer program, the computer program is used for executing the above-mentioned method for detecting the integrity of the qcow2 virtual disk image file.

[0049] The present application also provides a computer product comprising a computer program, the computer program is executed by a processor to realize the above-mentioned method for detecting the integrity of the qcow2 virtual disk image file.

[0050] Compared with the prior art, the present invention has the following beneficial effects:

[0051] 1. No need to start the virtual machine for detection: This invention operates directly on the qcow2 image file on the host machine. Even if the virtual disk is damaged and the virtual machine cannot start, detection can still be performed, which greatly improves the efficiency of operation and maintenance and troubleshooting.

[0052] 2. Achieving directness and accuracy: This invention directly reads and analyzes the MBR / GPT sector data at the lowest level of the virtual disk, avoiding the deviations that may be caused by indirectly obtaining information through the operating system kernel, resulting in more original and accurate results.

[0053] 3. Achieving automation and high efficiency: This invention automatically completes the entire process from qcow2 format parsing to partition table verification, eliminating the need for manual offset calculation and manual verification. It simplifies complex technical operations into a single command, resulting in high speed and efficiency.

[0054] 4. Highly targeted functionality: This invention fills the functional gap in conventional image management tools, specifically designed to detect the integrity of the data structure inside a virtual disk. It complements existing tools and together they form a more comprehensive virtual machine disk health detection system. Attached Figure Description

[0055] Figure 1 This is a flowchart of Embodiment 1 of the present invention;

[0056] Figure 2 This is a schematic diagram of the L1 / L2 table lookup process in Embodiment 2 of the present invention;

[0057] Figure 3 This is a flowchart of the automatic location, analysis, and verification of the GPT region in Embodiment 4 of the present invention. Detailed Implementation

[0058] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other.

[0059] The present invention will now be described in detail with reference to specific embodiments and accompanying drawings.

[0060] Example 1:

[0061] like Figure 1 As shown, the method for detecting the integrity of the qcow2 virtual disk image file proposed in Embodiment 1 specifically includes the following:

[0062] S1. Read the header of the qcow2 virtual disk image file and parse out the basic metadata, including the cluster size and L1 table offset.

[0063] The method described in the embodiment can be implemented by developing a command line tool, which can be written in C language and rely on the qcow2 format parsing library in the QEMU project or implement the related parsing logic by itself.

[0064] The first step of the parsing requires inputting the path of the qcow2 virtual disk image file, reading the file header of the file according to the path, and parsing the basic metadata such as cluster size and L1 table offset.

[0065] S2. Automatically calculating the physical offset of the data cluster corresponding to the starting position of the virtual disk in the qcow2 virtual disk image file according to the basic metadata.

[0066] According to the qcow2 format specification, the starting position of the virtual disk is usually the 0th sector, so this step automatically calculates the physical offset of the data cluster corresponding to the starting position of the virtual disk, i.e., the 0th sector, in the qcow2 file.

[0067] S3. Reading the data of a sector from the physical offset as the master boot record (MBR) for parsing and verification to obtain MBR parsing information.

[0068] This step reads the data of a sector from the physical offset obtained in step S2, and the sector is usually 512 bytes, so after reading the data of 512 bytes of the sector, it is processed as a master boot record.

[0069] S4. Judging whether the virtual disk uses the GPT partition scheme according to the master boot record (MBR), if yes, entering step S5, otherwise entering step S6.

[0070] The type code of the partition table entry in the master boot record (MBR) can be used to determine the type of the partition table. If the GPT partition scheme is used, the virtual disk contains a protective MBR, and the type code of the MBR partition table entry is 0xEE. Therefore, this step checks the type code of the partition table entry in the MBR to determine whether the virtual disk uses the MBR partition scheme or the GPT partition scheme. If the type code is 0xEE, it indicates that the virtual disk uses the GPT partition scheme.

[0071] S5. Automatically positioning the GPT region and performing parsing and verification to obtain GPT parsing information.

[0072] This step calculates the physical offset according to the GPT specification, parses the GPT header structure, performs integrity verification, and obtains GPT parsing information.

[0073] S6. Summarizing and outputting the parsing information, verification information and integrity detection information.

[0074] In this step, the final detection report is summarized and output. The report shows the parsing information of MBR and GPT, the CRC check result (pass / fail), and the overall integrity status in a readable format (such as plain text, JSON, or XML). For cases of check failure or structural abnormalities, clear error identification and prompts are provided.

[0075] The method described in this embodiment detects the integrity of the qcow2 virtual disk image file without starting the virtual machine, directly reads and analyzes, realizes the directness and accuracy of the detection result, improves the detection efficiency through automation, and has strong function pertinence, which is specially used for detecting the data structure integrity inside the virtual disk.

[0076] Embodiment 2:

[0077] This embodiment further refines step S2 based on embodiment 1 and details the process of calculating the physical offset.

[0078] The process specifically embodies the L1 / L2 table query process of the qcow2 format, as shown in Figure 2 , which includes:

[0079] S201: Read the L1 table.

[0080] As can be seen in Figure 2 , the L1 table offset in the basic metadata obtained from the qcow2 file header is used to read the L1 table data.

[0081] S202: Calculate the corresponding L2 table index according to the sector number of the virtual disk, and find the corresponding L2 table item from the L1 table.

[0082] As shown in Figure 2 , the L1 table records the L2 table offset, and the L2 table data can be read according to the L2 table offset.

[0083] S203: Read the L2 table and find the corresponding data cluster table item according to the intra-cluster offset.

[0084] As shown in Figure 2 , the L2 table stores the offset of each data cluster, which can be obtained by reading the L2 table.

[0085] S204: Analyze the data cluster table item to obtain the actual physical offset of the 0th sector data of the virtual disk in the qcow2 file.

[0086] This embodiment provides a method for querying the actual physical offset for directly detecting the qcow2 image file on the host machine, which can be directly queried even if the virtual machine is not started, greatly improving the efficiency of operation and troubleshooting.

[0087] Embodiment 3:

[0088] This embodiment is based on embodiment 1, and step S3 is refined, and the process of analyzing and verifying the main boot record MBR is described in detail.

[0089] The process specifically includes:

[0090] S301: Analyze the MBR structure, including boot code, disk signature, and partition table entries (four).

[0091] The boot code is located at the beginning, responsible for loading the operating system startup program; the disk signature is located 4 bytes after the boot code, serving as the unique identifier for writing the disk; the partition table entries (4) are each 16 bytes, recording partition information: the end flag is in the last 2 bytes, with a fixed value of 0x55AA, used to verify the integrity of the MBR.

[0092] S302: Verify the integrity of the MBR structure.

[0093] The last 2 bytes of the end flag have a fixed value of 0x55AA, so the operation of verifying the integrity of the MBR structure at least includes verifying whether the MBR end flag is 0x55AA.

[0094] S303: Output the analysis results of the MBR, including the disk signature, the start sector, size, and type of each partition table, etc.

[0095] This embodiment directly reads and analyzes the MBR data at the bottom layer of the virtual disk, which can avoid the bias that may be caused by indirectly obtaining information through the operating system kernel, and the results are more original and accurate.

[0096] Embodiment 4:

[0097] This embodiment is based on embodiment 1, and step S5 is refined, and the process of automatically positioning the GPT region and performing analysis and verification is described in detail.

[0098] The process specifically includes: Figure 3 as shown, specifically including:

[0099] S501, according to the basic metadata, automatically calculate the physical offset of the data cluster corresponding to the GPT header position in the qcow2 virtual disk image file, and read the GPT header data.

[0100] According to the GPT specification, the main GPT header is located at the first sector (LBA1) of the virtual disk. The physical offset of LBA1 in the qcow2 file is calculated using the method of step S2, and the sector data is read.

[0101] S502, parse the GPT header structure, including GPT signature, version, header size, header CRC32 checksum, main GPT location, backup GPT location, partition table start LBA, partition table item quantity and size, partition table CRC32 checksum.

[0102] S503, recalculate the CRC32 checksum of the GPT header data, and compare it with the parsed header CRC32 checksum to verify the integrity of the GPT header data.

[0103] S504, according to the information of GPT header, locate the partition table area, calculate the physical offset of partition table area in qcow2 virtual disk image file, and read partition table data.

[0104] S505, recalculate the CRC32 checksum of the read partition table data, and compare it with the partition table CRC32 checksum recorded in the GPT header to verify the integrity of the entire partition table.

[0105] S506, output GPT analysis information including disk GUID, partition table GUID, unique GUID of each partition, type GUID, start and end LBA, attributes and name.

[0106] The embodiment directly reads and analyzes the GPT sector data at the bottom layer of the virtual disk, which can avoid the deviation caused by indirectly obtaining information through the operating system kernel, and the result is more original and accurate.

[0107] Embodiment 5:

[0108] The embodiment provides a system for detecting the integrity of a qcow2 virtual disk image file, comprising:

[0109] qcow2 analysis engine: read the file header of the qcow2 virtual disk image file, and parse the basic metadata including cluster size and L1 table offset; according to the basic metadata, automatically calculate the physical offset of the data cluster corresponding to the starting position of the virtual disk in the qcow2 virtual disk image file;

[0110] MBR processing module: read one sector of data from the physical offset as the master boot record MBR for analysis and verification, and obtain MBR analysis information;

[0111] GPT processing module: determine whether the virtual disk uses GPT partition scheme according to the master boot record MBR, if yes, automatically locate the GPT area and perform analysis and verification to obtain GPT analysis information; otherwise, jump to the output module;

[0112] Output module: summarize and output analysis information, verification information and integrity detection information.

[0113] The qcow2 parsing engine comprises:

[0114] reading the L1 table; calculating the corresponding L2 table index according to the sector number of the virtual disk, and finding the corresponding L2 table item from the L1 table; reading the L2 table, and finding the corresponding data cluster table item according to the intra-cluster offset; parsing the data cluster table item to obtain the actual physical offset of the data cluster corresponding to the starting position in the qcow2 virtual disk image file.

[0115] The MBR processing module comprises:

[0116] parsing the master boot record (MBR) structure, including boot code, disk signature, and partition table item; verifying the integrity of the MBR structure; and outputting MBR parsing information including the disk signature, the starting sector, size, and type of each partition table. The verification of the integrity of the MBR structure comprises verifying whether the MBR end flag is 0x55AA.

[0117] The GPT processing module comprises:

[0118] checking the type code of the partition table item in the MBR, and if the type code is 0xEE, indicating that the virtual disk uses the GPT partition scheme; automatically calculating the physical offset of the data cluster corresponding to the GPT header position in the qcow2 virtual disk image file according to the basic metadata, and reading the GPT header data; parsing the GPT header structure, including the GPT signature, version, header size, header CRC32 check value, main GPT position, backup GPT position, partition table starting LBA, partition table item quantity and size, and partition table CRC32 check value; recalculating the CRC32 check value of the GPT header data and comparing it with the parsed header CRC32 check value to verify the integrity of the GPT header data; locating the partition table region according to the information of the GPT header, calculating the physical offset of the partition table region in the qcow2 virtual disk image file, and reading the partition table data; recalculating the CRC32 check value of the read partition table data and comparing it with the partition table CRC32 check value recorded in the GPT header to verify the integrity of the entire partition table; and outputting GPT parsing information including the disk GUID, partition table GUID, unique GUID, type GUID, starting and ending LBA, attribute, and name of each partition.

[0119] The output module summarizes and outputs the final detection report, which displays the GPT parsing information and / or MBR parsing information, CRC check result, and integrity status; and for cases of failed verification or abnormal structure, explicit error identification and prompt are provided.

[0120] The system for detecting the integrity of the qcow2 virtual disk image file has the same technical effects as those of the embodiments 1, 2 and 3.

[0121] The above-described embodiments are only preferred embodiments of the present application, and are used to help understand the method and its core idea of the present application. The protection scope of the present application is not limited to the above-described embodiments. Any technical solution falling within the idea of the present application belongs to the protection scope of the present application. It should be noted that, for ordinary skilled persons in the art, some improvements and refinements without departing from the principle of the present application are also considered to be within the protection scope of the present application.

Claims

1. A method for detecting the integrity of a qcow2 virtual disk image file, characterized in that, include: S1. Read the file header of the qcow2 virtual disk image file and parse out the basic metadata including the cluster size and L1 table offset. S2. Based on the basic metadata, automatically calculate the physical offset of the data cluster corresponding to the starting position of the virtual disk in the qcow2 virtual disk image file; S3. Read the data of a sector from the physical offset and use it as the Master Boot Record (MBR) for parsing and verification to obtain MBR parsing information; S4. Determine whether the virtual disk uses the GPT partitioning scheme based on the Master Boot Record (MBR). If yes, proceed to step S5; otherwise, proceed to step S6. S5. Automatically locate the GPT region, perform parsing and verification, and obtain GPT parsing information; including: S501. Based on the basic metadata, automatically calculate the physical offset of the data cluster corresponding to the GPT header position in the qcow2 virtual disk image file, and read the GPT header data. S502. Parse the GPT header structure, including GPT signature, version, header size, header CRC32 checksum, primary GPT location, backup GPT location, partition table starting LBA, number and size of partition table entries, and partition table CRC32 checksum. S503. Recalculate the CRC32 check value of the GPT header data and compare it with the parsed header CRC32 check value to verify the integrity of the GPT header data. S504. Based on the information in the GPT header, locate the partition table region, calculate the physical offset of the partition table region in the qcow2 virtual disk image file, and read the partition table data. S505. Recalculate the CRC32 checksum of the read partition table data and compare it with the CRC32 checksum of the partition table recorded in the GPT header to verify the integrity of the entire partition table. S506, The output includes disk GUID, partition table GUID, unique GUID of each partition, type GUID, start and end LBA, attribute and name GPT resolution information; S6. Summarize and output the parsing information, CRC32 check results, and integrity information of the entire partition table.

2. The method for detecting the integrity of a qcow2 virtual disk image file according to claim 1, characterized in that, Step S2 includes: S201, Read table L1; S202. Calculate the corresponding L2 table index based on the sector number of the virtual disk, and find the corresponding L2 table entry from the L1 table. S203. Read the L2 table and find the corresponding data cluster table entry based on the offset within the cluster; S204. Parse the data cluster table entry to obtain the actual physical offset of the data cluster corresponding to the starting position in the qcow2 virtual disk image file.

3. The method for detecting the integrity of a qcow2 virtual disk image file according to claim 1, characterized in that, The parsing and verification methods in step S3 include: S301. Parse the Master Boot Record (MBR) structure, including the boot code, disk signature, and partition table entries; S302. Verify the structural integrity of the MBR; S303. The output includes disk signature, starting sector, size, and type of MBR parsing information for each partition table.

4. The method for detecting the integrity of a qcow2 virtual disk image file according to claim 3, characterized in that, The verification of MBR structural integrity in step S302 includes verifying whether the MBR end flag is 0x55AA.

5. The method for detecting the integrity of a qcow2 virtual disk image file according to claim 1, characterized in that, Step S4 describes the method for determining whether a virtual disk uses the GPT partitioning scheme, which includes: Check the type code of the partition table entry in the MBR. If the type code is 0xEE, it indicates that the virtual disk uses the GPT partitioning scheme.

6. The method for detecting the integrity of a qcow2 virtual disk image file according to claim 1, characterized in that, In step S6, the final test report is compiled and output. The report shows GPT parsing information and / or MBR parsing information, CRC check results, and integrity status; for cases of check failure or structural abnormality, clear error markings and prompts are provided.

7. A system for detecting the integrity of qcow2 virtual disk image files, characterized in that, include: The qcow2 parsing engine reads the header of the qcow2 virtual disk image file and parses out basic metadata including cluster size and L1 table offset. Based on the basic metadata, the physical offset of the data cluster corresponding to the starting position of the virtual disk in the qcow2 virtual disk image file is automatically calculated. MBR processing module: Reads data from a sector at the physical offset, parses and verifies it as the Master Boot Record (MBR), and obtains MBR parsing information; The GPT processing module determines whether the virtual disk uses the GPT partitioning scheme based on the Master Boot Record (MBR). If so, it automatically locates the GPT region and performs parsing and verification to obtain GPT parsing information, including checking the type code of the partition table entries in the MBR. If the type code is 0xEE, it indicates that the virtual disk uses the GPT partitioning scheme. Based on the basic metadata, it automatically calculates the physical offset of the data cluster corresponding to the GPT header position in the qcow2 virtual disk image file and reads the GPT header data. It parses the GPT header structure, including the GPT signature, version, header size, header CRC32 checksum, primary GPT location, backup GPT location, partition table starting LBA, number and size of partition table entries, etc. The CRC32 checksum of the partition table is calculated; the CRC32 checksum of the GPT header data is recalculated and compared with the parsed header CRC32 checksum to verify the integrity of the GPT header data; based on the information in the GPT header, the partition table region is located, the physical offset of the partition table region in the qcow2 virtual disk image file is calculated, and the partition table data is read; the CRC32 checksum of the read partition table data is recalculated and compared with the partition table CRC32 checksum recorded in the GPT header to verify the integrity of the entire partition table; the output includes GPT parsing information including disk GUID, partition table GUID, unique GUID of each partition, type GUID, start and end LBA, attributes and names; Otherwise, jump to the output module; Output module: Summarizes and outputs parsed information, CRC32 check results, and integrity information of the entire partition table.

8. A computer-readable storage medium storing a computer program, characterized in that, The computer program is used to perform the method for detecting the integrity of the qcow2 virtual disk image file as described in any one of claims 1-6.

9. A computer product comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method for detecting the integrity of a qcow2 virtual disk image file as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Copy-on-write-based virtual disk writing method and apparatus, and storage medium

    CN107861685A

  • Virtual disk reduction method and apparatus

    CN107918521A