Shared memory-based virtual machine recovery method, device, medium and program product

By directly reconstructing the virtual machine environment through shared memory and utilizing the dual-write memory mechanism to quickly recover the virtual machine in case of failure, the problem of long recovery time and high data consistency risk in traditional solutions is solved, and efficient virtual machine failure recovery is achieved.

CN120743439BActive Publication Date: 2025-11-07LANGCHAO ELECTRONIC INFORMATION IND CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511255558.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-04
Publication Date
2025-11-07
Estimated Expiration
2045-09-04

AI Technical Summary

Technical Problem

Traditional virtual machine high availability solutions suffer from excessively long recovery times, high data consistency risks, and low resource utilization. Existing solutions cannot meet the high availability requirements of high-speed scenarios.

Method used

By directly reconstructing the virtual machine environment through the virtual machine state in shared memory, the bottlenecks of disk read/write and network dependencies are bypassed. The dual-write memory mechanism enables rapid recovery of the virtual machine in case of failure, and data synchronization between shared memory and local memory is achieved.

Benefits of technology

It improves fault recovery efficiency, reduces performance loss, ensures strong data consistency when multiple nodes access the data concurrently, and achieves efficient fault recovery without the business being aware of it.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120743439B_ABST
    Figure CN120743439B_ABST
Patent Text Reader

Abstract

The application discloses a shared memory-based virtual machine recovery method, device, medium and program product, relates to the technical field of cloud computing, and comprises the following steps: starting memory double writing of a target host node, so as to write data received by a target virtual machine in the target host node into shared memory and physical memory of the target host node; if the target host node fails, checking shared memory data of the shared memory based on a fault check value of the target virtual machine; if the checking is passed, running the target virtual machine by using an operating environment of the target virtual machine reconstructed based on the shared memory data through a backup host node, transferring virtual machine data of the target virtual machine in the shared memory to physical memory of the backup host node, and sending a memory double writing instruction to the backup host node, so as to start memory double writing of the backup host node. Therefore, the virtual machine environment can be directly reconstructed through the virtual machine state in the shared memory, the bottleneck of disk reading and writing is skipped, and the fault recovery efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of cloud computing, and particularly relates to a virtual machine recovery method based on shared memory, a device, a medium and a program product. BACKGROUND

[0002] With the continuous expansion of cloud computing and data center scale, as the main carrier of bearing core business, the high availability of virtual machines has become a key requirement, but the traditional virtual machine high availability scheme faces significant challenges, among which, the fault switching based on SAN (Storage Area Network) or NAS (Network Attached Storage) needs to reload the virtual machine image from the disk, resulting in too long recovery time, which cannot meet the demand of virtual machine high availability in high-speed scenarios; the hot standby scheme based on memory replication relies on continuous data synchronization of the network, and with the fluctuation of network state, data loss is easy to occur; the cost of the persistent scheme based on non-volatile memory is too high, and lacks cross-node memory sharing capability.

[0003] Therefore, there is an urgent need for a virtual machine high availability fault recovery scheme to solve the problems of too long recovery time, high data consistency risk and low resource utilization in the traditional high availability scheme. SUMMARY

[0004] The present application provides a virtual machine recovery method based on shared memory, a device, a medium and a program product, which can directly reconstruct the virtual machine environment through the virtual machine state in the shared memory, skip the bottleneck of disk reading and writing and network dependence, and improve the fault recovery efficiency.

[0005] The present application provides a virtual machine recovery method based on shared memory, applied to a virtual machine management end, comprising:

[0006] The memory double writing of the target host node is started by presetting boot parameters, so as to write the data received by the target virtual machine in the target host node into the shared memory and the physical memory of the target host node;

[0007] When it is monitored that the target host node fails, the shared memory data corresponding to the current checkpoint of the shared memory is checked based on the fault check value of the target virtual machine corresponding to the fault checkpoint;

[0008] If the shared memory data passes the verification, a virtual machine takeover instruction is sent to the backup host node, so that the backup host node, after receiving the virtual machine takeover instruction, reconstructs the running environment of the target virtual machine based on the shared memory data, runs the target virtual machine by using the reconstructed running environment, transfers the virtual machine data of the target virtual machine in the shared memory to the physical memory of the backup host node, and sends a memory double-write instruction to the backup host node to start the memory double-write of the backup host node.

[0009] The application further provides a shared memory-based virtual machine recovery device, applied to a virtual machine management end, comprising:

