A qcow2 image file incremental update method and device
Patent Information
- Application Number
- CN202111241500.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-25
- Publication Date
- 2025-01-17
- Estimated Expiration
- 2041-10-25
AI Technical Summary
In the VOI scenario, the increase in the hierarchy of qcow2 mirror files leads to a decrease in the system's read and write disk efficiency. The existing merge method requires a large amount of free space for hard disks and multiple read and write operations, affecting the update efficiency.
By analyzing the metadata of the qcow2 image file to be updated, obtain the data content, data size and sector offset of each assigned data cluster, perform only one write operation, and write the data directly to the virtual disk to avoid temporary data storage and multiple data Write operation.
Improve update efficiency, shorten update time, eliminate the need to prepare additional free space for hard disks, and reduce the number of write operations on VOI clients.
Smart Images

Figure CN114003569B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of VOI (Virtual OS Infrastructure, virtual terminal management system), and in particular to a qcow2 image file incremental update method and device. Background Art
[0002] In the VOI scenario, after the user sends the qcow2 format system image file to the VOI client through the VOI server for the first time to complete the system deployment, when the user wants to update the template system data, the VOI server usually uses the qcow2 external snapshot to store the user's updated data. Each update data corresponds to a qcow2 image file, so that the VOI server can send the updated data to all clients in an incremental form. However, as the number of user updates increases, the number of qcow2 (a disk image format) file levels corresponding to the template system will increase. If the VOI client stores all updates in the form of qcow2 external snapshots like the VOI server, then according to the qcow2 algorithm principle, the more qcow2 image file levels a system corresponds to, the lower its efficiency in reading and writing disks in the system will be, which will affect the user experience.
[0003] In view of the above situation, the current common practice is: when the VOI server sends the update file to the VOI client, the VOI client uses the qcow2 merge function to merge two or more qcow2 image files into one file, so as to reduce the hierarchical relationship and avoid the reduction of the efficiency of reading and writing disks in the system. However, this method has the following defects: 1. When using the qcow2 merge function, the files to be merged must be stored locally first, and the sent files can be deleted only after the merge operation is completed. During the merge process, the merged files may gradually increase, and the maximum increased capacity is basically equal to the size of the update file. At this time, the VOI client needs to have 2 times or more of the update file size. Free hard disk space, if the hard disk free space is insufficient, the merge will fail; 2. During the entire merge update process, the VOI client needs to perform 1 read operation and 2 write operations on the same file. The first write operation is in the process of receiving the file sent by the VOI server, and the read operation and the second write operation are in the process of executing the merge, which takes a lot of time and affects the update efficiency. Summary of the invention
[0004] In view of the defects existing in the prior art, the object of the present invention is to provide a method and device for incrementally updating a qcow2 image file.
[0005] In order to achieve the above purpose, the technical solution adopted by the present invention is:
[0006] In a first aspect, the present invention provides a method for incrementally updating a qcow2 image file, which specifically comprises the following steps:
[0007] Obtain a qcow2 image file to be sent to the VOI client to update the qcow2 image file in the VOI client;
[0008] Analyze the metadata of the qcow2 image file to be sent, and obtain the data content, data size and sector offset of each allocated data cluster in the virtual disk corresponding to the qcow2 image file;
[0009] Send the data content, data size and sector offset of each allocated data cluster to the VOI client;
[0010] The data size, sector offset and the file handle to be written on the VOI client are taken as parameters, and then the data content is written into the sector of the virtual disk corresponding to the qcow2 image file in the VOI client.
[0011] On the basis of the above technical solution, the specific steps of obtaining the qcow2 image file to be sent to the VOI client to update the qcow2 image file in the VOI client include:
[0012] Compare the qcow2 image file in the VOI server with the qcow2 image file in the VOI client;
[0013] Based on the comparison result, the qcow2 image file to be sent is obtained, and the qcow2 image file to be sent is used to be sent to the VOI client to update the qcow2 image file in the VOI client.
[0014] On the basis of the above technical solution, the metadata of the qcow2 image file to be sent is analyzed to obtain the data content, data size and sector offset of each allocated data cluster in the virtual disk corresponding to the qcow2 image file, wherein the specific steps for obtaining the data size and sector offset are as follows:
[0015] The VOI server analyzes the metadata of the qcow2 image file to be sent, and traverses all L2 table entries of the metadata based on the traversal method to obtain the set of all allocated data clusters;
[0016] A sent data information list is created, and the data size of each allocated data cluster in the set and the sector offset in the virtual disk corresponding to the qcow2 image file are stored in the sent data information list.
[0017] Based on the above technical solution, before sending the data content, data size and sector offset of each allocated data cluster to the VOI client, the method further includes:
[0018] The VOI server sends the space size information of the qcow2 image file to be sent and the name of the parent image file to the VOI client;
[0019] The VOI client receives the space size information and the parent image file, and determines whether the free space capacity of its own disk is sufficient based on the received space size information.
[0020] Based on the above technical solution, when the free space on the VOI client disk is sufficient:
[0021] The VOI client uses the path of the received parent image file as a parameter and calls qcow2 to open the file interface to obtain the file handle of the data to be written on the VOI client;
[0022] The VOI server takes the file path of the qcow2 image file to be sent as a parameter, and obtains the file handle of the qcow2 image file to be sent by calling the qcow2 open file interface.
[0023] On the basis of the above technical solution, when the free space capacity of the VOI client's own disk is insufficient: the update of the qcow2 image file on the VOI client is stopped.
[0024] On the basis of the above technical solution, the metadata of the qcow2 image file to be sent is analyzed to obtain the data content, data size and virtual sector offset corresponding to each allocated data cluster in the qcow2 image file, wherein the specific steps for obtaining the data content are as follows:
[0025] The VOI server traverses the sent data information list and obtains the data size and sector offset of each allocated data cluster;
[0026] The acquired data size, sector offset, and file handle of the qcow2 image file to be sent are used as parameters, and the data content of each allocated data cluster is obtained in turn by calling the qcow2 file reading interface.
[0027] On the basis of the above technical solution, the data size, sector offset and the file handle to be written on the VOI client are taken as parameters, and then the data content is written to the sector of the virtual disk corresponding to the qcow2 image file in the VOI client. The specific steps include:
[0028] The data size, sector offset, and file handle of each allocated data cluster to be written on the VOI client are taken as parameters. By calling the qcow2 file write interface, the data content of each allocated data cluster is written to the sector of the virtual disk corresponding to the qcow2 image file in the VOI client, thereby completing the update of the qcow2 image file in the VOI client.
[0029] On the basis of the above technical solution, the data content, data size and sector offset of each allocated data cluster are sent to the VOI client, specifically:
[0030] The VOI server sends the data content, data size and sector offset of each allocated data cluster to the VOI client in turn.
[0031] In a second aspect, the present invention provides a qcow2 image file incremental update device, comprising:
[0032] The VOI server is used to obtain the qcow2 image file to be sent to the VOI client for updating the qcow2 image file in the VOI client, and analyze the metadata of the qcow2 image file to be sent, obtain the data content, data size and sector offset of each allocated data cluster in the virtual disk corresponding to the qcow2 image file, and then send the data content, data size and sector offset of each allocated data cluster to the VOI client;
[0033] The VOI client is used to receive the data content, data size and sector offset sent by the VOI server, and take the data size, sector offset and the file handle to be written on the VOI client as parameters, and then write the data content into the sector of the virtual disk corresponding to the qcow2 image file in the VOI client.
[0034] Compared with the prior art, the advantage of the present invention is that when the qcow2 image file is incrementally updated to the VOI client through the VOI server, the metadata of the qcow2 image file to be sent is analyzed to obtain the data content, data size and sector offset of each allocated data cluster in the virtual disk corresponding to the qcow2 image file, and then the data content, data size and sector offset of each allocated data cluster are sent to the VOI client, and finally the data size, sector offset and the file handle to be written to the data on the VOI client are used as parameters, and then the data content is written to the sector of the virtual disk corresponding to the qcow2 image file in the VOI client, so that the incremental update operation of the qcow2 image file can be completed. During the entire update process, the VOI client does not need to prepare additional large hard disk free space to store temporary data, and the VOI client only needs to perform a write operation on the qcow2 image file to be sent, which effectively improves the update efficiency and shortens the update time. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0036] Figure 1 It is a flow chart of a method for incrementally updating a qcow2 image file in an embodiment of the present invention;
[0037] Figure 2 The present invention is a schematic diagram of the structure of a qcow2 image file incremental update device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0038] The embodiment of the present invention provides a qcow2 image file incremental update method. When the qcow2 image file is incrementally updated to the VOI client through the VOI server, the metadata of the qcow2 image file to be sent is analyzed to obtain the data content, data size and sector offset of each allocated data cluster in the virtual disk corresponding to the qcow2 image file; then the data content, data size and sector offset of each allocated data cluster are sent to the VOI client, and finally the data size, sector offset and the file handle to be written on the VOI client are used as parameters, and then the data content is written to the sector of the virtual disk corresponding to the qcow2 image file in the VOI client, so that the incremental update operation of the qcow2 image file can be completed. During the entire update process, the VOI client does not need to prepare additional large hard disk free space to store temporary data, and the VOI client only needs to perform a write operation on the qcow2 image file to be sent, which effectively improves the update efficiency and shortens the update time. The embodiment of the present invention also provides a qcow2 image file incremental update device accordingly.
[0039] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0040] See also Figure 1 As shown, a qcow2 image file incremental update method provided by an embodiment of the present invention specifically includes the following steps:
[0041] S1: Obtain a qcow2 image file to be sent to a VOI client to update the qcow2 image file in the VOI client; the qcow2 image file to be sent is specifically obtained by the VOI server.
[0042] In an embodiment of the present invention, the VOI server is used to provide centralized management and on-demand distribution of qcow2 format image files; the VOI client is installed on the VOI client and is used to receive the qcow2 format image files distributed by the VOI server and create a virtual disk device.
[0043] The data cluster of qcow2 is a data storage unit in the qcow2 image format, which is used to store the metadata of qcow2 and the virtual disk data corresponding to the image file. The size of each cluster in the same qcow2 image file is equal and spatially continuous in the image file. Usually, the size of each cluster is an integer multiple of 512 bytes. The present invention divides the data cluster of qcow2 into a qcow2 metadata cluster, an allocated data cluster and an unallocated data cluster; the qcow2 metadata cluster is a cluster used to store the metadata of the qcow2 image format; the allocated data cluster is a cluster stored in the qcow2 image file and used to represent disk data; the unallocated data cluster is a data cluster with a reference count of 0 and is not used.
[0044] In an embodiment of the present invention, the qcow2 image file to be sent to the VOI client to update the qcow2 image file in the VOI client is obtained, and the specific steps include:
[0045] S101: Compare the qcow2 image file in the VOI server with the qcow2 image file in the VOI client;
[0046] S102: Based on the comparison result, a qcow2 image file to be sent is obtained, where the qcow2 image file to be sent is used to be sent to the VOI client to update the qcow2 image file in the VOI client.
[0047] That is, when the user executes the function operation of sending system updates to the VOI client through the VOI server as needed, the VOI server finds all the corresponding qcow2 image files stored in the VOI server according to the system to be sent, and then compares them with the qcow2 image files in the VOI client to obtain the qcow2 image files that need to be sent to the VOI client for update, that is, the qcow2 image files to be sent.
[0048] S2: Analyze the metadata of the qcow2 image file to be sent, and obtain the data content, data size and sector offset of each allocated data cluster in the virtual disk corresponding to the qcow2 image file;
[0049] S3: Send the data content, data size and sector offset of each allocated data cluster to the VOI client;
[0050] S4: taking the data size, sector offset and the file handle to be written on the VOI client as parameters, and then writing the data content into the sector of the virtual disk corresponding to the qcow2 image file in the VOI client.
[0051] In the embodiment of the present invention, the metadata of the qcow2 image file to be sent is analyzed to obtain the data content, data size and sector offset of each allocated data cluster in the virtual disk corresponding to the qcow2 image file, wherein the specific steps of obtaining the data size and sector offset are as follows:
[0052] S111: The VOI server analyzes the metadata of the qcow2 image file to be sent, and traverses all L2 (layer 2) table entries of the metadata based on a traversal method to obtain a set of all allocated data clusters;
[0053] S112: Create a sent data information list, and store the data size of each allocated data cluster in the set and the sector offset in the virtual disk corresponding to the qcow2 image file in the sent data information list.
[0054] In the embodiment of the present invention, before sending the data content, data size and sector offset of each allocated data cluster to the VOI client, the process further includes:
[0055] S301: The VOI server sends the space size information of the qcow2 image file to be sent and the name of the parent image file to the VOI client;
[0056] S302: The VOI client receives the space size information and the parent image file, and determines whether the free space capacity of its own disk is sufficient based on the received space size information.
[0057] Among them, when the VOI client's own disk free space capacity is sufficient: the VOI client takes the path of the received parent image file as a parameter, and obtains the file handle of the data to be written on the VOI client by calling qcow2 to open the file interface; the VOI server takes the file path of the qcow2 image file to be sent as a parameter, and obtains the file handle of the qcow2 image file to be sent by calling qcow2 to open the file interface.
[0058] It should be noted that the qcow2 image file to be sent will eventually be written to the VOI client, but when the file handle of the data to be written on the VOI client is obtained, the qcow2 image file to be sent has not yet been sent to the VOI client. At this time, obtaining the file handle of the data to be written is equivalent to the preparatory work for the subsequent writing stage, and obtaining the file handle of the corresponding position where the data to be written is written in advance.
[0059] When the free space capacity of the VOI client's own disk is insufficient, the update of the qcow2 image file on the VOI client is stopped.
[0060] In the embodiment of the present invention, the metadata of the qcow2 image file to be sent is analyzed to obtain the data content, data size and sector offset of each allocated data cluster in the virtual disk corresponding to the qcow2 image file, wherein the specific steps of obtaining the data content are as follows:
[0061] S221: The VOI server traverses the sent data information list to obtain the data size and sector offset of each allocated data cluster;
[0062] S222: The acquired data size, sector offset, and file handle of the qcow2 image file to be sent are used as parameters, and the data content of each allocated data cluster is acquired in turn by calling the qcow2 file reading interface.
[0063] In the embodiment of the present invention, the data size, sector offset and the file handle to be written on the VOI client are used as parameters, and then the data content is written to the sector of the virtual disk corresponding to the qcow2 image file in the VOI client. The specific steps include:
[0064] The data size, sector offset, and file handle of each allocated data cluster to be written on the VOI client are taken as parameters. By calling the qcow2 file write interface, the data content of each allocated data cluster is written to the sector of the virtual disk corresponding to the qcow2 image file in the VOI client, thereby completing the update of the qcow2 image file in the VOI client.
[0065] In the embodiment of the present invention, the data content, data size and sector offset of each allocated data cluster are sent to the VOI client, specifically:
[0066] The VOI server sends the data content, data size and sector offset of each allocated data cluster to the VOI client in turn.
[0067] The specific process of the qcow2 image file incremental update method of the present invention is:
[0068] A: When the user needs to execute the function operation of sending system updates to the VOI client through the VOI server;
[0069] B: The VOI server finds all the corresponding qcow2 image files stored on the VOI server according to the system to be issued;
[0070] C: Compare the qcow2 image file in the VOI server with the qcow2 image file in the VOI client, and obtain the qcow2 image file to be sent based on the comparison result, wherein the qcow2 image file to be sent is used to be sent to the VOI client to update the qcow2 image file in the VOI client;
[0071] D: The VOI server analyzes the metadata of the qcow2 image file to be sent, and traverses all L2 table entries of the metadata based on the traversal method to obtain a set of all allocated data clusters, creates a sent data information list, and stores the data size of each allocated data cluster in the set and the sector offset in the virtual disk corresponding to the qcow2 image file in the sent data information list;
[0072] E: The VOI server sends the space size information of the qcow2 image file to be sent and the name of the parent image file to the VOI client;
[0073] F: The VOI client receives the space size information and the parent image file, and determines whether the free space capacity of its own disk is sufficient based on the received space size information. If it is sufficient, the VOI client uses the path of the received parent image file as a parameter, and opens the file interface by calling qcow2 to obtain the file handle of the data to be written on the VOI client;
[0074] G: The VOI server takes the file path of the qcow2 image file to be sent as a parameter, and obtains the file handle of the qcow2 image file to be sent by calling the qcow2 open file interface;
[0075] H: The VOI server traverses the sent data information list, obtains the data size and sector offset of each allocated data cluster, takes the obtained data size, sector offset, and the file handle of the qcow2 image file to be sent as parameters, and obtains the data content of each allocated data cluster in turn by calling the qcow2 file reading interface. Then, the VOI server sends the data content, data size, and sector offset of each allocated data cluster to the VOI client in turn;
[0076] I: Take the data size, sector offset, and file handle of each allocated data cluster on the VOI client as parameters, and write the data content of each allocated data cluster to the sector of the virtual disk corresponding to the qcow2 image file in the VOI client by calling the qcow2 file write interface, so as to complete the update of the qcow2 image file in the VOI client;
[0077] J: After the VOI server sends all the allocated data clusters in the qcow2 image file, the incremental update of the entire qcow2 image file is completed.
[0078] The incremental update method of the qcow2 image file of the present invention, when the user performs the function operation of sending the qcow2 incremental file (i.e., the qcow2 image file used to update the qcow2 image file in the VOI client) to the VOI client through the VOI server, the qcow2 incremental file data must first be analyzed, and all the allocated data clusters in the qcow2 incremental file can be found through the data structure characteristics of the qcow2 format file itself, so that the VOI server can send the data of these clusters to the VOI client in batches in the form of streams, and the VOI client writes the data to the qcow2 file to be merged through the write interface of qcow2 when receiving the data, thus completing the incremental update operation of the qcow2 image file. In the entire data sending and updating process, it is not necessary to prepare a hard disk free space twice the size of the sent file to store temporary data, and it is only necessary that the remaining hard disk space is larger than the size of the sent file, and in the update process, the VOI client only performs one write operation on the qcow2 incremental file, which greatly improves the efficiency and shortens the update time.
[0079] The qcow2 image file incremental update method of the embodiment of the present invention, when the qcow2 image file is incrementally updated to the VOI client through the VOI server, the metadata of the qcow2 image file to be sent is analyzed to obtain the data content, data size and sector offset of each allocated data cluster in the virtual disk corresponding to the qcow2 image file, and then the data content, data size and sector offset of each allocated data cluster are sent to the VOI client, and finally the data size, sector offset and the file handle to be written to the data on the VOI client are used as parameters, and then the data content is written to the sector of the virtual disk corresponding to the qcow2 image file in the VOI client, so that the incremental update operation of the qcow2 image file can be completed. During the entire update process, the VOI client does not need to prepare an additional large hard disk free space to store temporary data, and the VOI client only needs to perform a write operation on the qcow2 image file to be sent, which effectively improves the update efficiency and shortens the update time.
[0080] See also Figure 2 As shown, an embodiment of the present invention provides a qcow2 image file incremental update device, including a VOI server and a VOI client.
[0081] The VOI server is used to obtain the qcow2 image file to be sent to the VOI client to update the qcow2 image file in the VOI client, and analyze the metadata of the qcow2 image file to be sent, obtain the data content, data size and sector offset of each allocated data cluster in the virtual disk corresponding to the qcow2 image file, and then send the data content, data size and sector offset of each allocated data cluster to the VOI client; the VOI client is used to receive the data content, data size and sector offset sent by the VOI server, and use the data size, sector offset and the file handle to be written on the VOI client as parameters, and then write the data content to the sector of the virtual disk corresponding to the qcow2 image file in the VOI client.
[0082] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
[0083] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the process in the flowchart. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
Claims
1. A qcow2 image file incremental update method, characterized in that: The specific steps include: Obtain a qcow2 image file to be sent to the VOI client to update the qcow2 image file in the VOI client; Analyze the metadata of the qcow2 image file to be sent, and obtain the data content, data size and sector offset of each allocated data cluster in the virtual disk corresponding to the qcow2 image file; Send the data content, data size and sector offset of each allocated data cluster to the VOI client; The data size, sector offset and the file handle to be written on the VOI client are taken as parameters, and then the data content is written to the virtual disk sector corresponding to the qcow2 image file in the VOI client; The metadata of the qcow2 image file to be sent is analyzed to obtain the data content, data size and sector offset of each allocated data cluster in the virtual disk corresponding to the qcow2 image file, wherein the specific steps for obtaining the data size and sector offset are as follows: The VOI server analyzes the metadata of the qcow2 image file to be sent, and traverses all L2 table entries of the metadata based on the traversal method to obtain the set of all allocated data clusters; Create a sent data information list, and store the data size of each allocated data cluster in the set and the sector offset in the virtual disk corresponding to the qcow2 image file in the sent data information list; Before sending the data content, data size and sector offset of each allocated data cluster to the VOI client, the method further includes: The VOI server sends the space size information of the qcow2 image file to be sent and the name of the parent image file to the VOI client; The VOI client receives the space size information and the parent image file, and determines whether the free space capacity of its own disk is sufficient based on the received space size information; When the free space on the VOI client disk is sufficient: The VOI client uses the path of the received parent image file as a parameter and calls qcow2 to open the file interface to obtain the file handle of the data to be written on the VOI client; The VOI server takes the file path of the qcow2 image file to be sent as a parameter, and obtains the file handle of the qcow2 image file to be sent by calling the qcow2 open file interface; When the free space on the VOI client disk is insufficient, the update of the qcow2 image file on the VOI client is stopped. The metadata of the qcow2 image file to be sent is analyzed to obtain the data content, data size and sector offset of each allocated data cluster in the virtual disk corresponding to the qcow2 image file, wherein the specific steps for obtaining the data content are as follows: The VOI server traverses the sent data information list and obtains the data size and sector offset of each allocated data cluster; The acquired data size, sector offset, and file handle of the qcow2 image file to be sent are used as parameters, and the data content of each allocated data cluster is obtained in turn by calling the qcow2 file reading interface; The data size, sector offset and the file handle to be written on the VOI client are taken as parameters, and then the data content is written into the virtual disk sector corresponding to the qcow2 image file in the VOI client. The specific steps include: The data size, sector offset, and file handle of each allocated data cluster to be written on the VOI client are taken as parameters. By calling the qcow2 file write interface, the data content of each allocated data cluster is written to the sector of the virtual disk corresponding to the qcow2 image file in the VOI client, thereby completing the update of the qcow2 image file in the VOI client.
2. A qcow2 image file incremental update method as claimed in claim 1, characterized in that: The specific steps of obtaining the qcow2 image file to be sent to the VOI client to update the qcow2 image file in the VOI client include: Compare the qcow2 image file in the VOI server with the qcow2 image file in the VOI client; Based on the comparison result, the qcow2 image file to be sent is obtained, and the qcow2 image file to be sent is used to be sent to the VOI client to update the qcow2 image file in the VOI client.
3. A qcow2 image file incremental update method as claimed in claim 1, characterized in that: The data content, data size and sector offset of each allocated data cluster are sent to the VOI client, specifically: The VOI server sends the data content, data size and sector offset of each allocated data cluster to the VOI client in turn.
4. A qcow2 image file incremental update device, characterized in that: include: The VOI server is used to obtain the qcow2 image file to be sent to the VOI client to update the qcow2 image file in the VOI client, and analyze the metadata of the qcow2 image file to be sent, obtain the data content, data size and sector offset of the virtual disk corresponding to each allocated data cluster, and then send the data content, data size and sector offset of each allocated data cluster to the VOI client; The VOI client is used to receive the data content, data size and sector offset sent by the VOI server, and take the data size, sector offset and the file handle to be written on the VOI client as parameters, and then write the data content into the sector of the virtual disk corresponding to the qcow2 image file in the VOI client; The metadata of the qcow2 image file to be sent is analyzed to obtain the data content, data size and sector offset of each allocated data cluster in the virtual disk corresponding to the qcow2 image file, wherein the specific steps for obtaining the data size and sector offset are as follows: The VOI server analyzes the metadata of the qcow2 image file to be sent, and traverses all L2 table entries of the metadata based on the traversal method to obtain the set of all allocated data clusters; Create a sent data information list, and store the data size of each allocated data cluster in the set and the sector offset in the virtual disk corresponding to the qcow2 image file in the sent data information list; Before sending the data content, data size and sector offset of each allocated data cluster to the VOI client, the method further includes: The VOI server sends the space size information of the qcow2 image file to be sent and the name of the parent image file to the VOI client; The VOI client receives the space size information and the parent image file, and determines whether the free space capacity of its own disk is sufficient based on the received space size information; When the free space on the VOI client disk is sufficient: The VOI client uses the path of the received parent image file as a parameter and calls qcow2 to open the file interface to obtain the file handle of the data to be written on the VOI client; The VOI server takes the file path of the qcow2 image file to be sent as a parameter, and obtains the file handle of the qcow2 image file to be sent by calling the qcow2 open file interface; When the free space on the VOI client disk is insufficient, the update of the qcow2 image file on the VOI client is stopped. The metadata of the qcow2 image file to be sent is analyzed to obtain the data content, data size and sector offset of each allocated data cluster in the virtual disk corresponding to the qcow2 image file, wherein the specific steps for obtaining the data content are as follows: The VOI server traverses the sent data information list and obtains the data size and sector offset of each allocated data cluster; The acquired data size, sector offset, and file handle of the qcow2 image file to be sent are used as parameters, and the data content of each allocated data cluster is obtained in turn by calling the qcow2 file reading interface; The data size, sector offset and the file handle to be written on the VOI client are taken as parameters, and then the data content is written into the virtual disk sector corresponding to the qcow2 image file in the VOI client. The specific steps include: The data size, sector offset, and file handle of each allocated data cluster to be written on the VOI client are taken as parameters. By calling the qcow2 file write interface, the data content of each allocated data cluster is written to the sector of the virtual disk corresponding to the qcow2 image file in the VOI client, thereby completing the update of the qcow2 image file in the VOI client.
Citation Information
Patent Citations
Differential patch updating method and device suitable for embedded system
CN107273159A
Streaming incremental backup method and device based on virtual magnetic disk file
CN108845895A