Virtual machine data backup method, storage medium and electronic equipment

By allocating storage space for kernel-state programs and updating data bitmaps, the problem of insufficient applicability of virtual machine data backup methods in specific environments is solved, and effective backup on kernel-state programs is realized.

CN120256206AActive Publication Date: 2025-07-04JINAN INSPUR DATA TECH CO LTD

Patent Information

Application Number
CN202510736479.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-04
Publication Date
2025-07-04
Estimated Expiration
2045-06-04

AI Technical Summary

Technical Problem

In the prior art, the virtual machine data backup method has poor applicability in a specific virtual machine operating environment, especially when the KVM layer processes data IO operations, the QEMU layer cannot obtain data change information, resulting in the failure of the backup function.

Method used

By detecting the running position of the backend driver, if the target storage space is allocated for the kernel-state program on the kernel-state program, the kernel-state program is controlled to update the data bitmap, record the changed virtual machine data location in the virtual disk, and perform backup.

Benefits of technology

Even in a virtual machine environment running on a kernel-state program, virtual machine data can be effectively recorded and backed up, enhancing the applicability of the backup method and overcoming the lack of backup function in a specific environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120256206A_ABST
    Figure CN120256206A_ABST
Patent Text Reader

Abstract

The invention discloses a virtual machine data backup method, a storage medium and electronic equipment, and relates to the field of computers. Comprising the following steps: reading and writing a virtual disk of the virtual machine according to a disk reading and writing request sent by the virtual machine by utilizing a back-end driver corresponding to the virtual machine, recording the characteristics that a data bitmap can record the disk position of changed virtual machine data in the virtual disk, and updating the data bitmap according to the running position of the back-end driver, and when it is detected that the rear-end driver runs on the kernel mode program, allocating a target storage space for the kernel mode program, and controlling the kernel mode program to update the data bitmap stored in the target storage space. Finally, according to the target data bitmap stored in the target storage space, the changed target virtual machine data in the virtual disk is backed up, the technical problem that the backup method of the virtual machine data is poor in applicability is solved, and the technical effect of enhancing the applicability of the backup method of the virtual machine data is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the field of computers, and more specifically, to a method for backing up virtual machine data, a storage medium, and an electronic device. Background Art

[0002] In a virtualized environment, backing up virtual machine data is an important part of ensuring data security and system reliability. In the prior art, virtual machine data backup usually relies on the Change Block Tracking (CBT) bitmap function to implement incremental backup. During the operation of the virtual machine, the system will obtain data change information in real time and store this information in the CBT bitmap. When backup is required, only the virtual machine data that has changed and is recorded in the CBT bitmap needs to be backed up to complete the backup. However, the prior art has limitations in some cases. For example, in a specific virtual machine operating environment, the traditional backup method may not be able to obtain data change situations, resulting in the failure of the backup function and limiting the applicability of the backup method in different scenarios.

[0003] In view of the technical problem that the applicability of the virtual machine data backup method in the related art is poor, no effective solution has been proposed yet. Summary of the Invention

[0004] Embodiments of the present application provide a method for backing up virtual machine data, a storage medium, and an electronic device, so as to at least solve the technical problem that the applicability of the virtual machine data backup method in the related art is poor.

[0005] According to an embodiment of the present application, a method for backing up virtual machine data is provided, including:

[0006] Detecting the current running position of the backend driver corresponding to the virtual machine, where the backend driver is used to read and write the virtual disk of the virtual machine according to the disk read and write requests sent by the virtual machine;

[0007] When it is detected that the running position is used to indicate that the backend driver is running on the kernel-mode program, allocating a target storage space for the kernel-mode program;

[0008] Controlling the kernel-mode program to update the data bitmap stored in the target storage space, where the data bitmap is used to record the disk positions of the virtual machine data that has changed in the virtual disk;

[0009] Backing up the target virtual machine data that has changed in the virtual disk according to the target data bitmap stored in the target storage space.

[0010] The present application also provides an electronic device, including: a memory for storing a computer program; a processor for implementing the steps of any of the above virtual machine data backup methods when executing the computer program.

[0011] The present application also provides a computer-readable storage medium storing a computer program, wherein the computer program implements the steps of any of the above virtual machine data backup methods when executed by a processor.

[0012] The present application also provides a computer program product including a computer program, and the computer program implements the steps of any of the above virtual machine data backup methods when executed by a processor.

[0013] Through the present application, by virtue of the characteristics that the backend driver corresponding to the virtual machine can read and write the virtual disk of the virtual machine according to the disk read and write requests sent by the virtual machine and the data bitmap can record the disk positions where the virtual machine data with changes in the virtual disk is located, the data bitmap is updated according to the running position of the backend driver. When it is detected that the backend driver is running on the kernel-mode program, a target storage space is allocated for the kernel-mode program, and the kernel-mode program is controlled to update the data bitmap stored in the target storage space. Finally, according to the target data bitmap stored in the target storage space, the target virtual machine data with changes in the virtual disk is backed up. That is, by allocating a target storage space for the kernel-mode program, even when the virtual machine is in a specific virtual machine running environment where the backend driver is running on the kernel-mode program, the kernel-mode program can also update the data bitmap in the allocated target storage space to record the disk positions where the virtual machine data with changes in the virtual disk is located, thereby realizing the backup of the virtual machine data, overcoming the problem in the prior art that in a specific virtual machine running environment, due to the inability to obtain the data change information in the kernel-mode program, the backup function is missing. Therefore, the technical problems such as poor applicability of the virtual machine data backup method in the related art can be solved, and the technical effect of enhancing the applicability of the virtual machine data backup method is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] To more clearly illustrate the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0015] Figure 1 is a hardware structure block diagram of a computer device for a virtual machine data backup method according to an embodiment of the present application;

[0016] Figure 2It is a flowchart of a method for backing up virtual machine data in the related art;

[0017] Figure 3 It is a flowchart of a method for backing up virtual machine data according to an embodiment of the present application;

[0018] Figure 4 It is a schematic diagram of the backend driver running on the kernel-mode program according to an embodiment of the present application;

[0019] Figure 5 It is a structural diagram of a data bitmap whose format type matches the first format according to an embodiment of the present application;

[0020] Figure 6 It is a flowchart of loading a data bitmap instructed by a load control instruction according to an embodiment of the present application;

[0021] Figure 7 It is a schematic diagram of an electronic device according to an embodiment of the present application. Detailed implementation manners

[0022] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the protection scope of the present application.

[0023] It should be noted that in the description of the present application, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in the present application are used to distinguish similar objects, rather than to describe a specific order or sequence.

[0024] In order to enable those skilled in the art of the present technology to better understand the solution of the present application, the present application will be further described in detail below in conjunction with the accompanying drawings and specific implementation manners.

