Method for generating virtual machine snapshot and server

During the virtual machine snapshot generation process, the virtual machine is suspended based on the memory dirty page data and the remaining memory of the host, and the data is stored in the cache, which solves the problem of long business interruption in the existing technology and improves snapshot generation efficiency and accuracy.

CN118963909APending Publication Date: 2024-11-15XFUSION DIGITAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410949324.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-15
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

In the existing virtual machine snapshot technology, business interruption time is long, which affects operational efficiency.

Method used

When generating snapshots, determine whether to pause the virtual machine based on the memory dirty page data size to be stored and the remaining memory size of the host, and store the memory dirty page data in the host cache to improve replication speed and reduce business interruption time.

Benefits of technology

It effectively reduces the duration of virtual machine business interruption, improves snapshot generation efficiency, and reduces the number of iterations and storage time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118963909A_ABST
    Figure CN118963909A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a method for generating a virtual machine snapshot and a server, and the method comprises the steps: storing the memory data of a virtual machine in a storage medium under the condition that the generation of the virtual machine snapshot is triggered. And obtaining memory dirty page data to be stored. And then based on the to-be-stored memory dirty page data, controlling the virtual machine to suspend running, storing the to-be-stored memory dirty page data into a cache of the host, and generating a snapshot of the virtual machine. According to the method, in the process of generating the virtual machine snapshot, the operation of the virtual machine is paused by determining the pause time point of the virtual machine, and the memory dirty page data can be stored in the cache of the host, so that the speed of copying the memory data of the virtual machine is increased, the copying time is shortened, and the service interruption duration of the virtual machine can be shortened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of snapshot processing, and in particular to a method and a server for generating a virtual machine snapshot. Background Art

[0002] A virtual machine refers to a complete computer system that runs in a completely isolated environment and has complete hardware system functions, simulated by software. Any work that can be done in a physical computer can be done in a virtual machine. When creating a virtual machine for application, in order to prevent data loss and other problems due to virtual machine failure, the virtual machine can be disaster-recovered. For example, a virtual machine can be snapshot stored. A snapshot represents a fully usable copy of a specified data set, which includes an image of the corresponding data at a certain point in time (the point in time when the copy starts). The main function of a snapshot is to enable online data backup and recovery. When a system failure occurs or a file is damaged, the data can be restored to the state at the time of the last snapshot.

[0003] Virtual machine snapshots are an important business scenario for virtualization platforms. They can save the memory state, disk state, and virtual machine configuration data of a virtual machine at a certain moment. These snapshots can be restored at a later point in time so that the virtual machine can be restored to the state at the time of the previous snapshot.

[0004] At present, the main method for virtual machine snapshots is incremental snapshots. The implementation principle of incremental snapshots is to copy the memory data that has changed since the last snapshot, iterate multiple times until the memory changes are reduced to a certain extent, then suspend the virtual machine to copy the last changed data and generate a disk snapshot, and then resume the virtual machine. However, in the current technology, there are problems such as long business interruption time, which affects business operations. Summary of the invention

[0005] The embodiments of the present application provide a method and a server for generating a virtual machine snapshot, which can reduce the duration of service interruption.

[0006] In a first aspect, an embodiment of the present application provides a method for generating a virtual machine snapshot, the method comprising: storing the memory data of the virtual machine in a storage medium when the generation of a snapshot is triggered; obtaining memory dirty page data to be stored; controlling the virtual machine to suspend operation based on the memory dirty page data to be stored; and when the virtual machine is suspended, storing the memory dirty page data to be stored in the cache of the host to generate a snapshot of the virtual machine.

[0007] In the process of generating a virtual machine snapshot, it is determined whether to suspend the operation of the virtual machine according to the memory dirty page data to be stored, and the snapshot process is executed to store the memory dirty page data in the cache of the host, so as to increase the rate of copying the memory data of the virtual machine, reduce the copying time, and reduce the service interruption duration of the virtual machine. It should be pointed out that in the embodiment of the present application, the optimal suspension time point can be achieved in the case of large memory dirty page data, so the number of iterations can be reduced.

[0008] In one possible implementation, based on the memory dirty page data to be stored, the virtual machine is controlled to suspend operation, including: when the size of the memory dirty page data to be stored is smaller than the size of the remaining memory of the host, or the size of the memory dirty page data to be stored is smaller than a preset threshold, the virtual machine is controlled to suspend operation.

[0009] When the memory dirty page data to be stored is smaller than the remaining memory of the host, or the size of the memory dirty page data to be stored is smaller than a preset threshold, it indicates that the memory dirty page data to be stored can be stored in the cache. Compared with storing the memory dirty page data in the storage medium, the speed of copying the memory data of the virtual machine can be increased, the copying time can be reduced, and the service interruption duration of the virtual machine can be reduced.

[0010] In one possible implementation, when the size of the memory dirty page data to be stored is smaller than the size of the remaining memory, the virtual machine is controlled to suspend operation, including: when the size of the memory dirty page data to be stored is smaller than the size of the remaining memory, determining the estimated time for storing the memory dirty page data to be stored in the cache; when the estimated time is smaller than the preset time, the virtual machine is controlled to suspend operation.

[0011] When the size of the memory dirty page data to be stored is smaller than the size of the remaining memory, the estimated time for storing the memory dirty page data to be stored in the cache can also be determined, and only when the estimated time is smaller than the preset time, the virtual machine will be controlled to suspend operation to facilitate subsequent execution, which can further ensure that the business interruption duration of the virtual machine will not be too long.

[0012] In one possible implementation, determining an estimated time to store memory dirty page data to be stored in a cache includes: determining a first duration for storing the memory data in a storage medium; determining a memory dirty page rate based on the memory dirty page data to be stored and the first duration; and determining an estimated time to store the memory dirty page data to be stored in the cache based on a memory rate of the host and the memory dirty page rate.