[0010] A data writing module is configured to start the memory double-write of the target host node by using preset boot parameters, so as to write the data received by the target virtual machine in the target host node into the shared memory and the physical memory of the target host node.

[0011] A data verification module is configured to, when monitoring that the target host node has a fault, verify the shared memory data corresponding to the current checkpoint of the shared memory based on the fault verification value of the fault checkpoint corresponding to the target virtual machine.

[0012] A virtual machine transferring module is configured to, if the shared memory data passes the verification, send a virtual machine takeover instruction to the backup host node, so that the backup host node, after receiving the virtual machine takeover instruction, reconstructs the running environment of the target virtual machine based on the shared memory data, runs the target virtual machine by using the reconstructed running environment, transfers the virtual machine data of the target virtual machine in the shared memory to the physical memory of the backup host node, and sends a memory double-write instruction to the backup host node to start the memory double-write of the backup host node.

[0013] The application further provides an electronic device, comprising a memory configured to store a computer program and a processor configured to execute the computer program to implement the steps of any of the shared memory-based virtual machine recovery methods.

[0014] The application further provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of any of the shared memory-based virtual machine recovery methods.

[0015] The application further provides a computer program product, comprising a computer program, and the computer program is executed by a processor to implement the steps of any of the shared memory-based virtual machine recovery methods.

[0016] In the present application, the memory double writing of the target host node is started by presetting a guide parameter, so as to write the data received by the target virtual machine in the target host node into the shared memory and the physical memory of the target host node; when it is monitored that the target host node fails, the shared memory data corresponding to the current checkpoint of the shared memory is checked based on the fault check value of the fault checkpoint corresponding to the target virtual machine; if the shared memory data passes the check, a virtual machine takeover instruction is sent to the standby host node, so that the standby host node reconstructs the running environment of the target virtual machine based on the shared memory data after receiving the virtual machine takeover instruction, and runs the target virtual machine by using the reconstructed running environment, and transfers the virtual machine data of the target virtual machine in the shared memory to the physical memory of the standby host node, and sends a memory double writing instruction to the standby host node, so as to start the memory double writing of the standby host node.

[0017] Therefore, by the method of the present application, the memory double writing of the target host node needs to be started by presetting a guide parameter, so as to write the data received by the target virtual machine into the physical memory and the shared memory of the target host node after the memory double writing is started, and then when the target host node fails, the shared memory data corresponding to the current checkpoint of the shared memory is checked by the fault check value of the fault checkpoint corresponding to the target virtual machine, if the check passes, the standby host node reconstructs the running environment of the target virtual machine based on the data in the shared memory, and runs the virtual machine by using the reconstructed environment, and then migrates the virtual machine data in the shared memory to the local of the standby host node, and starts the memory double writing of the standby host node. In this way, on the one hand, the double writing mechanism can realize the change of the virtual machine memory to be written into the local memory and the shared memory at the same time, avoiding the network replication overhead and reducing the performance loss; on the other hand, the shared memory can ensure the strong consistency of data when multiple nodes access concurrently, thereby ensuring the effectiveness of the recovery when the fault is recovered; further, the virtual machine environment is directly reconstructed by the virtual machine state in the shared memory, bypassing the bottleneck of disk reading and writing, and improving the fault recovery efficiency. BRIEF DESCRIPTION OF DRAWINGS

[0018] In order to more clearly illustrate the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creating laborious work.

[0019] Figure 1 A flow chart of a virtual machine recovery method based on shared memory provided for the embodiments of the present application;

[0020] Figure 2 A virtual machine recovery processing flowchart based on shared memory provided for the embodiments of the present application;

[0021] Figure 3 A virtual machine recovery method based on shared memory provided by an embodiment of the present application is shown in the schematic diagram of the architecture.

[0022] Figure 4 A virtual machine recovery device based on shared memory provided by an embodiment of the present application is shown in the schematic diagram of the structure. DETAILED DESCRIPTION

[0023] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, any other embodiments obtained by those skilled in the art without creative work fall within the protection scope of the present application.

[0024] It should be noted that, in the description of the present application, the terms “comprise”, “contain” or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. The terms “first”, “second” and the like in the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence.

[0025] Currently, the traditional virtual machine high availability solution faces significant challenges. The SAN or NAS-based failover needs to reload the virtual machine image from the disk, resulting in too long recovery time and failing to meet the demand for virtual machine high availability in high-speed scenarios. The hot standby solution based on memory replication relies on continuous network synchronization of data, and with the fluctuation of network state, data loss is easily caused. The cost of the persistent solution based on non-volatile memory is too high, and lacks the cross-node memory sharing capability.