[0025] The method embodiments provided in the embodiments of the present application can be executed in a server device or a similar computing device. Taking running on a server device as an example, Figure 1 It is a hardware structure block diagram of a computer device for a method of backing up virtual machine data according to an embodiment of the present application. As Figure 1 shown, the server device may include one or more ( Figure 1Only one processor 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data are shown. Among them, the above server device may further include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that Figure 1 The structure shown is only illustrative and does not limit the structure of the above server device. For example, the server device may further include more or fewer components than Figure 1 shown in, or have a different configuration from Figure 1 shown.

[0026] The memory 104 can be used to store computer programs. For example, software programs and modules of application software, such as the computer program corresponding to the backup method of virtual machine data in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the above method. The memory 104 may include a high-speed random access memory and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely set relative to the processor 102, and these remote memories can be connected to the server device through a network. Examples of the above network include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.

[0027] The transmission device 106 is used to receive or send data via a network. Specific examples of the above network may include a wireless network provided by the communication provider of the server device. In one instance, the transmission device 106 includes a network adapter (abbreviated as NIC), which can be connected to other network devices through a base station and thus communicate with the Internet. In one instance, the transmission device 106 may be a radio frequency (abbreviated as RF) module, which is used to communicate with the Internet wirelessly.

[0028] The explanations of the nouns involved in the embodiments of the present application are as follows:

[0029] VMM (Virtual Machine Monitor): Manages actual physical resources downward and provides logical resources to different virtual machines upward;

[0030] QEMU (Quick Emulator): A user-mode emulator that implements the VMM layer through software simulation and simulates the hardware environment of a virtual machine, including CPU, memory, I / O devices, etc.;

[0031] KVM (Kernel-based Virtual Machine): system virtualization module responsible for managing the operating environment of virtual machines.

[0032] The present application proposes a method for backing up virtual machine data. Before describing the optional embodiments of the present application, in order to better understand the inventive concept of the present application and the creativity of the solution, the relevant technologies are first described: Figure 2 is a flowchart of a method for backing up virtual machine data in the related art, such as Figure 2 As shown, in a virtualized environment, the front-end and back-end architecture using the virtio protocol for IO operations includes a front-end driver and a back-end device. The front-end driver and the back-end device transmit data through shared memory, where the front-end driver is the driver corresponding to the virtio simulation device in the virtual machine kernel space, and the back-end device is the driver that can process the disk read and write requests of the virtual machine in the user state program (such as the QEMU layer). The backup method for virtual machine data in the above virtual machine environment is:

[0033] Step 1: The application in the virtual machine user space initiates a read / write (IO) request, such as a disk read / write request or network communication;

[0034] Step 2: The front-end driver receives the IO request, encapsulates the IO request into a data packet that complies with the virtio protocol format and stores it in the shared memory, and marks the IO request as "available", that is, it is ready to be processed by the back-end driver, and then notifies the back-end driver in the QEMU layer that there is a new IO request;

[0035] Step 3: The backend driver listens to the notification mechanism. Once the notification is received, it reads the request from the shared memory, parses the request, determines the request type (read or write) and the disk offset and data length of the data involved, and records the data change information corresponding to this IO request in the bitmap;

[0036] Step ④: The backend driver encapsulates the IO request into a format that conforms to the host hardware device, and requests the driver in the kernel state program (such as the KVM layer) of the host to perform the actual IO operation through a system call;

[0037] Step ⑤: After receiving the request, the driver in the KVM layer directly interacts with the physical hardware resources (such as disks, network interfaces, etc.) to complete the actual IO operation (reading data from physical hardware resources or writing data to physical hardware resources), and then returns the processing results (such as operation success, failure reason, etc.) to the QEMU layer;

[0038] Step ⑥: After the backend driver in the QEMU layer receives the processing result, it stores the processing result in the shared memory and notifies the frontend driver through the event notification mechanism.

[0039] Step ⑦: After the frontend driver receives the notification from QEMU, it obtains the processing result from the shared memory and returns the processing result to the application in the virtual machine user space.

[0040] When it is necessary to back up disk data, obtain the data change information from the bitmap in the QEMU layer and back up the data that has changed.

[0041] The following technical problems exist in the virtual machine data backup method in the related art:

[0042] 1) When processing IO operations, frequent switching between the KVM layer and the QEMU layer will cause additional system call overhead, affecting the overall IO processing efficiency and backup efficiency.

[0043] 2) The backup method depends on the QEMU layer to obtain data change information and is only applicable to the case of using the virtio protocol to process IO operations. However, in some specific virtual machine running environments, such as when the KVM layer processes data IO operations, the QEMU layer may not be able to obtain this information, and thus cannot record the data change information in the bitmap, resulting in the failure of the backup function.

[0044] To solve the above problems, an embodiment of the present application provides a virtual machine data backup method. Figure 3 It is a flowchart of a virtual machine data backup method according to an embodiment of the present application. As Figure 3 shown, the process includes the following steps:

[0045] Step S12, detect the current running position of the backend driver corresponding to the virtual machine, where the backend driver is used to read and write the virtual disk of the virtual machine according to the disk read and write requests sent by the virtual machine.

[0046] Step S14, when it is detected that the running position is used to indicate that the backend driver runs on the kernel-mode program, allocate a target storage space for the kernel-mode program.

[0047] Step S16, control the kernel-mode program to update the data bitmap stored in the target storage space, where the data bitmap is used to record the disk positions of the virtual machine data that has changed in the virtual disk.

[0048] Step S18, back up the target virtual machine data that has changed in the virtual disk according to the target data bitmap stored in the target storage space.

[0049] Optionally, in this embodiment, the backend driver refers to a software component responsible for processing disk read and write requests sent by virtual machines in a virtualized environment, including but not limited to the following two main forms: the virtio backend device running in a user-mode program (such as the QEMU layer), which is used to process disk read and write requests for data packets encapsulated in the virtio protocol format. Among them, the virtio protocol accelerates IO operations by sharing memory between the front-end driver and the backend driver of the virtual machine; the vhost driver running in the host kernel-mode program, and the vhost driver directly processes disk read and write requests sent by virtual machines in the kernel mode. The backend driver in this embodiment takes the two cases of running in a user-mode program and running in a kernel-mode program as examples, but does not limit the running position of the backend driver. Actually, according to different system architectures or specific performance optimization requirements, there are also backend drivers in other running position situations for optimizing the virtual machine disk IO performance in specific scenarios. For example, the backend driver can also be integrated into a specific hardware controller to further improve the efficiency and performance of IO processing.

[0050] Optionally, the disk read and write requests can include but are not limited to read requests and write requests. Among them, a read request involves reading data from the physical storage device of the host. After the backend driver obtains the read request, it parses the position and size of the data to be read, and reads the corresponding data from the physical hardware resources through the driver program in the host kernel mode, and writes it into the specified user-mode buffer. A write request involves writing data from the user-mode buffer to the physical storage device of the host. After the backend driver obtains the write request, it parses the position and size of the data to be written, reads the data from the user-mode buffer, and writes the data into the physical hardware resources through the driver program in the host kernel mode.

[0051] Optionally, in this embodiment, the methods for detecting the current running position of the backend driver can include but are not limited to: reading the configuration file of the virtual machine or the virtualization management interface. For example, when it is detected that the vhost function is enabled, it is determined that the current running position of the backend driver is the kernel-mode program; monitoring the process and thread activities on the host and identifying the processes or threads related to the backend driver. By analyzing the attributes of these processes or threads (such as memory mapping, open file descriptors, etc.), the running position of the backend driver is inferred. For example, when it is monitored that there are IO operations through vhost, it is determined that the current running position of the backend driver is the kernel-mode program; analyzing the system log and the QEMU log file, identifying the log entries related to the backend driver, and judging whether the IO request is processed by QEMU or by vhost according to the information recorded in the log entries, so as to judge whether the running position of the backend driver is a user-mode process or a kernel-mode process.