[0013] The virtual machine pause time point is calculated by using the host's memory rate and the rate at which dirty memory page data is generated. This can achieve the optimal pause time point when there is a large amount of dirty memory page data and reduce the number of iterations for storing dirty memory page data.

[0014] In one possible implementation, based on the host's memory rate and memory dirty page rate, an estimated time for storing memory dirty page data to be stored in the cache is determined, including: determining the storage rate based on the difference between the host's memory rate and the memory dirty page rate; determining the estimated time based on the size of the memory dirty page data to be stored and the ratio of the storage rate.

[0015] Since the memory dirty page data generated by the virtual machine is also in the host's memory, it can be similar to a memory copy process. Therefore, it is necessary to use the host's memory rate minus the memory dirty page rate to determine the rate of storage to the cache.

[0016] In one possible implementation, when the size of the memory dirty page data to be stored is larger than the size of the remaining memory, the method further includes: re-executing the storage of the memory dirty page data to be stored in the storage medium, obtaining new memory dirty page data to be stored, and subsequent steps until the size of the new memory dirty page data to be stored is less than or equal to the size of the remaining memory.

[0017] When the size of the dirty memory page data to be stored is larger than the remaining memory size, the control virtual machine will not be suspended. Instead, the process of storing the dirty memory page data to the storage medium will be re-executed to avoid storing the dirty memory page data to be stored in the host cache for too long, causing the virtual machine business to be interrupted for too long.

[0018] In one possible implementation, the method further includes: when the estimated time is greater than or equal to the preset time, re-storing the memory dirty page data to be stored in the storage medium, obtaining new memory dirty page data to be stored, and subsequent steps until the estimated time is less than the preset time.

[0019] When the estimated time for storing the dirty memory page data to be stored in the cache is greater than or equal to the preset time, it indicates that the storage time is long, that is, the virtual machine needs to be suspended for a long time. In this case, the process of storing the dirty memory page data to be stored in the cache may not be performed. Instead, the dirty memory page data to be stored may be stored in the storage medium. In this case, there is no need to suspend the operation of the virtual machine, thereby avoiding excessive business interruption of the virtual machine.

[0020] In a possible implementation, the method further includes one or more of the following: restoring the running state of the virtual machine; or storing the dirty memory page data to be stored in the cache to a storage medium, and deleting the dirty memory page data to be stored in the cache.

[0021] When the virtual machine snapshot process is completed, the running state of the virtual machine is restored to avoid a long interruption of the virtual machine. Then, the dirty memory page data to be stored in the host cache can be stored in the storage medium, that is, the cache is cleared, so that the cache can continue to store dirty memory page data.

[0022] In a possible implementation, determining a memory dirty page rate based on memory dirty page data generated by the virtual machine within a first time period includes: calculating a ratio of a size of the memory dirty page data to the first time period to determine the memory dirty page rate.

[0023] In a second aspect, an embodiment of the present application provides a device for generating a virtual machine snapshot, the device comprising:

[0024] A first storage unit, configured to store the memory data of the virtual machine into a storage medium when generating a snapshot is triggered;

[0025] An acquisition unit, used for acquiring memory dirty page data to be stored;

[0026] A control unit, used for controlling the virtual machine to suspend operation based on the memory dirty page data to be stored;

[0027] The second storage unit is used to store the dirty memory page data to be stored in the cache when the virtual machine is suspended;

[0028] A generation unit is used to generate a snapshot of a virtual machine.

[0029] In a possible implementation, the control unit is specifically configured to obtain the remaining memory of the host; when the size of the dirty page data to be stored is smaller than the size of the remaining memory, the virtual machine is controlled to suspend operation.

[0030] In one possible implementation, the control unit is specifically used to determine the estimated time for storing the dirty memory page data to be stored in the cache when the size of the dirty memory page data to be stored is smaller than the size of the remaining memory; when the estimated time is smaller than the preset time, control the virtual machine to suspend operation.

[0031] In one possible implementation, the control unit is specifically used to determine a first duration for storing memory data in a storage medium; determine a memory dirty page rate based on the memory dirty page data to be stored and the first duration; and determine an estimated time for storing the memory dirty page data to be stored in a cache based on the host's memory rate and the memory dirty page rate.

[0032] In a possible implementation, the control unit is specifically used to determine the storage rate based on the difference between the host's memory rate and the memory dirty page rate; and determine the estimated time based on the ratio of the size of the memory dirty page data to be stored and the storage rate.

[0033] In one possible implementation, the device is also used to: when the size of the memory dirty page data to be stored is larger than the size of the remaining memory, re-execute the storage of the memory dirty page data to be stored in the storage medium, obtain new memory dirty page data to be stored and subsequent steps until the size of the new memory dirty page data to be stored is less than or equal to the size of the remaining memory.

[0034] In one possible implementation, the device is also used to: when the estimated time is greater than or equal to the preset time, re-execute the storage of the memory dirty page data to be stored in the storage medium, obtain new memory dirty page data to be stored and subsequent steps until the estimated time is less than the preset time.

[0035] In one possible implementation, the device also includes: a recovery unit, used to restore the running state of the virtual machine; or, a first storage unit, also used to store the dirty memory page data to be stored in the cache to a storage medium; or, the device also includes: a deletion unit, used to delete the dirty memory page data to be stored in the cache.

[0036] In a possible implementation, the control unit is specifically configured to calculate a ratio of a size of memory dirty page data to a first duration to determine a memory dirty page rate.

[0037] In a third aspect, an embodiment of the present application provides a server, the server comprising: a memory and a processor;

[0038] The memory is used to store relevant program codes;

[0039] The processor is used to call the program code to execute the method for generating a virtual machine snapshot in any one of the implementations of the first aspect above.

[0040] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which is used to store a computer program, and the computer program is used to execute the method for generating a virtual machine snapshot in any one of the implementations of the first aspect above.