[0026] In order to overcome the above technical problems, the present application discloses a virtual machine recovery method, device, medium and program product based on shared memory, which can directly reconstruct the virtual machine environment through the virtual machine state in the shared memory, skip the bottleneck of disk reading and writing and network dependence, and improve the fault recovery efficiency.

[0027] In order to make those skilled in the art better understand the present application, the present application will be further described in detail below with reference to the drawings and specific embodiments.

[0028] Reference is made to Figure 1As shown, the embodiments of the present application provide a shared memory-based virtual machine recovery method, which is applied to a virtual machine management end. The method is described in detail in combination with the execution flow of the shared memory-based virtual machine recovery method, and includes the following steps.

[0029] In step S11, the memory double writing of the target host node is started through the preset boot parameter, so as to write the data received by the target virtual machine in the target host node into the shared memory and the physical memory of the target host node.

[0030] In this embodiment, as shown in the figure, Figure 2 When the virtual machine management end is started, the CXL (Compute Express Link) memory double writing of the target host node needs to be started through the boot parameter, and when the CXL memory double writing is started, the data can be written into the DRAM (Dynamic Random Access Memory) physical memory and the CXL shared memory of the target host node at the same time. It should be noted that there is also a case where the target host node does not support memory double writing. If the current target host node does not support memory double writing, the write request of the target host node needs to be intercepted. It should be noted that the intercepted write request is a virtual machine memory write request intercepted at the virtual machine software layer. Then, the data to be written corresponding to the write request needs to be written into the physical memory of the target host node based on the write request, and the shared memory physical address of the physical memory of the target host node in the shared memory needs to be determined, and the data to be written is written into the shared memory physical address. Therefore, when the target host node does not support memory double writing, two write operations need to be performed. The first write operation writes the data into the physical address of the target host node local to the original mapping of the client physical address, and the second write operation writes the same data into the physical address in the CXL shared memory which is mapped in advance. In this way, although the performance overhead is increased by performing two write operations, the compatibility of the method of the present application, the availability of the function and the reliability of the data can be guaranteed. Even if the performance is lost, the real-time synchronization of the memory state can be realized, so as to achieve efficient fault recovery.

[0031] In step S12, when the failure of the target host node is monitored, the shared memory data corresponding to the current checkpoint of the shared memory is checked based on the fault check value of the fault checkpoint corresponding to the target virtual machine.

[0032] In this embodiment, as shown in the figure, Figure 2As shown, there can be a situation that the target host node fails, and in the embodiment, the heartbeat monitoring mode is adopted to determine whether the target host node fails. Specifically, a heartbeat message needs to be sent to the target host node based on a preset period, and it is determined whether a heartbeat response of the target host node is received. If the target host node does not feed back the heartbeat response, the heartbeat message is re-sent, and the retry number is recorded. It needs to be noted that the retry number can be set according to the requirement. In the application, the retry number is set to 3, that is, the preset retry number threshold is 3, and the heartbeat retry needs to be performed after a period of interval. In the embodiment, the retry interval is set to 200 milliseconds. When the recorded retry number is greater than the preset retry number threshold, it can be determined that the target host node fails.

[0033] Further, when it is determined that the target host node fails, the write permission of the shared memory needs to be frozen. Specifically, when it is monitored that the target host node fails, a data write freeze instruction is sent to the shared memory, so that the shared memory closes the data write permission based on the data write freeze instruction after receiving the data write freeze instruction. In this way, by freezing the write permission of the memory, it can be prevented that other nodes that can still be running continue to write data to the memory area, so as to avoid data damage and consistency problem, and create a stable snapshot environment for the next data verification.