[0052] Optionally, in this embodiment, Figure 4It is a schematic diagram of the back-end drive running on a kernel-mode program according to an embodiment of the present application. As Figure 4 shown, the kernel-mode program can be, but is not limited to, a program running in the operating system kernel space, including KVM. When it is detected that the back-end drive (back-end device) is running on the kernel-mode program, a target storage space is allocated for the kernel-mode program, where the target storage space can be, but is not limited to, a specific file or directory and a dedicated backup device or partition.

[0053] Optionally, in this embodiment, when it is detected that the running location is used to indicate that the back-end drive is running on the kernel-mode program, when the virtual machine data in the virtual disk changes, the kernel-mode program can be controlled to update the data bitmap stored in the target storage space through the following steps, but is not limited to: Allocate a target storage space for the kernel-mode program. The kernel-mode program listens to the disk read and write requests processed by the back-end drive. When it is recognized that the virtual machine data has changed, the data bitmap in the target storage space is updated according to the disk location of the changed virtual machine data.

[0054] Optionally, in this embodiment, when it is detected that the running location is used to indicate that the back-end drive is running on the user-mode program, when the virtual machine data in the virtual disk changes, the user-mode program can be controlled to update the data bitmap stored in the target storage space through the following steps, but is not limited to: The user-mode program listens to the disk read and write requests processed by the back-end drive. When it is recognized that the virtual machine data has changed, the data bitmap in the target storage space is updated according to the disk location of the changed virtual machine data.

[0055] Optionally, in this embodiment, the target virtual machine data that has changed in the virtual disk is backed up according to the target data bitmap stored in the target storage space. The backup process can include, but is not limited to: When virtual machine data needs to be backed up, obtain the stored data bitmap from the target storage space. According to the disk location of the changed virtual machine data recorded in the data bitmap, identify the disk location of the data to be backed up (i.e., the target virtual machine data), then read these changed data from the virtual disk, write the read data to the corresponding location of the backup storage device, and at the same time update the backup management information, including backup time, backup version, backup status, etc.

[0056] By allocating target storage space for the kernel-mode program, even when the virtual machine is in a specific virtual machine running environment where the backend driver runs on the kernel-mode program, the kernel-mode program can update the data bitmap in the allocated target storage space to record the disk locations of the virtual machine data that has changed in the virtual disk, thereby realizing the backup of the virtual machine data, overcoming the problem in the prior art that in a specific virtual machine running environment, due to the inability to obtain the data change information in the kernel-mode program, the backup function is missing, thus achieving the technical effect of enhancing the applicability of the virtual machine data backup method, and further solving the technical problem of poor applicability of the virtual machine data backup method.

[0057] As an optional solution, allocating target storage space for the kernel-mode program includes:

[0058] S21, detecting whether there is currently a storage space that matches the bitmap parameter, where the bitmap parameter is used to indicate the size of the space required to store the expected data bitmap, and the expected data bitmap is a data bitmap that allows recording the disk locations of the virtual machine data that has changed in the virtual disk;

[0059] S22, when it is detected that there is a reference storage space that matches the bitmap parameter, transmitting the reference space address of the reference storage space to the kernel-mode program, where the reference space address is used to identify the location of the reference storage space, and the target storage space includes the reference storage space;

[0060] S23, when it is detected that there is no storage space that matches the bitmap parameter, creating a candidate storage space according to the bitmap parameter and transmitting the candidate space address of the candidate storage space to the kernel-mode program, where the candidate space address is used to identify the location of the candidate storage space, and the target storage space includes the candidate storage space.

[0061] Optionally, in this embodiment, the expected data bitmap can be but is not limited to a data bitmap that matches the virtual disk backup requirements such as the size of the virtual disk, the bitmap granularity, and the alignment requirements. The expected data bitmap can record the change information of the data blocks on the entire virtual disk. The bitmap parameter can be but is not limited to the size of the memory space required to meet the virtual disk backup requirements such as the size of the virtual disk, the bitmap granularity, and the alignment requirements.

[0062] Optionally, in this embodiment, the target storage space can be allocated to the kernel-mode program by, but not limited to, the following steps: First, detect whether there is currently a storage space whose memory space size matches the bitmap parameter. When it is detected that there is a reference storage space that matches the bitmap parameter, that is, the memory space size of the reference storage space meets the virtual disk backup requirements such as the size of the virtual disk, the bitmap granularity, and the alignment requirements, the target storage space will directly use the found reference storage space without creating a new storage space. QEMU transfers the reference space address of this storage space to the kernel-mode program for registration, and can also transfer the size of this storage space and related memory attributes (such as whether it is readable and writable) to the kernel-mode program for registration. Among them, the reference space address can be the virtual address of the reference storage space or the physical address corresponding to the reference storage space. The kernel-mode program can access this parameter storage space through the reference space address.

[0063] Optionally, in this embodiment, when it is detected that there is no storage space that matches the bitmap parameter, that is, there is no storage space whose memory space size meets the virtual disk backup requirements such as the size of the virtual disk, the bitmap granularity, and the alignment requirements, it is necessary to create a storage space as the target storage space according to the bitmap parameter, and transfer the candidate space address of the created candidate storage space that matches the bitmap parameter to the kernel-mode program for registration, and can also transfer the size of the candidate storage space and related memory attributes (such as whether it is readable and writable) to the kernel-mode program for registration. Among them, the candidate space address can be the virtual address of the candidate storage space or the physical address corresponding to the candidate storage space. The kernel-mode program can access this candidate storage space through the candidate space address.

[0064] As an optional solution, before creating the candidate storage space according to the bitmap parameter, the method further includes:

[0065] S31, obtain the disk parameter and the granularity parameter of the virtual disk, where the disk parameter is used to indicate the capacity of the virtual disk, and the granularity parameter is used to indicate the backup granularity for backing up the data in the virtual disk;

[0066] S32, generate the bitmap parameter according to the disk parameter and the granularity parameter.

[0067] Optionally, in this embodiment, the bitmap parameter can be obtained by, but not limited to, the following steps: obtain the disk parameter and the granularity parameter of the virtual disk; and then calculate the bitmap parameter according to the disk parameter and the granularity parameter.

[0068] Optionally, in this embodiment, the disk parameter may be the total size of the virtual disk, which is used to determine how much storage space is required to accommodate the key information of the entire data bitmap. The granularity parameter may be the backup granularity for backing up the data in the virtual disk. The backup granularity determines the size of the data block represented by each bit in the data bitmap. A smaller granularity can provide a finer-grained backup, but more storage space is required to store the bitmap. For example, when the granularity parameter is 4KB, it means that the virtual disk is divided into multiple data blocks of 4KB size.