[0041] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a computer program / instructions. When the computer program / instructions are executed by a processor, the method for generating a virtual machine snapshot in any one of the implementation methods of the first aspect above is implemented.

[0042] It can be seen that the embodiments of the present application have the following beneficial effects:

[0043] In the above implementation of the embodiment of the present application, when triggering the generation of a virtual machine snapshot, the memory data of the virtual machine can first be stored in the storage medium. Among them, the memory data can represent all the memory data of the virtual machine copied for the first time, or it can represent the memory data that changes after the copy, that is, the memory dirty page data. When copying the memory data, since the virtual machine is still in operation, the virtual machine will also generate new memory data, that is, memory dirty page data, during the time when the memory data is stored in the storage medium, and the memory dirty page data to be stored generated during the time when the memory data is stored in the storage medium can be obtained. Based on the memory dirty page data to be stored, the virtual machine is controlled to suspend operation, and then the memory dirty page data to be stored is stored in the cache of the host, and a snapshot of the virtual machine is generated to complete the process of generating a virtual machine snapshot. Through the method provided in the embodiment of the present application, in the process of generating a virtual machine snapshot, the operation of the virtual machine is suspended by determining the suspension time point of the virtual machine, and then the memory dirty page data is stored in the cache of the host, so as to increase the rate of copying the memory data of the virtual machine, reduce the copy time, and reduce the service interruption duration of the virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. It is obvious that the drawings described below are only some embodiments provided in the present application, and a person skilled in the art can also obtain other drawings based on these drawings.

[0045] Figure 1 A schematic diagram of the structure of a hyper-converged virtualization platform provided in an embodiment of the present application;

[0046] Figure 2 A flowchart of a method for generating a virtual machine snapshot provided in an embodiment of the present application;

[0047] Figure 3 A flowchart of another method for generating a virtual machine snapshot provided in an embodiment of the present application;

[0048] Figure 4 A flowchart of another method for generating a virtual machine snapshot provided in an embodiment of the present application;

[0049] Figure 5 A schematic diagram of a device for generating a virtual machine snapshot provided in an embodiment of the present application;

[0050] Figure 6 A schematic diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0051] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. The described embodiments are only exemplary implementation methods of the present application, not all implementation methods. Those skilled in the art can combine the embodiments of the present application to obtain other embodiments without creative work, and these embodiments are also within the scope of protection of the present application.

[0052] Hyper-converged infrastructure is an information infrastructure that integrates virtual computing resources and storage devices. The same set of unit equipment not only has computing, network, storage and server virtualization resources and technologies, but also includes backup software, snapshot technology, online data compression, etc., and multiple sets of unit equipment can be aggregated through the network to achieve modular seamless horizontal expansion and form a unified resource pool.

[0053] Virtualization, software-defined storage and automation are the core of hyper-convergence technology. Virtualization enables multiple virtual machines to run simultaneously on a physical server, improving the utilization of hardware resources. A virtual machine refers to a complete computer system with complete hardware system functions that is simulated by software and runs in a completely isolated environment. Any work that can be done in a physical computer can also be done in a virtual machine.

[0054] When creating a virtual machine for application, in order to prevent data loss and other problems caused by virtual machine failure, you can perform disaster recovery on the virtual machine. For example, you can store snapshots of the virtual machine. A snapshot represents a fully available copy of a specified data set, which includes an image of the corresponding data at a certain point in time (the time when the copy starts). The main function of a snapshot is to enable online data backup and recovery. When a system failure occurs or a file is damaged, the data can be restored to the state at the time of the last snapshot.

[0055] Virtual machine snapshots are an important business scenario for virtualization platforms. They can save the memory state, disk state, and virtual machine configuration data of a virtual machine at a certain moment. These snapshots can be restored at a later point in time so that the virtual machine can be restored to the state at the time of the previous snapshot.

[0056] The embodiment of the present application provides a method for generating a virtual machine snapshot, which can reduce the time of generating a virtual machine snapshot. The embodiment of the present application is implemented based on the principle of incremental snapshot. When triggering the generation of a virtual machine snapshot, the memory data of the virtual machine can be first stored in a storage medium. Among them, the memory data can represent all the memory data of the virtual machine for the first time, or it can represent the memory data that changes after the replication, that is, the memory dirty page data. When copying the memory data, since the virtual machine is still in operation, the virtual machine will also generate new memory data, that is, memory dirty page data, during the time when the memory data is stored in the storage medium, and the memory dirty page data to be stored generated during the time when the memory data is stored in the storage medium can be obtained. Based on the memory dirty page data to be stored, the virtual machine is controlled to suspend operation, and then the memory dirty page data to be stored is stored in the cache of the host, and a snapshot of the virtual machine is generated to complete the process of generating a virtual machine snapshot. Through the method provided by the embodiment of the present application, in the process of generating a virtual machine snapshot, the operation of the virtual machine is suspended by determining the suspension time point of the virtual machine, and then the memory dirty page data is stored in the cache of the host, so as to increase the rate of copying the memory data of the virtual machine, reduce the replication time, and reduce the service interruption duration of the virtual machine.

[0057] The following first introduces a specific application scenario.

[0058] See also Figure 1 , which is a schematic diagram of the structure of a hyper-converged virtualization platform provided in an embodiment of the present application.

[0059] Optionally, the hyper-converged virtualization platform mainly consists of three parts: a host cluster, a virtual machine pool, and a hyper-converged control platform. Among them, the host cluster may include multiple hosts, such as host 1, host 2, ..., host m, where m is an integer greater than or equal to 2. The virtual machine pool may include multiple virtual machines, such as virtual machine 1, virtual machine 2, ..., virtual machine n, where n is an integer greater than or equal to 2. The host is physically existing computer hardware, and the virtual machine is a computer environment simulated by software on the host, which can run operating systems and applications, and multiple virtual machines can run on one host.