[0034] Further, as shown in FIG. 6, when it is determined that the target host node fails, the write permission of the shared memory needs to be frozen. Specifically, when it is monitored that the target host node fails, a data write freeze instruction is sent to the shared memory, so that the shared memory closes the data write permission based on the data write freeze instruction after receiving the data write freeze instruction. In this way, by freezing the write permission of the memory, it can be prevented that other nodes that can still be running continue to write data to the memory area, so as to avoid data damage and consistency problem, and create a stable snapshot environment for the next data verification. Figure 2As shown, the memory data needs to be checked, and the shared memory data corresponding to the current checkpoint needs to be checked by the fault check value of the target virtual machine corresponding to the fault checkpoint. Specifically, the latest current checkpoint of the shared memory needs to be determined, and the target check value of the shared memory data corresponding to the current checkpoint needs to be calculated by a preset verification algorithm. In this embodiment, the CRC64 (Cyclic Redundancy Check 64, cyclic redundancy check algorithm based on 64-bit code length) algorithm is used to calculate the check value. Then, the latest fault checkpoint corresponding to the target virtual machine needs to be determined, and the fault check value corresponding to the fault checkpoint needs to be extracted, that is, the CRC64 checksum of the target virtual machine state data in the shared memory needs to be calculated, and it is matched and compared with the check value of the latest fault checkpoint recorded last time. It needs to be noted that when calculating the check value, the shared memory data corresponding to the current checkpoint needs to be determined; the shared memory data is processed by taking the remainder based on the preset data block size, so as to obtain the remainder value of the shared memory data after the remainder processing, and the remainder value is taken as the target check value of the shared memory data. If the fault check value matches the target check value, it is determined that the shared memory data passes the check. If the fault check value does not match the target check value, it is determined that the shared memory data does not pass the check. It needs to be noted that CRC64 is a strong check algorithm with extremely low collision probability, which is used to confirm whether the data is completely and accurately written into the shared memory from the last checkpoint to the fault occurrence instant. If the fault check value matches the target check value, it means that the data in CXL is complete and consistent. If it does not match, it means that the data may have been damaged, for example, the CXL link is interrupted instantaneously during double writing. In this way, it can be confirmed whether the data is completely and accurately written into the CXL memory from the last checkpoint to the fault occurrence instant, and then the corresponding virtual machine recovery scheme is selected according to different situations, thereby ensuring the high availability of virtual machine recovery.

[0035] In step S13, if the shared memory data passes the check, a virtual machine takeover instruction is sent to the standby host node, so that the standby host node reconstructs the running environment of the target virtual machine based on the shared memory data after receiving the virtual machine takeover instruction, and runs the target virtual machine by using the reconstructed running environment, and transfers the virtual machine data of the target virtual machine in the shared memory to the physical memory of the standby host node, and sends a memory double writing instruction to the standby host node to start the memory double writing of the standby host node.

[0036] In this embodiment, if the shared memory data passes the check, it means that the CXL data is normal, for example, Figure 2As shown, the virtual machine recovery can be performed by the method of CXL fast recovery. Specifically, the virtual machine takeover instruction needs to be sent to the standby host node, and the access permission of the shared memory needs to be passed to the standby host node, so that the standby host node reads the shared memory based on the access permission, and maps the shared memory data and the memory state data in the shared memory to the physical memory of the standby host node. That is, the virtual machine management end needs to inform the standby host node to prepare for virtual machine takeover and grant it access permission to CXL shared memory. The Hypervisor of host B directly maps the memory data of the virtual machine in the CXL shared memory to the local, and this mapping method is a zero-copy process, without the need to transmit a large amount of memory data on the network, nor the need to load from the disk, greatly saving time. Further, the standby host node needs to reconstruct the running environment of the target virtual machine based on the memory state data, so as to run the target virtual machine based on the running environment. Specifically, based on the page table information in the memory state data, the memory of the target virtual machine needs to be mapped to the local of the standby host node, and based on the register state data in the memory state data, a virtual machine thread needs to be created for the target virtual machine. In this way, the running environment of the target virtual machine is reconstructed by the shared memory data, and the memory is mapped by the zero-copy method, effectively improving the efficiency of virtual machine recovery and ensuring the high availability of the virtual machine.

[0037] Further, the dual-write mechanism of the standby host node needs to be started, so the virtual machine memory page of the target virtual machine needs to be asynchronously copied from the shared memory to the physical memory of the standby host node, and the mapping between the virtual machine memory page and the physical memory of the standby host node needs to be established. During the asynchronous copying of the memory page, the memory page of the target virtual machine needs to be copied from the shared memory to the physical memory of the standby host node, and it is necessary to track whether a memory dirty page is generated during the copying of the memory page. If a memory dirty page is generated, the memory page is iteratively copied for multiple rounds, so that the dirty page generated in the previous round of iteration is copied in each round of iteration, until the number of remaining dirty pages is less than a preset threshold. It needs to be noted that, since the target virtual machine is still running, the memory pages that have been copied may be modified again during the copying process. Therefore, these dirty pages need to be dynamically tracked, and a background task iteratively copies these dirty pages for multiple rounds until the generation rate of the dirty pages exceeds the copying rate or the number of remaining dirty pages is sufficiently small. Finally, the target virtual machine needs to be paused until the remaining dirty pages have been copied to the physical memory of the standby host node. Specifically, when the number of remaining dirty pages drops to a very low threshold, such as 64 4KB pages, the vCPU (virtual Central Processing Unit) of the target virtual machine is temporarily paused. At the moment when the vCPU is paused, the memory state is static, and the last batch of dirty pages needs to be quickly synchronized so that the data on the standby host node is completely consistent with the data in the shared memory. In this way, the data migration can be implemented without the awareness of the business, and the dual-write mechanism of the standby host node can be started.