[0069] Optionally, in this embodiment, when it is necessary to reduce the memory usage space, the status of the virtual machine data in the virtual disk can be recorded by bit. Since one byte is composed of 8 bits, if the granularity size of the bitmap is 1MB, that is, each bit in the bitmap represents a data block of 1MB size, then one byte can correspond to the status of eight data blocks, that is, 8MB of data. For example, for a 1GB virtual disk, when directly using one byte to represent the status of a data block, about 1GB of memory is required to store the data status information. When using a bitmap and each bit represents the status of a 1MB data block, only about 1MB of memory is required to store the status information of the entire virtual disk.

[0070] As an alternative solution, bitmap parameters are generated according to the disk parameter and the granularity parameter, including:

[0071] S41, call the space creation interface to divide the virtual disk into multiple data blocks according to the disk parameter and the granularity parameter, and obtain a data block set;

[0072] S42, call the space creation interface to determine the data volume required to record the location information and status information of all data blocks in the data block set as the bitmap parameter, where the location information is used to indicate the disk location of the corresponding data block in the virtual disk, and the status information is used to indicate whether the virtual machine data stored in the corresponding data block has changed.

[0073] Optionally, in this embodiment, the steps of generating bitmap parameters according to the disk parameter (disksize) and the granularity parameter (granularity) may include but are not limited to:

[0074] The first step, QEMU divides the virtual disk into multiple data blocks according to the disk parameter and the granularity parameter through the space creation interface (qmp_vhost_dirty_bitmap_add interface), and obtains a data block set, that is, the number of bits (size) required to cover all the data blocks in the virtual disk can be calculated according to the following formula:

[0075] size = (((disksize + granularity–1) / granularity)+7) / 8。

[0076] Among them, the part of (disksize + granularity–1) / granularity can obtain the number of blocks required to cover the entire virtual disk, ensuring that even if the disk parameters are not an integer multiple of the backup granularity, the entire virtual disk can be fully covered. The part of (the number of blocks + 7) / 8 can obtain the number of bytes. Since each byte contains 8 bits, it ensures that the total number of bits is a multiple of 8.

[0077] In the second step, determine the amount of data required to record the position information and status information of all data blocks in the data block set as the bitmap parameter, and calculate the specific bitmap parameter, that is, the memory size (memsize) that meets the alignment requirement (such as 4KB). It can be calculated according to the following formula:

[0078] memsize = ((size + 4095) / 4096)×4096。

[0079] Among them, the part of (size + 4095) / 4096 can ensure that the memory size is an integer multiple of 4096 bytes (4KB), obtain the required number of 4KB blocks, and the part of the number of blocks × 4096 can obtain the final memory size, ensuring that the 4KB alignment requirement is met.

[0080] Optionally, in this embodiment, after obtaining the bitmap parameter, QEMU calls a memory allocation function (such as malloc, mmap, etc.) according to the bitmap parameter to apply for memory that meets the bitmap parameter in the user space. After successfully applying for memory, use the ioctl system to transfer the candidate space address of the allocated memory area (that is, the candidate storage space) to the kernel program (KVM) for registration, and notify the kernel program of the address and size of the shared memory. The kernel program can access the candidate storage space through the candidate space address.

[0081] Optionally, in this embodiment, after the kernel program allocates the created candidate storage space, it is necessary to initialize this memory area to store the data bitmap. The initialization operation includes clearing the bitmap area or setting it to a specific initial value to indicate that there is no data change on the virtual disk at the initial moment.

[0082] As an optional solution, before transferring the reference space address of the reference storage space to the kernel program, it includes:

[0083] S51, detect the format type of the initial data bitmap currently stored in the reference storage space;

[0084] S52. When the format type is the first format, convert the initial data bitmap from the first format to the second format to obtain a candidate data bitmap, where the first format is the format type used by the user-mode program to update the data bitmap stored in the reference storage space, and the second format is the format type used by the kernel-mode program to update the data bitmap stored in the reference storage space.

[0085] Optionally, in this embodiment, the format type of the data bitmap can be identified by, but not limited to, checking the metadata of the data bitmap. The first format is the format type used by the user-mode program (such as QEMU) to update the data bitmap. Figure 5 It is a structure diagram of the data bitmap whose format type matches the first format according to the embodiment of the present application. For example, Figure 5 As shown, the data bitmap whose format type matches the first format can be a QEMU-native bitmap, that is, a data bitmap that conforms to the Hbitmap hierarchy. It adopts an 8-layer structure, and only each bit in the top layer corresponds to a data block. The lower layer records the modified bit positions of the upper layer. When a certain bit position in the upper layer is set to 1, the corresponding bit in the lower layer will be recorded. When querying, it can start traversing from the bottom layer, and only when it is 1 will it continue to traverse upward, improving the query speed. It is mainly used to improve the migration speed during virtual machine migration; the second format is the format type used by the kernel-mode program to update the data bitmap. Since it is only used for backup, the data bitmap whose format type matches the second format (the bitmap format of the vhost layer) can be a data bitmap that conforms to the data in the top layer of the Hbitmap hierarchy.

[0086] Optionally, in this embodiment, when it is detected that there is a reference storage space that matches the bitmap parameter, before transmitting the reference space address of the reference storage space to the kernel-mode program, it is necessary to ensure that the format type of the data bitmap currently stored in the reference storage space is the second format, so that the kernel-mode program can update the data bitmap stored in the reference storage space. Therefore, before transmitting the reference space address of the reference storage space to the kernel-mode program, it is necessary to detect the format type of the data bitmap (i.e., the initial data bitmap) stored in the reference storage space, and when the format type of the initial data bitmap is the first format and does not match the second format, convert the format type of the initial data bitmap from the first format to the second format.

[0087] Optionally, in this embodiment, before transmitting the reference space address of the reference storage space to the kernel-mode program, when it is detected that the format type of the data bitmap stored in the reference storage space matches the second format, no processing may be performed, and the reference space address of the reference storage space may be transmitted to the kernel-mode program, enabling the kernel-mode program to continue using the initial data bitmap. Alternatively, two additional fields may be added to record the address and size of the shared memory based on the initial data bitmap.

[0088] Optionally, in this embodiment, when it is detected that the running position indicates that the backend driver is running on the user-mode program and there is a storage space that matches the bitmap parameter, before transmitting the space address of the storage space to the user-mode program, it is necessary to ensure that the format type of the data bitmap currently stored in the storage space is the first format so that the user-mode program can update the data bitmap stored in the storage space. Therefore, before transmitting the reference space address of the storage space to the user-mode program, it is necessary to detect the format type of the data bitmap stored therein, and when the format type of the data bitmap stored therein is the second format and does not match the first format, convert the format type of the data bitmap stored therein from the second format to the first format. If it is detected that the format type of the data bitmap stored therein is the first format, no processing may be performed, and the user-mode program may continue to use the data bitmap.

[0089] As an optional solution, converting the initial data bitmap from the first format to the second format to obtain a candidate data bitmap includes:

[0090] S61, screening out the target position information and the target status information from the initial data bitmap, where the target position information is used to indicate the disk position of each data block in the virtual disk, and the target status information is used to indicate whether the virtual machine data stored in each data block in the virtual disk has changed;

[0091] S62, generating a candidate data bitmap in the second format based on the target position information and the target status information.