[0060] The hyper-converged control platform may include a host memory management unit, a virtual machine memory management unit, and a snapshot control unit. The host memory management unit may monitor the resource status of the host memory, including the remaining memory size, memory rate, etc., and may send the recorded data to the snapshot control unit for processing. The virtual machine memory management unit may copy memory data, monitor the memory dirty page data of the virtual machine, and may send the monitored recorded data to the snapshot control unit for processing.

[0061] The snapshot control unit can execute the process of generating a virtual machine snapshot. Specifically, when the generation of the snapshot is triggered, the memory data of the virtual machine is stored in the storage medium. The memory dirty page data to be stored generated during the time of storing the memory data in the storage medium is obtained. The memory data of the virtual machine and the memory dirty page data generated subsequently can be sent to the snapshot control unit by the virtual machine memory management unit. Then, based on the memory dirty page data to be stored, the virtual machine is controlled to suspend operation, the memory dirty page data to be stored is stored in the cache, and a snapshot of the virtual machine is generated.

[0062] In order to facilitate the understanding of the technical solutions provided by the embodiments of the present application, a detailed introduction will be given below in conjunction with the drawings in the specification.

[0063] See also Figure 2 , Figure 2 A flowchart of a method for generating a virtual machine snapshot is provided in an embodiment of the present application.

[0064] S201: When generating a snapshot, the memory data of the virtual machine is stored in a storage medium.

[0065] When a request to trigger the generation of a virtual machine snapshot is obtained, the process of generating a virtual machine snapshot is started. The operation of triggering the generation of a snapshot can be manually triggered or timed, that is, the process of generating a virtual machine snapshot can be manually triggered by a user, or a task of generating a virtual machine snapshot can be pre-set to trigger the generation of a virtual machine snapshot. For example, the generation of a virtual machine snapshot can be triggered every 15 minutes.

[0066] When executing the snapshot process of a virtual machine, the memory data of the virtual machine needs to be stored in a storage medium first. The embodiment of the present application does not limit the specific type of the storage medium. For example, the storage medium for storing memory data may be a hard disk, a storage all-in-one machine, etc. A storage all-in-one machine may represent a hardware device that integrates a storage device and a computing device. The storage all-in-one machine integrates storage resources and computing resources together, and realizes data storage and processing through high-speed interconnection technology.

[0067] When the memory data of the virtual machine is copied for the first time (i.e., the memory data is stored in the storage medium), it is necessary to store all the memory data of the virtual machine to the storage medium. At this time, the virtual machine is still in a normal operating state, so when storing the previous memory data, the virtual machine will also generate new memory data, i.e., memory dirty page data, and the newly generated memory dirty page data can be stored later, that is, incremental copying of the memory data is achieved. In this embodiment, the memory data in step S201 can be represented as the first storage of all the memory data of the virtual machine, and can also be represented as the subsequent storage of newly generated memory dirty page data.

[0068] S202: Obtain memory dirty page data to be stored.

[0069] In the process of storing memory data in the storage medium, the virtual machine is still in a normal operating state and new memory data will be generated. Therefore, the newly generated memory dirty page data to be stored in the process of storing the memory data can be obtained.

[0070] S203: Based on the memory dirty page data to be stored, control the virtual machine to suspend operation.

[0071] In order to increase the rate of copying virtual machine memory data and reduce the time required for copying, since the host's memory read and write rate is greater than the storage medium's memory data storage rate, a cache can be allocated in the host's remaining memory to store the virtual machine's memory dirty page data, thereby reducing the time for storing memory dirty page data. Since the virtual machine needs to be controlled to suspend operation when storing memory dirty page data, the duration of virtual machine business interruption can also be shortened. Since the host's remaining memory space may be limited, it can be determined whether to store the memory dirty page data to be stored in the host's remaining memory based on the size of the memory dirty page data to be stored and the size of the host's remaining memory, that is, whether to control the virtual machine to suspend operation.

[0072] In specific implementation, the remaining memory in the host can be obtained first. Before storing the dirty memory page data to be stored in the cache of the host, the size of the dirty memory page data to be stored can be compared with the size of the remaining memory in the host. When the size of the dirty memory page data to be stored is smaller than the size of the remaining memory (i.e., the optimal pause time point of the virtual machine), it indicates that all the dirty memory page data can be stored in the remaining memory of the host. At this time, the virtual machine can be controlled to pause, which facilitates the subsequent step of storing the dirty memory page data to be stored in the remaining memory.

[0073] Since the size of the host's remaining memory is larger than the size of the memory dirty page data to be stored, at this time, the cache can be allocated in the host's remaining memory according to the size of the memory dirty page data to be stored, so that the size of the cache is the same as the size of the memory dirty page data to be stored, or the size of the cache can be made slightly larger than the size of the memory dirty page data to be stored, so that the memory dirty page data to be stored can be stored in the cache later.

[0074] Optionally, when the size of the dirty memory page data to be stored is larger than the size of the remaining memory, it indicates that the dirty memory page data cannot be stored in the remaining memory of the host at this time. At this time, the dirty memory page data may not be stored in the remaining memory of the host, and the subsequent snapshot process may not be executed, but the execution of step S201 may be returned, that is, the dirty memory page data to be stored is stored in the storage medium again, and new dirty memory page data to be stored and subsequent steps are obtained. That is, the dirty memory page data to be stored is stored in the storage medium again, and the newly generated dirty memory page data to be stored is obtained, and it is determined whether the size of the newly generated dirty memory page data to be stored is smaller than the size of the remaining memory of the host. If so, the virtual machine may be controlled to suspend operation. Otherwise, the execution of step S201 may be returned, and it may be iterated until the size of the newly generated dirty memory page data to be stored is smaller than the size of the remaining memory of the host.

[0075] When it is determined that the size of the dirty memory page data to be stored is smaller than the size of the remaining memory of the host, the virtual machine can be controlled to suspend operation, so that the dirty memory page data to be stored is stored in the cache in the subsequent execution, and no new dirty memory page data is generated.