[0038] As can be seen, by the method of the present application, the memory dual-write of the target host node is started by using the preset boot parameter, so that the data received by the target virtual machine is written to the physical memory and the shared memory of the target host node after the memory dual-write is started. When the target host node fails, the shared memory data corresponding to the current checkpoint of the shared memory is checked by using the fault check value corresponding to the fault checkpoint of the target virtual machine, and if the check is passed, the running environment of the target virtual machine is reconstructed based on the data in the shared memory by using the standby host node, and the virtual machine is run in the reconstructed environment. Then, the virtual machine data in the shared memory is migrated to the local of the standby host node, and the memory dual-write of the standby host node is started. In this way, on the one hand, the dual-write mechanism can realize the change of the virtual machine memory to be written to the local memory and the shared memory, avoiding the network replication overhead and reducing the performance loss. On the other hand, the shared memory can ensure data strong consistency when multiple nodes access concurrently, thereby ensuring the effectiveness of the recovery when a fault occurs. On the other hand, the virtual machine environment is directly reconstructed by using the virtual machine state in the shared memory, thereby skipping the bottleneck of disk read / write and improving the fault recovery efficiency.

[0039] As a preferred embodiment, asFigure 2 If the shared memory data fails the verification, the virtual machine can be restored by mirroring. Specifically, if the shared memory data fails the verification, a mirror loading instruction is sent to the standby host node, so that the standby host node obtains the virtual machine image of the target virtual machine from the preset shared distributed storage after receiving the mirror loading instruction, and re-runs the target virtual machine through the virtual machine image. The standby host node needs to perform a complete virtual machine startup process, including disk initialization and memory state reconstruction. In addition, the standby host node reconstructs the virtual machine data and the memory state of the target virtual machine based on the virtual machine image, so as to re-run the target virtual machine according to the virtual machine data and the memory state. Thus, although the virtual machine recovery by mirroring is less efficient than the shared memory-based method, the virtual machine can still be recovered in the case where the shared memory recovery is not supported, thereby ensuring the high availability of the virtual machine recovery.

[0040] As a preferred embodiment, as shown in Figure 3 The architecture of the virtual machine recovery method based on shared memory is shown in the figure. The virtual machine management end starts the memory double writing of the target host node through preset boot parameters, writes the data received by the target virtual machine in the target host node into the shared memory and the physical memory of the target host node, and determines whether the target host node fails through heartbeat detection. When the target host node fails, the running environment of the target virtual machine is reconstructed based on the shared memory data in the shared memory, and the memory mapping is performed through zero-copy to transfer the virtual machine from the target host node to the standby host node, and then the virtual machine is recovered. In the case where the shared memory data fails the verification, the virtual machine is recovered through the virtual machine image saved in the preset shared distributed storage. In this way, the high availability of the virtual machine is effectively ensured.

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

[0042] As shown in Figure 4 The embodiment of the application also provides a virtual machine recovery device based on shared memory, which is applied to a virtual machine management end and includes:

[0043] The data writing module 11 is configured to start the memory double writing of the target host node through preset boot parameters, so as to write the data received by the target virtual machine in the target host node into the shared memory and the physical memory of the target host node;

[0044] The data checking module 12 is configured to, when it is monitored that the target host node fails, check shared memory data corresponding to a current checkpoint of the shared memory based on a failure checking value of a failure checkpoint corresponding to the target virtual machine.

[0045] The virtual machine transferring module 13 is configured to, if the shared memory data passes the check, send a virtual machine takeover instruction to the standby host node, so that the standby host node reconstructs a running environment of the target virtual machine based on the shared memory data after receiving the virtual machine takeover instruction, and runs the target virtual machine by using the reconstructed running environment, and transfers virtual machine data of the target virtual machine in the shared memory to a physical memory of the standby host node, and sends a memory double-write instruction to the standby host node to start memory double-write of the standby host node.