[0092] Optionally, in this embodiment, when the format type of the initial data bitmap is the first format and does not match the second format, the format type of the initial data bitmap may be converted from the first format to the second format through the following steps, but not limited thereto: screening out the target position information indicating the disk position of each data block in the virtual disk and the target status information indicating whether the virtual machine data stored in each data block in the virtual disk has changed from the initial data bitmap, and generating a candidate data bitmap in the second format based on the target position information and the target status information.

[0093] Optionally, in this embodiment, as Figure 5As shown, if the target format is the bitmap format of the vhost layer and the initial data bitmap is the native HBitmap structure of QEMU, then only the top layer of the HBitmap structure needs to be copied to form the candidate data bitmap of the second format (the bitmap format of the vhost layer).

[0094] Optionally, in this embodiment, if the target format is the native HBitmap structure of QEMU and the initial data bitmap is the bitmap format of the vhost layer, then seven layers need to be completed. The hbitmap_set function in the QEMU layer can be used for setting, setting the corresponding data block to 1 (indicating that the data block has changed) in the top layer of the HBitmap structure, and automatically updating the modified bit record in the lower layer according to the rules of the native QEMU bitmap.

[0095] As an optional solution, controlling the kernel-mode program to update the data bitmap stored in the target storage space includes:

[0096] S71, controlling the kernel-mode program to detect whether the backend driver has currently received a disk read / write request;

[0097] S72, in the case of detecting that the backend driver has currently received a disk read / write request, controlling the kernel-mode program to extract the offset parameter and the length parameter from the disk read / write request, where the offset parameter is used to indicate the starting position of the reference virtual machine data whose request has changed in the virtual disk in the disk read / write request, and the length parameter is used to indicate the length of the storage position of the reference virtual machine data in the virtual disk;

[0098] S73, controlling the kernel-mode program to update the data bitmap stored in the target storage space according to the offset parameter and the length parameter.

[0099] Optionally, in this embodiment, the kernel-mode program listens to the disk read / write requests processed by the backend driver. In the case of detecting that the backend driver has currently received a disk read / write request, that is, when it is detected that the virtual machine data may have changed, the kernel-mode program is controlled to extract the offset parameter and the length parameter of the reference virtual machine data whose request has changed in the disk read / write request from the disk read / write request. According to the obtained offset parameter and length parameter, the data block position corresponding to the reference virtual machine data is obtained, and the corresponding position in the data bitmap is marked, and the bitmap status of the corresponding position is set to "1" or set to a specific value to indicate that the data block at the corresponding position has changed.

[0100] Optionally, in this embodiment, the offset parameter of the reference virtual machine data may be the starting position of the reference virtual machine data in the virtual disk, indicating the starting position where the reference virtual machine data is located starting from the starting position of the virtual disk. Assuming that the offset parameter of the reference virtual machine data is 10 KB, then the starting position of the reference virtual machine data is at the 10 KB position of the virtual disk. The length parameter of the reference virtual machine data may be the length of the storage location occupied by the reference virtual machine data in the virtual disk, indicating the size of the storage space occupied by the reference virtual machine data starting from its starting position. Assuming that the length parameter of the reference virtual machine data is 8 KB (i.e., 8192 bytes), this means that starting from the starting position of the reference virtual machine data, the reference virtual machine data occupies 8192 bytes in the virtual disk.

[0101] As an optional solution, the control kernel-mode program updates the data bitmap stored in the target storage space according to the offset parameter and the length parameter, including:

[0102] S81, obtain the granularity parameter of the virtual disk, where the granularity parameter is used to indicate the backup granularity for backing up the data in the virtual disk;

[0103] S82, detect the reference position information of the reference data block storing the reference virtual machine data according to the offset parameter, the length parameter, and the granularity parameter, where the reference data block is a data block in the virtual disk, and the virtual disk is pre-divided into multiple data blocks according to the granularity parameter, and the reference position information is used to indicate the disk position of the reference data block in the virtual disk;

[0104] S83, update the reference status information corresponding to the reference position information in the data bitmap to the first status value, where the status information in the first status value is used to indicate that the virtual machine data stored in the data block corresponding to the position information has changed.

[0105] Optionally, in this embodiment, when the control kernel-mode program updates the data bitmap stored in the target storage space according to the offset parameter and the length parameter, first, the control kernel-mode program obtains the granularity parameter of the virtual disk. The granularity parameter may be the backup granularity for backing up the data in the virtual disk, and the backup granularity determines the size of the data block represented by each bit in the data bitmap. Then, according to the offset parameter (offset), the length parameter (length), and the granularity parameter (granularity), calculate the reference position information of the reference data block storing the reference virtual machine data, that is, the position of the data block corresponding to the reference virtual machine data. The specific calculation steps include:

[0106] The first step is to calculate the starting position (index) of the reference data block, and the calculation formula is:

[0107] index = offset / granularity。

[0108] Among them, index represents the starting position of the reference data block, and it needs to be rounded up to ensure that the starting position is an integer.

[0109] In the second step, calculate the number of affected data blocks (count), and the calculation formula is:

[0110] count = (length + granularity – 1) / granularity。

[0111] Among them, count represents the total number of data blocks involved in the changed reference virtual machine data, and it is rounded up to ensure that all affected data blocks are covered.

[0112] Based on the position index of the starting data block of the changed data and the total number of data blocks count involved in the changed data, the reference position information of the reference data block can be obtained, that is, count data blocks starting from index.

[0113] Optionally, in this embodiment, the method of updating the reference status information in the data bitmap to the first status value according to the calculated reference position information may include: according to the calculated index and count, find the corresponding bit in the data bitmap, and set the status of count bits starting from index in the data bitmap to "1" or a specific value (the first status value) to indicate that the data blocks at these positions have changed. Assume that the granularity parameter of the virtual disk is 4KB (i.e., 4096 bytes), the offset parameter (offset) of the reference virtual machine data requested to be changed in the received disk read / write request is 10KB (i.e., 10240 bytes), and the length parameter (length) is 8KB (i.e., 8192 bytes). Substituting the specific values into the relevant formula for calculating the starting position (index) of the reference data block, we can calculate that index = 3, that is, the starting position (index) of the reference data block corresponding to the reference virtual machine data is 3, indicating that the data block corresponding to the reference virtual machine data is the 3rd data block, corresponding to the 3rd bit in the data bitmap. Substituting the specific values into the relevant formula for calculating the number of affected data blocks (count), we can calculate that count = 3, that is, the total number of data blocks involved in the changed reference virtual machine data is 3. Through index and count, the reference position information of the reference data block can be obtained, that is, count data blocks starting from index, that is, corresponding to the 3rd, 4th, and 5th bits in the data bitmap, and mark the corresponding positions (the 3rd, 4th, and 5th bits) in the data bitmap, and set the bitmap status of the corresponding positions to "1" or a specific value to indicate that the virtual machine data stored in the data blocks at the corresponding positions has changed.

[0114] Through the above steps, the kernel-mode program can accurately update the data bitmap in the target storage space according to the offset parameter and length parameter of the disk read / write request, combined with the granularity parameter of the virtual disk, so as to efficiently record the changes of the virtual machine data in the virtual disk and provide support for virtual machine backup and migration.