[0076] Optionally, when the size of the memory dirty page data to be stored is less than a preset threshold (i.e., the optimal pause time point of the virtual machine), the virtual machine is controlled to pause. When the size of the memory dirty page data to be stored is greater than the preset threshold, the memory dirty page data to be stored is stored in a storage medium, and this is iterated until the size of the newly generated memory dirty page data to be stored is less than the preset threshold, the virtual machine is controlled to pause, and then subsequent steps are executed. The set threshold can be set in advance by the user.

[0077] It should be pointed out that in the embodiment of the present application, it is possible to achieve the optimal pause time point in the case of large memory dirty page data, thereby reducing the number of iterations.

[0078] In the above embodiment, the time point for controlling the virtual machine to suspend operation can be determined based on the size of the host's remaining memory and the size of the memory dirty page data. Optionally, in order to further shorten the duration of the virtual machine suspension operation, it can also be determined based on the estimated time for storing the memory dirty page data to be stored.

[0079] Since the virtual machine needs to be suspended when generating a memory snapshot, which causes business interruption of the virtual machine, in order to avoid the virtual machine from being suspended for a long time, a preset time can be pre-set as the maximum time for the virtual machine to be suspended, so as to minimize the impact on the running state of the virtual machine. Therefore, the size of the estimated time and the preset time can be judged. When the estimated time is less than the preset time, it indicates that the time for storing the dirty memory page data to be stored is short and within a reasonable time range, that is, the time for the virtual machine to be suspended is within a reasonable range. At this time, the virtual machine can be controlled to be suspended, which is convenient for the subsequent execution of the step of storing the dirty memory page data to be stored in the cache.

[0080] In a possible implementation, when the size of the dirty memory page data to be stored is smaller than the size of the remaining memory, an estimated time for storing the dirty memory page data to be stored in the cache can be determined. When the estimated time is smaller than a preset time, the virtual machine can be controlled to suspend operation, so as to facilitate the subsequent step of storing the dirty memory page data to be stored in the cache.

[0081] In a specific implementation, the estimated time for storing the memory dirty page data to be stored in the cache can be determined in the following manner. For the process of storing the memory data of the virtual machine in the storage medium in step S201, the first duration for storing the memory data of the virtual machine in the storage medium can be determined. Based on the memory dirty page data to be stored generated by the virtual machine within the first duration, the memory dirty page rate is determined. Specifically, the size of the generated memory dirty page data to be stored can be calculated, and the ratio between the size and the first duration can be used to determine the memory dirty page rate. Then, based on the memory rate of the host and the memory dirty page rate, the estimated time for storing the memory dirty page data to be stored in the cache is determined. When the estimated time is less than the preset time (i.e., the optimal pause time point of the virtual machine), the virtual machine is controlled to pause.

[0082] It should be noted that the embodiment of the present application does not limit the specific value of the preset time, and it can be adjusted according to the importance of the program running in the virtual machine, etc.

[0083] Since the host needs to allocate its own memory to the virtual machine, the memory dirty page data generated by the virtual machine also needs to occupy the host's memory. In fact, it can be understood that the host copies the memory data. Therefore, when the host stores the memory dirty page data, the difference between the host's memory rate and the memory dirty page rate can be used to represent the storage rate of storing the memory dirty page data to be stored in the cache.

[0084] In a possible implementation, the storage rate can be determined based on the difference between the host's memory rate and the memory dirty page rate, and then the ratio of the size of the memory dirty page data to be stored to the storage rate is calculated to obtain an estimated time for storing the memory dirty page data to be stored in the cache.

[0085] Using the host's memory rate and memory dirty page rate to calculate the virtual machine's pause time point can meet the optimal pause time point in the case of large memory dirty page data, and can reduce the number of iterations for storing memory dirty page data.

[0086] It should be noted that in actual application scenarios, when calculating the storage rate, it may not be just a simple difference between the host's memory rate and the memory dirty page rate. For example, there may be multiple other virtual machines running in the host, so some weight coefficients can be added to the host's memory rate or memory dirty page rate based on actual needs. However, the principle of excluding the memory dirty page rate from the host's memory rate is the same, and other possible implementation methods will not be listed one by one in the embodiments of this application.

[0087] In a possible implementation, when the estimated time for storing the dirty memory page data to be stored in the cache is greater than or equal to the preset time, it indicates that the time for controlling the virtual machine to be suspended is long, which will affect the business of the virtual machine, etc. At this time, the virtual machine will not be controlled to be suspended, but the dirty memory page data to be stored will continue to be stored in the storage medium. That is, the dirty memory page data to be stored in the storage medium is stored again, and new dirty memory page data to be stored and subsequent steps are obtained until the calculated estimated time is less than the preset time. That is, the dirty memory page data to be stored is stored in the storage medium, and the first time required for storing the dirty memory page data to be stored in the storage medium is obtained. Based on the newly generated dirty memory page data to be stored by the virtual machine within the first time, a new dirty memory page rate is re-determined. Based on the memory rate of the host and the new dirty memory page rate, the estimated time for storing the new dirty memory page data to be stored in the cache is determined, and the above process is repeated until the recalculated estimated time is less than the preset time, and then the virtual machine is controlled to be suspended.

[0088] S204: When the virtual machine is suspended, the dirty memory page data to be stored is stored in the cache, and a snapshot of the virtual machine is generated.

[0089] When the control virtual machine is suspended, the dirty memory page data to be stored can be stored in the cache of the host, and a snapshot of the virtual machine, ie, a copy of the current state data of the virtual machine, is generated.

[0090] Optionally, in order to reduce the time for generating a virtual machine snapshot and shorten the duration of virtual machine service interruption, the storage of the dirty memory page data to be stored and the generation of the virtual machine snapshot may be performed simultaneously, and the two processes do not conflict with each other and do not affect each other.