[0046] In some embodiments, the shared memory-based virtual machine recovery apparatus can further include:

[0047] The request intercepting unit is configured to, if the target host node currently does not support memory double-write, intercept a write request of the target host node.

[0048] The first data writing unit is configured to write to-be-written data corresponding to the write request into a physical memory of the target host node based on the write request.

[0049] The second data writing unit is configured to determine a shared memory physical address of the shared memory in which the physical memory of the target host node is located, and write the to-be-written data into the shared memory physical address.

[0050] In some embodiments, the shared memory-based virtual machine recovery apparatus can further include:

[0051] The heartbeat message sending unit is configured to send a heartbeat message to the target host node based on a preset period, and determine whether a heartbeat response of the target host node is received.

[0052] The sending retry unit is configured to, if the target host node does not feed back the heartbeat response, resend the heartbeat message, and record a retry number.

[0053] The failure determining unit is configured to, if the retry number is greater than a preset retry number threshold, determine that the target host node fails.

[0054] In some embodiments, the shared memory-based virtual machine recovery apparatus can further include:

[0055] The permission closing unit is configured to send a data write freezing instruction to the shared memory when it is monitored that the target host node fails, so that the shared memory closes the data write permission based on the data write freezing instruction after receiving the data write freezing instruction.

[0056] In some embodiments, the data verification module 12 can specifically include:

[0057] The check value calculation submodule is configured to determine the latest current checkpoint of the shared memory, and calculate a target check value of the shared memory data corresponding to the current checkpoint through a preset verification algorithm.

[0058] The check value extraction submodule is configured to determine the latest failure checkpoint corresponding to the target virtual machine, and extract a failure check value corresponding to the failure checkpoint.

[0059] The check value matching submodule is configured to match the failure check value and the target check value.

[0060] The check judgment submodule is configured to determine that the shared memory data passes the verification if the failure check value matches the target check value, and determine that the shared memory data fails the verification if the failure check value does not match the target check value.

[0061] In some embodiments, the check value calculation submodule can specifically include:

[0062] The shared data determination unit is configured to determine the shared memory data corresponding to the current checkpoint.

[0063] The check value determination unit is configured to perform a modulo operation on the shared memory data based on a preset data block size to obtain a remainder value of the shared memory data after the modulo operation, and take the remainder value as the target check value of the shared memory data.

[0064] In some embodiments, the virtual machine transfer module 13 can specifically include:

[0065] The first virtual machine running submodule is configured to send a virtual machine takeover instruction to the standby host node, and transfer the access permission of the shared memory to the standby host node, so that the standby host node reads the shared memory based on the access permission, maps the shared memory data and memory state data in the shared memory to the physical memory of the standby host node, and reconstructs the running environment of the target virtual machine based on the memory state data, to run the target virtual machine based on the running environment.

[0066] In some embodiments, the first virtual machine running submodule can specifically include:

[0067] a thread creation unit, configured to map, by the standby host node, memory of the target virtual machine to a local of the standby host node based on page table information in the memory state data, and create a virtual machine thread for the target virtual machine based on register state data in the memory state data.

[0068] In some embodiments, the shared memory-based virtual machine recovery apparatus can further include:

[0069] a second virtual machine running submodule, configured to send, to the standby host node, an image loading instruction if the shared memory data fails the verification, so that the standby host node acquires a virtual machine image of the target virtual machine from a preset shared distributed storage after receiving the image loading instruction, and re-runs the target virtual machine through the virtual machine image.

[0070] In some embodiments, the second virtual machine running submodule can specifically include:

[0071] a virtual machine running unit, configured to reconstruct, by the standby host node, virtual machine data and a virtual machine memory state of the target virtual machine based on the virtual machine image, so as to re-run the target virtual machine according to the virtual machine data and the virtual machine memory state.

[0072] In some embodiments, the virtual machine transfer module 13 can specifically include:

[0073] a mapping establishing submodule, configured to asynchronously copy virtual machine memory pages of the target virtual machine from the shared memory to physical memory of the standby host node, and establish a mapping between the virtual machine memory pages and the physical memory of the standby host node.

[0074] In some embodiments, the mapping establishing submodule can specifically include:

[0075] a memory page copying unit, configured to copy memory pages of the target virtual machine from the shared memory to physical memory of the standby host node, and track whether a memory dirty page is generated during the copying of the memory pages;