[0115] As an alternative solution, backing up the target virtual machine data that has changed in the virtual disk according to the target data bitmap stored in the target storage space includes:

[0116] S91, screen out the backup position information corresponding to the backup status information in the first status value from the status information and position information with corresponding relationships recorded in the target data bitmap, where the status information in the first status value is used to indicate that the virtual machine data stored in the data block corresponding to the position information has changed, and the backup position information is used to indicate the disk position of the data block in the virtual disk where the virtual machine data stored has changed;

[0117] S92, back up the target virtual machine data stored at the disk position indicated by the backup location information in the virtual disk.

[0118] Optionally, in this embodiment, each bit in the target data bitmap corresponds to the status information and location information of a virtual machine data block. Among them, the virtual machine data block is one of the multiple data blocks obtained by dividing the virtual disk according to a fixed backup granularity. The status information indicates whether the virtual machine data stored in the virtual machine data block corresponding to this bit has changed, that is, whether it needs to be backed up. If the status information corresponding to a certain bit in the target data bitmap is the first status value, it means that the virtual machine data stored in the virtual machine data block corresponding to this bit has changed, and then it needs to be backed up. The location information represents the index value of this bit, and the disk location of the virtual machine data block corresponding to this bit in the virtual disk can be obtained through the index value and the backup granularity.

[0119] Optionally, in this embodiment, the step of screening out the backup location information corresponding to the backup status information with the first status value from the target data bitmap is as follows: First, traverse the target data bitmap, starting from the starting position of the target data bitmap, and check the status information of each bit one by one. Then, screen out the backup location information that meets the conditions. If the status information of a certain bit is in the first status value (for example, "1"), it means that the virtual machine data stored in the data block at the corresponding position has changed, and then it needs to be backed up. Then record the index value of this bit in the data bitmap, that is, the backup location information. The disk location of the corresponding data block in the virtual disk can be found through the backup location information, and then the disk location of the virtual machine data that needs to be backed up in the virtual disk can be found.

[0120] Optionally, in this embodiment, after obtaining the location information (backup location information) of the data that needs to be backed up from the target data bitmap, locate the location of the virtual machine data that needs to be backed up in the virtual disk according to the backup location information, read the virtual machine data corresponding to the backup location information, and write the read target virtual machine data into the backup storage space. Among them, the backup storage space can be a local disk, a network storage device, or other storage media that support backup.

[0121] Optionally, in this embodiment, in order to ensure the integrity and consistency of the backup operation, the integrity of the data can be verified through a checksum and / or a hash value.

[0122] As an optional solution, before backing up the target virtual machine data that has changed in the virtual disk according to the target data bitmap stored in the target storage space, the method further includes:

[0123] S101, receive a control instruction sent by the virtual machine;

[0124] S102, when receiving an export control instruction, call the bitmap export interface to export the reference data bitmap stored in the target storage space to the bitmap storage space, where the export control instruction is used to indicate exporting the data bitmap in the storage space, and the bitmap storage space is the storage space that allows storing the data bitmap when a virtual machine exception occurs.

[0125] Optionally, in this embodiment, during the operation of the virtual machine, control instructions can be sent to perform corresponding operations on the data bitmap, including export, load, and deletion, etc., to ensure the security and availability of the data bitmap. Among them, the control instructions can be sent through a virtual machine management tool (such as a QEMU management tool) or an application program inside the virtual machine.

[0126] Optionally, in this embodiment, when receiving a control instruction sent by the virtual machine and confirming that the control instruction is an export control instruction, call the bitmap export interface, such as the QMP interface qmp_vhost_dirty_bitmap_dump in the QEMU layer, to export the reference data bitmap stored in the target storage space to the bitmap storage space. The export control instruction can indicate exporting the data bitmap in the storage space to the bitmap storage space, where the bitmap storage space is the storage space that allows storing the data bitmap when a virtual machine exception or a specified state occurs, and can be a dedicated backup file or storage device.

[0127] Optionally, in this embodiment, to ensure the efficiency and reliability of virtual machine data backup, recovery, and other operations, export the bitmaps in the memory in a unified export format, and record detailed log information after the export is completed. At the same time, considering that the bitmaps are stored in little - endian byte order in the storage space, they need to be converted to big - endian byte order for subsequent processing after export.

[0128] Optionally, in this embodiment, when exporting the reference data bitmap stored in the target storage space to the bitmap storage space, a unified export format can be set for the exported bitmap file. For example, set the exported bitmap file to contain:

[0129] name_len: Record the length of the bitmap name, in bytes. For example, if the bitmap name is "bitmap1", then the value of name_len is 7;

[0130] name: The bitmap name, whose length is specified by name_len. For example, "bitmap1".

[0131] disk_size: The total size of the virtual disk, usually in bytes. For example, if the virtual disk size is 100MB, the value of disk_size is 100 × 1024 × 1024 = 104857600.

[0132] granularity: The granularity of the bitmap, indicating the size of each data block, usually in bytes. For example, if the granularity is 4KB, the value of granularity is 4096.

[0133] bitmapsize: The size of the bitmap, usually in bytes;

[0134] bitmap: The actual data of the bitmap, representing the status of each data block in the virtual disk. Each bit corresponds to a data block, where "1" indicates that the data block has been changed and "0" indicates that the data block has not been changed.

[0135] After setting the unified export format, use the bitmap export interface (such as qmp_vhost_dirty_bitmap_dump) to export the bitmap in memory to a local file. The export path needs to be specified in advance, for example, / path / to / exported_bitmap.bin.

[0136] Optionally, in this embodiment, since the bitmap in the storage space uses little-endian byte order, it needs to be converted to big-endian byte order after export, including: reading the exported bitmap file; for the key fields in the file (such as name_len, disk_size, granularity, bitmapsize), reading byte by byte and rearranging them in big-endian byte order; writing the converted data to a new file or overwriting the original file.

[0137] Optionally, in this embodiment, after the bitmap export operation is completed, record detailed log information for subsequent recovery and viewing. The log information includes: export time, version of the exported data bitmap, export path, and export result, where the export result is used to indicate the status information of successful or failed export.

[0138] Optionally, in this embodiment, when backing up the target virtual machine data with changes in the virtual disk according to the target data bitmap stored in the target storage space, it further includes: calling a bitmap export interface, such as the QMP interface qmp_vhost_dirty_bitmap_dump in the QEMU layer, to export the target data bitmap stored in the target storage space to the bitmap storage space; converting the little-endian byte order adopted by the exported target bitmap file to big-endian byte order, for example, for the key fields (such as name_len, disk_size, granularity, bitmapsize) in the target bitmap file, reading byte by byte and rearranging them in big-endian byte order for byte-by-byte parsing; converting the bitmap data in the target bitmap file to binary format; parsing the converted binary bitmap data bit by bit, and judging which data blocks need to be backed up according to the positions of "1".

[0139] Through the above steps, this embodiment ensures that the changed data blocks in the virtual disk can be efficiently identified and processed during the backup process. By converting the bitmap from little-endian byte order to big-endian byte order, from hexadecimal to binary, and performing bit-by-bit parsing, it can accurately judge which data blocks need to be backed up, thereby improving the backup efficiency and ensuring the integrity and consistency of the data.