[0091] When generating a snapshot of a virtual machine, you can generate a virtual machine snapshot based on different virtualization platforms. For example, you can achieve this in the following way: in the interface of the virtualization platform, select the virtual machine for which you want to generate a snapshot. Based on the setting window of the virtual machine, select the snapshot function tab. In the snapshot function tab, select a similar option to take a snapshot to create a snapshot of the virtual machine. You can also enter a name and related description for the created snapshot so that you can identify the snapshot based on the name and related description later. Click "OK" or a similar button to save the snapshot settings and close the settings window. At this point, the virtualization platform can capture the current state of the virtual machine, including the virtual machine's memory, disk, configuration, etc., and save it as a snapshot.

[0092] Through the method provided in the embodiment of the present application, in the process of generating a virtual machine snapshot, the operation of the virtual machine is suspended by determining the suspension time point of the virtual machine, and the memory dirty page data can be stored in the cache of the host to increase the rate of copying the memory data of the virtual machine, reduce the copying time, and reduce the business interruption duration of the virtual machine.

[0093] In a possible implementation, after the virtual machine snapshot process is completed, the running state of the virtual machine can be restored to prevent the virtual machine from being suspended for too long and affecting the business of the virtual machine. In addition, the dirty memory page data to be stored in the host cache can be stored in the storage medium, so that when the memory image is generated, the dirty memory page data to be stored in the cache can be deleted to release the host's memory space, which is convenient for the subsequent storage of the virtual machine's memory data.

[0094] In the above embodiment, a process of controlling a virtual machine to suspend operation and generate a virtual machine snapshot when the size of the memory dirty page data to be stored is smaller than the size of the remaining memory is introduced. In a possible implementation, when the size of the memory dirty page data to be stored is greater than or equal to the size of the remaining memory, it is also possible to determine whether part of the memory data in the memory dirty page data can be stored in the remaining memory of the host by judging the size of the difference between the memory dirty page data to be stored and the remaining memory.

[0095] First, the remaining memory in the host is obtained. When the size of the memory dirty page data to be stored is greater than or equal to the size of the remaining memory, the difference between the size of the memory dirty page data to be stored and the size of the remaining memory can be determined first. When the difference is less than or equal to the preset value, it indicates that most of the memory dirty page data to be stored can be stored in the remaining memory, and the remaining memory dirty page data to be stored can be stored in the storage medium. Compared with the prior art of storing all memory data in the storage medium, the rate of storing the memory dirty page data to be stored can also be significantly improved.

[0096] Specifically, when the difference between the size of the memory dirty page data to be stored and the size of the remaining memory is less than or equal to a preset value, the target memory dirty page data in the memory dirty page data to be stored can be determined based on the size of the remaining memory in the host. That is, the size of the target memory dirty page data is made the same as the size of the remaining memory. At this time, the entire remaining memory in the host is the cache for storing the target memory dirty page data. Then, the virtual machine is controlled to suspend operation, the target memory dirty page data in the memory dirty page data to be stored is stored in the cache, and a snapshot of the virtual machine is generated.

[0097] Since the size of the dirty memory page data to be stored is greater than or equal to the size of the remaining memory, the dirty memory page data to be stored may contain the remaining dirty memory page data that has not been stored in the cache in addition to the target dirty memory page data. Therefore, the remaining dirty memory page data can be determined based on the dirty memory page data to be stored and the target dirty memory page data, and then the remaining dirty memory page data can be stored in the storage medium to implement the copying process of all memory data.

[0098] In one possible implementation, when the difference between the size of the memory dirty page data to be stored and the size of the remaining memory is greater than a preset value, it indicates that the size of the memory dirty page data to be stored is quite different from the size of the remaining memory. At this time, the total time for storing part of the memory dirty page data to be stored in the remaining memory and storing the remaining memory dirty page data to be stored in the storage medium is long. In this case, the process of storing the memory dirty page data to be stored in the storage medium and the subsequent process are re-executed, that is, obtaining the new memory dirty page data to be stored generated again within the storage time, and re-judging the size of the new memory dirty page data to be stored and the size of the remaining memory of the host. The subsequent execution process will not be elaborated here.

[0099] Based on the above method embodiment, the present application embodiment also provides a method for generating a virtual machine snapshot. Figure 3 , which is a flowchart of another method for generating a virtual machine snapshot provided in an embodiment of the present application.

[0100] The method may include the following steps:

[0101] S301: In response to a virtual machine being in a running state, triggering a process of generating a virtual machine snapshot.

[0102] Among them, the operation of triggering the generation of snapshots can be manually triggered or timed triggered, that is, the process of generating virtual machine snapshots can be manually triggered by the user, or the task of generating virtual machine snapshots can be pre-set to timed trigger, that is, the process of generating virtual machine snapshots is triggered at fixed intervals.

[0103] S302: Obtain a second duration for storing the memory data (or memory dirty page data) of the virtual machine in the storage medium.

[0104] That is, when generating a memory image of a virtual machine, all memory data of the virtual machine needs to be copied to the storage medium for the first time, and the corresponding second duration is obtained. At this time, the virtual machine is still in a normal operating state, so when storing the current memory data, the virtual machine will also generate new memory data, that is, memory dirty page data, and the newly generated memory dirty page data can be stored later, that is, incremental copying of memory data is achieved.

[0105] S303: Determine a memory dirty page rate based on the memory dirty page data to be stored generated by the virtual machine within the second time period.

[0106] Specifically, the ratio of the size of the memory dirty page data to the second time length may be calculated to determine the memory dirty page rate.

[0107] S304: Determine whether the remaining memory of the host is larger than the size of the dirty page data to be stored. If yes, execute step S305; otherwise, jump to execute step S302.

[0108] When the size of the remaining memory is larger than the size of the memory dirty page data to be stored, it indicates that all the memory dirty page data to be stored can be stored in the remaining memory of the host, and the snapshot process can be continued.