[0076] an iterative copying unit, configured to perform multiple rounds of iterative copying on the memory pages if the memory dirty page is generated, so as to copy a dirty page generated in a previous round of iteration in each round of iteration, until a number of remaining dirty pages is lower than a preset threshold;

[0077] a virtual machine pausing unit, configured to pause the target virtual machine until the remaining dirty pages have been copied to the physical memory of the standby host node.

[0078] The features of the embodiments of the shared memory-based virtual machine recovery device can be referred to the related descriptions of the embodiments of the shared memory-based virtual machine recovery method, which will not be repeated here.

[0079] The embodiments of the present application also provide an electronic device, comprising a memory and a processor, the memory stores a computer program, and the processor is configured to execute the computer program to perform the steps in any of the above-mentioned embodiments of the shared memory-based virtual machine recovery method.

[0080] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program, wherein the computer program is configured to perform the steps in any of the above-mentioned embodiments of the shared memory-based virtual machine recovery method when executed.

[0081] In an example embodiment, the above-mentioned computer readable storage medium can include but is not limited to: a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store computer programs.

[0082] The embodiments of the present application also provide a computer program product, which comprises a computer program, and the computer program is executed by a processor to implement the steps in any of the above-mentioned embodiments of the shared memory-based virtual machine recovery method.

[0083] The embodiments of the present application also provide another computer program product, which comprises a non-volatile computer readable storage medium, and the non-volatile computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps in any of the above-mentioned embodiments of the shared memory-based virtual machine recovery method.

[0084] The skilled person can further realize that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been described in general terms in the above description. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0085] The above describes in detail a virtual machine recovery method, device, medium and program product based on shared memory provided by the present application. The principles and implementation modes of the present application are described by applying specific examples, and the above description of the examples is only applicable to help understand the method of the present application and its core idea. It should be pointed out that, for ordinary skilled persons in the technical field, some improvements and modifications can be made to the present application without departing from the principles of the present application, and these improvements and modifications also fall within the protection scope of the claims of the present application.

Claims

1. A shared memory-based virtual machine recovery method, characterized by, The application is applied to a virtual machine management terminal, and comprises the following steps: Starting memory double writing of a target host node by using preset boot parameters, so as to write data received by a target virtual machine in the target host node into shared memory and physical memory of the target host node; When it is monitored that the target host node fails, checking shared memory data corresponding to a current checkpoint of the shared memory based on a failure check value of a failure checkpoint corresponding to the target virtual machine; If the shared memory data passes the check, sending a virtual machine takeover instruction to a backup host node, so that the backup host node reconstructs a running environment of the target virtual machine based on the shared memory data after receiving the virtual machine takeover instruction, and runs the target virtual machine by using the reconstructed running environment, and transfers virtual machine data of the target virtual machine in the shared memory to physical memory of the backup host node, and sends a memory double writing instruction to the backup host node, so as to start memory double writing of the backup host node.

2. The shared memory-based virtual machine recovery method according to claim 1, wherein, After the step of starting memory double writing of the target host node by using the preset boot parameters, so as to write data received by the target virtual machine in the target host node into the shared memory and the physical memory of the target host node, the method further comprises the following steps: If the target host node does not currently support memory double writing, intercepting a write request of the target host node; Based on the write request, writing data to be written corresponding to the write request into the physical memory of the target host node; Determining a shared memory physical address of the shared memory in the physical memory of the target host node, and writing the data to be written into the shared memory physical address.

3. The shared memory-based virtual machine recovery method according to claim 1, wherein, Before the step of, when it is monitored that the target host node fails, checking shared memory data corresponding to a current checkpoint of the shared memory based on a failure check value of a failure checkpoint corresponding to the target virtual machine, the method further comprises the following steps: Based on a preset period, sending a heartbeat message to the target host node, and determining whether a heartbeat response of the target host node is received; If the target host node does not feed back the heartbeat response, re-sending the heartbeat message, and recording a retry number; If the retry number is greater than a preset retry number threshold, it is determined that the target host node fails.

4. The shared memory-based virtual machine recovery method according to claim 1, wherein, Before the step of, when it is monitored that the target host node fails, checking shared memory data corresponding to a current checkpoint of the shared memory based on a failure check value of a failure checkpoint corresponding to the target virtual machine, the method further comprises the following steps: When it is monitored that the target host node fails, sending a data write freezing instruction to the shared memory, so that the shared memory closes a data write permission based on the data write freezing instruction after receiving the data write freezing instruction.