[0140] As an optional solution, after calling the bitmap export interface to export the reference data bitmap stored in the storage space to the bitmap storage space, the method further includes:

[0141] S111, receiving a control instruction sent by the virtual machine;

[0142] S112, in the case of receiving a load control instruction, obtaining the reference data bitmap from the bitmap storage space, where the load control instruction is used to indicate loading the data bitmap in the bitmap storage space;

[0143] S113, detecting whether there is a storage space matching the reference data bitmap currently;

[0144] S114, in the case of detecting that there is a first storage space matching the reference data bitmap, calling a bitmap load interface to load the reference data bitmap into the first storage space;

[0145] S115, in the case of not detecting a storage space matching the reference data bitmap, creating a second storage space matching the reference data bitmap, and calling a bitmap load interface to load the reference data bitmap into the second storage space.

[0146] Optionally, in this embodiment, after exporting the data bitmap to the bitmap storage space, when a control instruction sent by the virtual machine is received and it is confirmed that the control instruction is a loading control instruction, the currently stored reference data bitmap is obtained from the bitmap storage space, and the data bitmap in the bitmap storage space is loaded.

[0147] Optionally, in this embodiment, Figure 6 is a flowchart of loading the data bitmap according to the loading control instruction of the embodiment of the present application. As Figure 6 shown, the data bitmap in the bitmap storage space can be loaded, but not limited to, through the following steps: First, obtain the currently stored reference data bitmap from the bitmap storage space. Then, detect whether there is a storage space that matches the reference data bitmap currently. If it is detected that there is a first storage space that matches the reference data bitmap, the bitmap loading interface is called to load the reference data bitmap into the first storage space; in the case where no storage space that matches the reference data bitmap is detected, a second storage space that matches the reference data bitmap is created according to the size and format of the reference data bitmap, and the bitmap loading interface is called to load the reference data bitmap into the second storage space.

[0148] Optionally, in this embodiment, the method of creating a second storage space that matches the reference data bitmap according to the size and format of the reference data bitmap may include: QEMU calls a memory allocation function (such as malloc, mmap, etc.) according to the size and format of the reference data bitmap to apply for memory that matches the size and format of the reference data bitmap in the user space. The applied memory is the second storage space. By loading the reference data bitmap from the bitmap storage space and automatically detecting the status of the storage space to determine whether a storage space needs to be created, it can ensure that after the virtual machine crashes or the system restarts, the state of the data bitmap can be quickly restored, thereby ensuring the continuity and stability of the system.

[0149] Optionally, in this embodiment, after calling the bitmap loading interface to load the reference data bitmap into the first storage space / second storage space, when it is detected that the running position of the backend driver is in the kernel program, QEMU then uses the ioctl system to transfer the space address of the first storage space / second storage space to the kernel program for registration, and notifies the kernel program of the address and size of the first storage space / second storage space. The kernel program can access the first storage space / second storage space through the address of the first storage space / second storage space.

[0150] As an optional solution, after backing up the target virtual machine data with changes in the virtual disk according to the target data bitmap stored in the target storage space, the method further includes:

[0151] S121, receiving a control instruction sent by the virtual machine;

[0152] S122, upon receiving a deletion control instruction, call the bitmap deletion interface to delete the data bitmap stored in the target storage space and release the target storage space, where the deletion control instruction is used to indicate deleting the data bitmap in the target storage space.

[0153] Optionally, in this embodiment, after backing up the changed target virtual machine data in the virtual disk according to the target data bitmap stored in the target storage space, upon receiving a control instruction sent by the virtual machine and confirming that the control instruction is a deletion control instruction, call the bitmap deletion interface, such as the QMP interface qmp_vhost_dirty_bitmap_remove, to delete the data bitmap stored in the target storage space and release the target storage space to ensure the reasonable utilization of system resources, where the deletion control instruction can indicate deleting the data bitmap in the target storage space.

[0154] Optionally, in this embodiment, the method of using the bitmap deletion interface to delete the data bitmap stored in the target storage space may include: First, the QEMU layer sends a notification to the kernel process through an ioctl system call, informing that the target storage space is about to be released. Correspondingly, after receiving the notification, the kernel process stops updating the data bitmap in the target storage space to avoid data conflicts or errors during the process of releasing the target storage space. Then, after confirming that the kernel process has stopped updating the data bitmap, the QEMU layer calls the munmap system call to release the shared memory where the target storage space is located, so that it can be reallocated by the system or used for other purposes.

[0155] Through the above steps, operations of exporting, loading, and deleting the data bitmap can be performed by receiving a control instruction sent by the virtual machine, ensuring that the data bitmap can be restored when the virtual machine is abnormal, and at the same time optimizing the use of storage resources.

[0156] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation method.

[0157] Based on such an understanding, the technical solution of this application, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc) and includes several instructions to enable a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of this application.

[0158] The embodiments of this application also provide an electronic deviceFigure 7 is a schematic diagram of an electronic device according to an embodiment of the present application. As Figure 7 shown, the electronic device includes a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any of the above-described embodiments of the virtual machine data backup method.

[0159] In an exemplary embodiment, the above electronic device may further include a transmission device and an input / output device. Among them, the transmission device is connected to the above processor, and the input / output device is connected to the above processor.

[0160] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary embodiments, and details will not be repeated here.

[0161] An embodiment of the present application further provides a computer-readable storage medium. A computer program is stored in the computer-readable storage medium, and the computer program is configured to execute the steps in any of the above-described embodiments of the virtual machine data backup method when running.

[0162] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: USB flash drives, read-only memories (ROM), random access memories (RAM), external hard drives, magnetic disks, or optical discs, etc., all of which can store computer programs.

[0163] An embodiment of the present application further provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the steps of the methods in various embodiments of the present application; the computer program product further includes a non-volatile computer-readable storage medium. The non-volatile computer-readable storage medium stores the computer program, and when the computer program is executed by the processor, it implements the steps of the virtual machine data backup method in various embodiments of the present application.

[0164] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Skilled professionals can use different methods for each specific application to implement the described functions, but such implementation should not be considered to exceed the scope of the present application.

[0165] The above has introduced in detail a method for backing up virtual machine data provided by this application. Specific examples are used in this article to elaborate on the principle and implementation manner of this application. The description of the above embodiments is only used to help understand the method and its core idea of this application. It should be noted that for those of ordinary skill in the art of this technology, without departing from the principle of this application, several improvements and modifications can be made to this application, and these improvements and modifications also fall within the protection scope of the claims of this application.

Claims

1. A method for backing up virtual machine data, characterized in that Including: Detect the current running position of the backend driver corresponding to the virtual machine, where the backend driver is used to read and write the virtual disk of the virtual machine according to the disk read and write requests sent by the virtual machine; When it is detected that the running position is used to indicate that the backend driver runs on the kernel-mode program, allocate a target storage space for the kernel-mode program; Control the kernel-mode program to update the data bitmap stored in the target storage space, where the data bitmap is used to record the disk positions of the virtual machine data that has changed in the virtual disk; Back up the target virtual machine data that has changed in the virtual disk according to the target data bitmap stored in the target storage space.