[0109] S305: Allocate cache in the remaining memory.

[0110] That is, the size of the allocated cache is determined according to the size of the memory dirty page data to be stored.

[0111] S306: Determine an estimated time for storing the memory dirty page data to be stored in the cache based on the memory rate and the memory dirty page rate of the host.

[0112] Since the host needs to allocate its own memory to the virtual machine, the memory dirty page data generated by the virtual machine also needs to occupy the host's memory, which can be understood as the host copying the memory data. Therefore, when the host stores the memory dirty page data, the difference between the host's memory rate and the memory dirty page rate can be used to represent the storage rate of storing the memory dirty page data to be stored in the cache (the remaining memory of the host).

[0113] In a possible implementation, the storage rate may be determined based on the difference between the host's memory rate and the memory dirty page rate, and then the ratio of the size of the memory dirty page data to be stored to the storage rate is calculated to obtain an estimated time for storing the memory dirty page data to be stored.

[0114] It should be noted that in actual application scenarios, when calculating the storage rate, it may not be just a simple difference between the host's memory rate and the memory dirty page rate. For example, there may be multiple other virtual machines running in the host, so some weight coefficients can be added to the host's memory rate or memory dirty page rate based on actual needs. However, the principle of excluding the memory dirty page rate from the host's memory rate is the same, and other possible implementation methods will not be listed one by one in the embodiments of this application.

[0115] S307: When the estimated time is less than the preset time, control the virtual machine to suspend operation.

[0116] When generating a virtual machine's memory snapshot, the virtual machine needs to be suspended, which causes a business interruption of the virtual machine. In order to avoid the virtual machine from being suspended for a long time, a preset time can be set in advance as the maximum time for the virtual machine to be suspended, so as to minimize the impact on the virtual machine's running state. Therefore, the size of the estimated time and the preset time can be determined. When the estimated time is less than the preset time, it indicates that the virtual machine's suspension time is within a reasonable range. At this time, the virtual machine can be controlled to be suspended and the subsequent process can be executed.

[0117] In a possible implementation, when the estimated time for storing the dirty memory page data to be stored in the cache is greater than or equal to the preset time, it indicates that the time for controlling the virtual machine to be suspended is long, which will affect the business of the virtual machine, etc. At this time, the virtual machine will not be controlled to be suspended, but the dirty memory page data to be stored will continue to be stored in the storage medium. That is, the second time length for storing the dirty memory page data to be stored in the storage medium and subsequent steps are re-executed until the calculated estimated time is less than the preset time.

[0118] S308: When the virtual machine is suspended, the dirty memory page data to be stored is stored in the cache, and a snapshot of the virtual machine is generated.

[0119] When the control virtual machine is suspended, the dirty memory page data to be stored can be stored in the cache of the host, and a snapshot of the virtual machine is generated.

[0120] Based on the above method embodiment, the present application embodiment also provides a method for generating a virtual machine snapshot. Figure 4 , which is a flowchart of another method for generating a virtual machine snapshot provided in an embodiment of the present application.

[0121] The method comprises the following steps:

[0122] A1: The virtual machine is in running state;

[0123] A2: triggers the process of generating a virtual machine snapshot;

[0124] Among them, the operation of triggering the generation of snapshots can be manually triggered or timed triggered, that is, the process of generating virtual machine snapshots can be manually triggered by the user, or the task of generating virtual machine snapshots can be pre-set to timed trigger, that is, the process of generating virtual machine snapshots is triggered at fixed intervals.

[0125] A3: Store the virtual machine's memory data into the storage medium;

[0126] A4: Determine whether the size of the dirty page data to be stored is smaller than the size of the remaining memory of the host;

[0127] A5: If yes, allocate cache in the remaining memory; otherwise, jump to step A3;

[0128] A6: Control the virtual machine to suspend operation;

[0129] A7: Store the dirty memory page data to be stored in the cache.

[0130] A8: Generate a snapshot of the virtual machine;

[0131] A9: Restore the running status of the virtual machine;

[0132] When the snapshot process of the virtual machine is completed, the running state of the virtual machine is restored, thereby preventing the virtual machine from being suspended for too long and affecting the business of the virtual machine.

[0133] A10: Store the dirty memory page data in the cache into the storage medium;

[0134] A11: Delete the dirty memory page data in the cache.

[0135] Storing dirty memory page data in the host cache in a storage medium can delete dirty memory page data in the cache while generating a memory image, thereby releasing the host's memory space and facilitating subsequent storage of virtual machine memory data in the host's memory.

[0136] Based on the above method embodiment, the present application embodiment also provides a device for generating a virtual machine snapshot. Figure 5 , which is a schematic diagram of a device for generating a virtual machine snapshot provided in an embodiment of the present application.

[0137] The apparatus 500 may include:

[0138] The first storage unit 501 is used to store the memory data of the virtual machine into a storage medium when generating a snapshot;

[0139] An acquisition unit 502 is used to acquire memory dirty page data to be stored;

[0140] A control unit 503, configured to control the virtual machine to suspend operation based on the memory dirty page data to be stored;

[0141] The second storage unit 504 is used to store the dirty memory page data to be stored in the cache when the virtual machine is suspended;

[0142] The generating unit 505 is used to generate a snapshot of the virtual machine.

[0143] In a possible implementation, the control unit 503 is specifically configured to obtain the remaining memory of the host; when the size of the dirty page data to be stored is smaller than the size of the remaining memory, the virtual machine is controlled to suspend operation.

[0144] In one possible implementation, the control unit 503 is specifically used to determine the estimated time for storing the dirty page data to be stored in the cache when the size of the dirty page data to be stored is smaller than the size of the remaining memory; when the estimated time is smaller than the preset time, control the virtual machine to suspend operation.

[0145] In one possible implementation, the control unit 503 is specifically used to determine a first duration for storing memory data in a storage medium; determine a memory dirty page rate based on the memory dirty page data to be stored and the first duration; and determine an estimated time for storing the memory dirty page data to be stored in the cache based on the host's memory rate and the memory dirty page rate.