5. The shared memory based virtual machine recovery method according to claim 1, wherein, The step of checking shared memory data corresponding to a current checkpoint of the shared memory based on a failure check value of a failure checkpoint corresponding to the target virtual machine comprises the following steps: Determining a latest current checkpoint of the shared memory, and calculating a target check value of shared memory data corresponding to the current checkpoint by using a preset checking algorithm; determining that the target virtual machine corresponds to a latest fault checkpoint, and extracting a fault check value corresponding to the fault checkpoint; matching the fault check value and the target check value; if the fault check value matches the target check value, determining that the shared memory data passes the check, and if the fault check value does not match the target check value, determining that the shared memory data fails the check.

6. The shared memory-based virtual machine recovery method according to claim 5, wherein, The target check value of the shared memory data corresponding to the current checkpoint is calculated by a preset verification algorithm, including: determining the shared memory data corresponding to the current checkpoint; based on a preset data block size, performing a remainder processing on the shared memory data to obtain a remainder value of the shared memory data after the remainder processing, and taking the remainder value as the target check value of the shared memory data.

7. The shared memory based virtual machine recovery method according to claim 1, wherein, The standby host node sends a virtual machine takeover instruction to the standby host node, so that the standby host node reconstructs the running environment of the target virtual machine based on the shared memory data after receiving the virtual machine takeover instruction, including: sending a virtual machine takeover instruction to a standby host node and transferring access rights of the shared memory to the standby host node, so that the standby host node reads the shared memory based on the access rights, and maps the shared memory data and memory state data in the shared memory to the physical memory of the standby host node, and reconstructs the running environment of the target virtual machine based on the memory state data, to run the target virtual machine based on the running environment.

8. The shared memory based virtual machine recovery method according to claim 7, wherein, The process of reconstructing the running environment of the target virtual machine by the standby host node based on the memory state data, including: The standby host node maps the memory of the target virtual machine to the local of the standby host node based on the page table information in the memory state data, and creates a virtual machine thread for the target virtual machine based on the register state data in the memory state data.

9. The shared memory based virtual machine recovery method according to claim 1, wherein, After checking the shared memory data corresponding to the current checkpoint of the shared memory, it further includes: if the shared memory data fails the check, send an image loading instruction to the standby host node, so that the standby host node obtains a virtual machine image of the target virtual machine from a preset shared distributed storage after receiving the image loading instruction, and re-runs the target virtual machine through the virtual machine image.

10. The shared memory based virtual machine recovery method according to claim 9, wherein, The process of re-running the target virtual machine by the standby host node through the virtual machine image, including: The standby host node reconstructs the virtual machine data and the virtual machine memory state of the target virtual machine based on the virtual machine image, to re-run the target virtual machine according to the virtual machine data and the virtual machine memory state.

11. The shared memory based virtual machine recovery method according to any one of claims 1 to 10, wherein, The virtual machine data of the target virtual machine in the shared memory is transferred to the physical memory of the standby host node, including: Asynchronously copying the virtual machine memory page of the target virtual machine from the shared memory to the physical memory of the standby host node, and establishing a mapping between the virtual machine memory page and the physical memory of the standby host node.

12. The shared memory based virtual machine recovery method according to claim 11, wherein, The copying the virtual machine memory page of the target virtual machine from the shared memory to the physical memory of the standby host node asynchronously comprises: copying the memory page of the target virtual machine from the shared memory to the physical memory of the standby host node and tracking whether a memory dirty page is generated during the copying of the memory page; if the memory dirty page is generated, performing multi-round iterative copying on the memory page to copy the dirty page generated in the previous round of iteration in each round of iteration until the number of remaining dirty pages is lower than a preset threshold; suspending the target virtual machine until the remaining dirty pages have been copied to the physical memory of the standby host node.

13. An electronic device, comprising: comprise: a memory for storing a computer program; a processor for implementing the steps of the shared memory-based virtual machine recovery method according to any one of claims 1 to 12 when executing the computer program.

14. A computer-readable storage medium, characterized in that, The computer program is stored in the computer readable storage medium, and when the computer program is executed by the processor, the steps of the shared memory-based virtual machine recovery method according to any one of claims 1 to 12 are implemented.

15. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the shared memory-based virtual machine recovery method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Hyper-converged platform fault recovery method, device, electronic equipment and storage medium

    CN112148485A

  • Data sharing method and device, processor, electronic equipment and readable storage medium

    CN118467102A