2. The method according to claim 1, wherein: The allocating a target storage space for the kernel-mode program includes: Detect whether there is a storage space that matches the bitmap parameter currently, where the bitmap parameter is used to indicate the size of the space required to store the expected data bitmap, and the expected data bitmap is a data bitmap that allows recording the disk positions of the virtual machine data that has changed in the virtual disk; When it is detected that there is a reference storage space that matches the bitmap parameter, transmit the reference space address of the reference storage space to the kernel-mode program, where the reference space address is used to identify the position of the reference storage space, and the target storage space includes the reference storage space; When it is detected that there is no storage space that matches the bitmap parameter, create a candidate storage space according to the bitmap parameter, and transmit the candidate space address of the candidate storage space to the kernel-mode program, where the candidate space address is used to identify the position of the candidate storage space, and the target storage space includes the candidate storage space.

3. The method according to claim 2, wherein: Before creating the candidate storage space according to the bitmap parameter, the method further includes: Obtain the disk parameter and the granularity parameter of the virtual disk, where the disk parameter is used to indicate the capacity of the virtual disk, and the granularity parameter is used to indicate the backup granularity for backing up the data in the virtual disk; Generate the bitmap parameter according to the disk parameter and the granularity parameter.

4. The method according to claim 3, wherein: The generating the bitmap parameter according to the disk parameter and the granularity parameter includes: Call the space creation interface to divide the virtual disk into multiple data blocks according to the disk parameter and the granularity parameter to obtain a data block set; Call the space creation interface to determine the data volume required to record the position information and status information of all the data blocks in the data block set as the bitmap parameter, where the position information is used to indicate the disk position of the corresponding data block in the virtual disk, and the status information is used to indicate whether the virtual machine data stored in the corresponding data block has changed.

5. The method according to claim 2, wherein: Before transmitting the reference space address of the reference storage space to the kernel-mode program, it includes: Detect the format type of the initial data bitmap currently stored in the reference storage space; When the format type is the first format, convert the initial data bitmap from the first format to the second format to obtain a candidate data bitmap, where the first format is the format type used by the user-mode program to update the data bitmap stored in the reference storage space, and the second format is the format type used by the kernel-mode program to update the data bitmap stored in the reference storage space.

6. The method according to claim 5, wherein: The converting the initial data bitmap from the first format to the second format to obtain a candidate data bitmap includes: Screen out target position information and target status information from the initial data bitmap, where the target position information is used to indicate the disk position of each data block in the virtual disk, and the target status information is used to indicate whether the virtual machine data stored in each data block in the virtual disk has changed; Generate the candidate data bitmap in the second format according to the target position information and the target status information.

7. The method according to claim 1, wherein: The controlling the kernel-mode program to update the data bitmap stored in the target storage space includes: Control the kernel-mode program to detect whether the backend driver currently receives the disk read / write request; When it is detected that the backend driver currently receives the disk read / write request, control the kernel-mode program to extract an offset parameter and a length parameter from the disk read / write request, where the offset parameter is used to indicate the starting position of the reference virtual machine data whose request changes in the virtual disk, and the length parameter is used to indicate the length of the storage position of the reference virtual machine data in the virtual disk; Control the kernel-mode program to update the data bitmap stored in the target storage space according to the offset parameter and the length parameter.

8. The method according to claim 7, wherein: The controlling the kernel-mode program to update the data bitmap stored in the target storage space according to the offset parameter and the length parameter includes: Obtain the granularity parameter of the virtual disk, where the granularity parameter is used to indicate the backup granularity for backing up the data in the virtual disk; Detect the reference position information of the reference data block storing the reference virtual machine data according to the offset parameter, the length parameter and the granularity parameter, where the reference data block is a data block in the virtual disk, the virtual disk is pre-divided into multiple data blocks according to the granularity parameter, and the reference position information is used to indicate the disk position of the reference data block in the virtual disk; Update the reference status information corresponding to the reference position information in the data bitmap to a first status value, where the status information in the first status value is used to indicate that the virtual machine data stored in the data block corresponding to the position information has changed.

9. The method according to claim 1, wherein the backing up of the target virtual machine data with changes in the virtual disk according to the target data bitmap stored in the target storage space includes: screening out the backup location information corresponding to the backup status information with a first status value from the status information and location information with a corresponding relationship recorded in the target data bitmap, wherein the status information with the first status value is used to indicate that the virtual machine data stored in the data block corresponding to the location information has changed, and the backup location information is used to indicate the disk location of the data block in the virtual disk where the virtual machine data stored has changed; backing up the target virtual machine data stored at the disk location indicated by the backup location information in the virtual disk.

10. The method according to claim 1, wherein before the backing up of the target virtual machine data with changes in the virtual disk according to the target data bitmap stored in the target storage space, the method further includes: receiving a control instruction sent by the virtual machine; in the case of receiving an export control instruction, calling a bitmap export interface to export the reference data bitmap stored in the target storage space to a bitmap storage space, wherein the export control instruction is used to indicate exporting the data bitmap in the storage space, and the bitmap storage space is a storage space that allows storing the data bitmap when the virtual machine is abnormal.

11. The method according to claim 10, wherein after the calling of the bitmap export interface to export the reference data bitmap stored in the storage space to the bitmap storage space, the method further includes: receiving a control instruction sent by the virtual machine; in the case of receiving a load control instruction, obtaining the reference data bitmap from the bitmap storage space, wherein the load control instruction is used to indicate loading the data bitmap in the bitmap storage space; detecting whether there is a storage space matching the reference data bitmap currently; in the case of detecting that there is a first storage space matching the reference data bitmap, calling a bitmap load interface to load the reference data bitmap into the first storage space; in the case of not detecting a storage space matching the reference data bitmap, creating a second storage space matching the reference data bitmap, and calling the bitmap load interface to load the reference data bitmap into the second storage space.

12. The method according to claim 1, wherein after the backing up of the target virtual machine data with changes in the virtual disk according to the target data bitmap stored in the target storage space, the method further includes: receiving a control instruction sent by the virtual machine; in the case of receiving a delete control instruction, calling a bitmap delete interface to delete the data bitmap stored in the target storage space, and releasing the target storage space, wherein the delete control instruction is used to indicate deleting the data bitmap in the target storage space.

13. An electronic device, characterized in that, including: a memory for storing a computer program; A processor for implementing the steps of the virtual machine data backup method according to any one of claims 1 to 12 when executing the computer program.

14. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, wherein the computer program implements the steps of the virtual machine data backup method according to any one of claims 1 to 12 when executed by a processor.

15. A computer program product comprising a computer program, characterized in that, The computer program implements the steps of the virtual machine data backup method according to any one of claims 1 to 12 when executed by a processor.

Citation Information

Patent Citations

  • Data backup method, device and computer program product

    CN110058959A

  • Data backup method and system for reducing type dependency of file system

    CN117389801A

  • Distributed storage method and device based on vhost protocol and medium

    CN117472278A

  • Data backup method and device

    CN119311471A

  • Method for tracking changes in virtual disks

    US20100228913A1

Cited By

  • Host data reading method, electronic equipment, medium and program product

    CN121143733A