[0146] In a possible implementation, the control unit 503 is specifically used to determine the storage rate based on the difference between the host's memory rate and the memory dirty page rate; and determine the estimated time based on the ratio of the size of the memory dirty page data to be stored and the storage rate.

[0147] In one possible implementation, the device is also used to: when the size of the memory dirty page data to be stored is larger than the size of the remaining memory, re-execute the storage of the memory dirty page data to be stored in the storage medium, obtain new memory dirty page data to be stored and subsequent steps until the size of the new memory dirty page data to be stored is less than or equal to the size of the remaining memory.

[0148] In one possible implementation, the device is also used to: when the estimated time is greater than or equal to the preset time, re-execute the storage of the memory dirty page data to be stored in the storage medium, obtain new memory dirty page data to be stored and subsequent steps until the estimated time is less than the preset time.

[0149] In one possible implementation, the device also includes: a recovery unit, used to restore the running state of the virtual machine; or, a first storage unit, also used to store the dirty memory page data to be stored in the cache to a storage medium; or, the device also includes: a deletion unit, used to delete the dirty memory page data to be stored in the cache.

[0150] In a possible implementation, the control unit 503 is specifically configured to calculate a ratio of the size of the memory dirty page data to the first duration, and determine the memory dirty page rate.

[0151] Based on the above method embodiment and device embodiment, the present application embodiment further provides a server, which will be described below in conjunction with the accompanying drawings.

[0152] See also Figure 6 , Figure 6 A schematic diagram of a server provided in an embodiment of the present application.

[0153] The server 600 includes: a memory 601 and a processor 602;

[0154] The memory 601 is used to store relevant program codes;

[0155] The processor 602 is used to call the program code to execute the method for generating a virtual machine snapshot described in the above method embodiment.

[0156] In addition, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method for generating a virtual machine snapshot described in the above method embodiment.

[0157] It should be noted that the technical features of the higher-level means provided in the embodiments of the present application are clear to those skilled in the art, and the problems to be solved by the higher-level means are also clear. The means for obtaining the corresponding features can be selected by those skilled in the art according to specific implementation requirements. The means provided in this application should not be regarded as a limitation on the solution or as the only means of implementation.

[0158] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can refer to each other. In particular, for the system or device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only exemplary, in which the units or modules described as separate components may or may not be physically separated, and the components displayed as units or modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units, and some or all of the units or modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.

[0159] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the method, device and equipment etc. of various embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of the boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0160] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0161] It should also be noted that, in this application, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0162] The steps of the method or algorithm described in conjunction with the embodiments disclosed in this application can be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module can be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0163] The above description of the disclosed embodiments enables professionals and technicians in the field to implement or use the present application. Various modifications to these embodiments will be apparent to professionals and technicians in the field, and the general principles defined in this application can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown in the present application, but will conform to the widest range consistent with the principles and novel features disclosed in the present application.

Claims

1. A method for generating a virtual machine snapshot, characterized in that: The method comprises: When the snapshot is triggered, the memory data of the virtual machine is stored in a storage medium; Get the memory dirty page data to be stored; Based on the memory dirty page data to be stored, controlling the virtual machine to suspend operation; When the virtual machine is suspended, the dirty memory page data to be stored is stored in the cache of the host, and a snapshot of the virtual machine is generated.

2. The method according to claim 1, characterized in that The controlling the virtual machine to suspend operation based on the memory dirty page data to be stored includes: When the size of the dirty memory page data to be stored is smaller than the size of the remaining memory of the host, or the size of the dirty memory page data to be stored is smaller than a preset threshold, the virtual machine is controlled to suspend operation.

3. The method according to claim 2, characterized in that When the size of the dirty page data to be stored is smaller than the size of the remaining memory, controlling the virtual machine to suspend operation includes: When the size of the memory dirty page data to be stored is smaller than the size of the remaining memory, determining an estimated time for storing the memory dirty page data to be stored in the cache; When the estimated time is less than the preset time, the virtual machine is controlled to suspend operation.

4. The method according to claim 3, characterized in that The determining an estimated time for storing the dirty memory page data to be stored in the cache includes: Determining a first duration for storing the memory data in the storage medium; Determine a memory dirty page rate based on the memory dirty page data to be stored and the first time length; Based on the memory rate of the host and the memory dirty page rate, an estimated time for storing the memory dirty page data to be stored in the cache is determined.

5. The method according to claim 4, characterized in that The determining, based on the memory rate of the host and the memory dirty page rate, an estimated time for storing the memory dirty page data to be stored in the cache includes: Determine a storage rate based on a difference between a memory rate of the host and a memory dirty page rate; The estimated time is determined based on the ratio of the size of the memory dirty page data to be stored and the storage rate.

6. The method according to claim 2, characterized in that The method further comprises: When the size of the memory dirty page data to be stored is larger than the size of the remaining memory, the memory dirty page data to be stored is stored in the storage medium.

7. The method according to claim 3, characterized in that The method further comprises: When the estimated time is greater than or equal to the preset time, the memory dirty page data to be stored is stored in the storage medium.

8. The method according to any one of claims 1 to 7, characterized in that: The method may further include one or more of the following: Restoring the running state of the virtual machine; or, The dirty memory page data to be stored in the cache is stored in the storage medium, and the dirty memory page data to be stored in the cache is deleted.

9. The method according to claim 4, characterized in that The determining a memory dirty page rate based on the memory dirty page data to be stored and the first time duration includes: The ratio of the size of the memory dirty page data to be stored to the first time length is calculated to determine the memory dirty page rate.

10. A server, characterized in that: The server includes: a memory and a processor; The memory is used to store relevant program codes; The processor is used to call the program code to execute the method for generating a virtual machine snapshot according to any one of claims 1 to 9.