WO2021174698A1 - 虚拟机快照创建方法、装置、存储介质及计算机设备 - Google Patents

虚拟机快照创建方法、装置、存储介质及计算机设备 Download PDF

Info

Publication number
WO2021174698A1
WO2021174698A1 PCT/CN2020/093384 CN2020093384W WO2021174698A1 WO 2021174698 A1 WO2021174698 A1 WO 2021174698A1 CN 2020093384 W CN2020093384 W CN 2020093384W WO 2021174698 A1 WO2021174698 A1 WO 2021174698A1
Authority
WO
WIPO (PCT)
Prior art keywords
virtual machine
data
copy
dirty
snapshot
Prior art date
Application number
PCT/CN2020/093384
Other languages
English (en)
French (fr)
Inventor
刘仁仕
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2021174698A1 publication Critical patent/WO2021174698A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45562Creating, deleting, cloning virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/4557Distribution of virtual machine instances; Migration and load balancing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45575Starting, stopping, suspending or resuming virtual machine instances

Definitions

  • This application relates to the field of cloud computing in the field of big data, and in particular to a method, device, storage medium, and computer equipment for creating a virtual machine snapshot.
  • the snapshot function is an indispensable part: when the system crashes or is abnormal, the virtual machine disk file system and system storage can be restored by restoring the backup snapshot data.
  • the existing virtual machine creates a virtual machine snapshot usually before saving the virtual machine device state and memory state, the virtual machine is first suspended, and the virtual machine device state data and virtual machine memory data are saved to the file and all writable virtual disks After the disk snapshot is created, restore the virtual machine to the running state.
  • the inventor realizes that during the entire process of creating a virtual machine snapshot, the virtual machine is in a suspended state, and the virtual machine system is unavailable during this period, which largely limits the use scenarios of the virtual machine snapshot.
  • the embodiments of the present application provide a method, apparatus, storage medium, and computer equipment for creating a snapshot of a virtual machine, which are used to solve the problem that the virtual machine interrupts the service time of the virtual machine during the process of creating a snapshot in the prior art.
  • the copy duration of the remaining dirty data in the memory is estimated. If the estimated copy duration of the dirty data in the current remaining memory is less than or equal to the preset time threshold, the first virtual machine is suspended, wherein, when the dirty memory data to be copied in each round of iterative copying is all copied to the transit virtual machine, it is determined that the round of iterative copying ends;
  • the transfer virtual machine After the transfer virtual machine receives the dirty memory data of the first virtual machine, it saves the dirty memory data of the first virtual machine to the memory of the corresponding operating system of the transfer virtual machine in real time In space
  • an apparatus for creating a virtual machine snapshot including:
  • the receiving module is configured to receive a command for taking a snapshot of the first virtual machine, and create a target snapshot save file according to the command;
  • the first copy module is configured to copy the dirty memory data of the first virtual machine to the transit virtual machine in a loop iteratively;
  • the first calculation module is used to predict the copy duration of the current remaining dirty memory data at the end of each iteration of copying. If the estimated copy duration of the current remaining dirty memory data is less than or equal to the preset time threshold, then The first virtual machine is suspended, wherein when the dirty memory data to be copied in each round of iterative copying is all copied to the transit virtual machine, it is determined that the round of iterative copying ends;
  • the second copy module is configured to copy the currently remaining dirty memory data to the transit virtual machine and copy the virtual disk state data of the first virtual machine to the transit virtual machine; wherein, the first virtual machine The data transmission to the transit virtual machine is realized through a local interface. After the transit virtual machine receives the dirty memory data of the first virtual machine, it saves the dirty memory data of the first virtual machine to the In the memory space of the operating system corresponding to the transit virtual machine; and
  • the copy duration of the remaining dirty data in the memory is estimated. If the estimated copy duration of the dirty data in the current remaining memory is less than or equal to the preset time threshold, the first virtual machine is suspended, wherein, when the dirty memory data to be copied in each round of iterative copying is all copied to the transit virtual machine, it is determined that the round of iterative copying ends;
  • the transfer virtual machine After the transfer virtual machine receives the dirty memory data of the first virtual machine, it saves the dirty memory data of the first virtual machine to the memory of the corresponding operating system of the transfer virtual machine in real time In space
  • an embodiment of the present application provides a computer device, including:
  • One or more processors are One or more processors;
  • One or more computer programs wherein the one or more computer programs are stored in the memory and configured to be executed by the one or more processors, and the one or more computer programs are configured to execute A method for creating a snapshot of a virtual machine, wherein the method for creating a snapshot of a virtual machine includes:
  • the copy duration of the remaining dirty data in the memory is estimated. If the estimated copy duration of the dirty data in the current remaining memory is less than or equal to the preset time threshold, the first virtual machine is suspended, wherein, when the dirty memory data to be copied in each round of iterative copying is all copied to the transit virtual machine, it is determined that the round of iterative copying ends;
  • the transfer virtual machine After the transfer virtual machine receives the dirty memory data of the first virtual machine, it saves the dirty memory data of the first virtual machine to the memory of the corresponding operating system of the transfer virtual machine in real time In space
  • the virtual machine copy method provided by the embodiments of the present application adopts an iterative copy method when copying a virtual machine, using the feature of real-time perception of new dirty memory data during online copying of a virtual machine, and creating and saving a virtual machine snapshot
  • the new dirty memory data is saved in real time during the memory status, and the virtual machine is not suspended until the dirty memory data can be saved in a short period of time. Therefore, it solves the problem that the virtual machine interrupts the virtual machine in the process of creating a snapshot in the prior art.
  • the problem of long machine service time increases the usage scenarios of virtual machine snapshots.
  • the embodiment of the present application provides for setting a transit virtual machine, and the dirty memory data received by the transit virtual machine is loaded into the memory space of the operating system of the physical machine, and then sent to the target snapshot save file. Since the data migration from the first virtual machine to the transit virtual machine can perform memory operations through the local interface, the pause phase of the first virtual machine can be reached faster, and the virtual machine snapshot operation can also be successfully completed with a higher probability.
  • the transit virtual machine can load data into the memory address space of the corresponding physical machine operating system in real time, the same memory area is modified multiple times during the copy process. The transit virtual machine must finally present the final data. Since the transit virtual machine is only used as a transit and will not run, the amount of data finally saved to the target snapshot save file is smaller than the current solution, so the storage space for the target snapshot save file can be greatly reduced. use.
  • FIG. 1 is a flowchart of a method for creating a virtual machine snapshot provided by an embodiment of the application
  • FIG. 2 is a schematic block diagram of an apparatus for creating a virtual machine snapshot provided by an embodiment of the application
  • Fig. 3 is a schematic block diagram of a computer device provided by an embodiment of the application.
  • the virtual machine before saving the virtual machine device state and memory state, the virtual machine is first suspended. After the virtual machine device state and the virtual machine memory state are saved to the file, all the virtual machine states that can be written are saved. After the disk snapshot is completed, the virtual machine is restored to the running state. In this way, during the entire process of creating a virtual machine snapshot, the virtual machine is in a paused state, and the virtual machine system is unavailable during this period, which largely limits the usage scenarios of the virtual machine snapshot.
  • the virtual machine snapshot creation method provided by the embodiments of the present application adopts an iterative copy method during virtual machine copying, and utilizes the feature of real-time perception of new dirty memory data during virtual machine online copying, and creates and saves virtual machine snapshots.
  • the new dirty memory data is saved in real time, and the virtual machine is not suspended until the dirty memory data can be saved in a short period of time. Therefore, it solves the interruption of the virtual machine in the process of creating a snapshot in the prior art.
  • the problem of long virtual machine service time increases the usage scenarios of virtual machine snapshots.
  • handheld devices or portable devices include, but are not limited to, other portable devices such as mobile phones, laptop computers, or tablet computers with touch-sensitive surfaces (for example, touch screen displays and/or touch pads).
  • Methods for creating virtual machine snapshots include:
  • Step S02 Copy the dirty memory data of the first virtual machine to the transit virtual machine in a loop iteration.
  • Step S03 At the end of each round of iterative copying, the current remaining memory dirty data copy duration is estimated. If the current remaining memory dirty data copy duration is less than or equal to the preset time threshold, the virtual machine is suspended, where When all the dirty memory data to be copied in each round of iterative copying are copied to the transit virtual machine, it is determined that the round of iterative copying ends.
  • Step S04 Copy the currently remaining dirty memory data to the transit virtual machine and copy the virtual disk state data of the first virtual machine to the transit virtual machine; wherein the data transmission from the first virtual machine to the transit virtual machine is realized through a local interface, After the transfer virtual machine receives the dirty memory data of the first virtual machine, it saves the dirty memory data of the first virtual machine in the memory space of the operating system corresponding to the transfer virtual machine in real time.
  • Step S05 Save the dirty memory data and virtual disk state data of the first virtual machine saved in the transit virtual machine to the target snapshot save file.
  • the virtual machine copy method provided by the embodiments of the present application adopts an iterative copy method when copying a virtual machine, using the feature of real-time perception of new dirty memory data during online copying of a virtual machine, and creating and saving a virtual machine snapshot
  • the new dirty memory data is saved in real time during the memory status, and the virtual machine is not suspended until the dirty memory data can be saved in a short period of time. Therefore, it solves the problem that the virtual machine interrupts the virtual machine in the process of creating a snapshot in the prior art.
  • the problem of long machine service time increases the usage scenarios of virtual machine snapshots.
  • the embodiment of the present application provides for setting a transit virtual machine, and the dirty memory data received by the transit virtual machine is loaded into the memory space of the operating system of the physical machine, and then sent to the target snapshot save file. Since the data transmission from the first virtual machine to the transit virtual machine can perform memory operations through the local interface, the pause phase of the first virtual machine can be reached faster, and the virtual machine snapshot operation can be successfully completed with a higher probability.
  • the transit virtual machine can load data into the memory address space of the corresponding physical machine operating system in real time, the same memory area is modified multiple times during the copy process. The transit virtual machine must finally present the final data. Since the transit virtual machine is only used as a transit and will not run, the amount of data finally saved to the target snapshot save file is smaller than the current solution, so the storage space for the target snapshot save file can be greatly reduced. use.
  • step S01 receiving a command to take a snapshot of the first virtual machine, and creating a target snapshot save file according to the command.
  • the command to take a snapshot of the first virtual machine can be issued by the relevant operator, or it can be issued autonomously by the virtual machine snapshot creation device according to a certain strategy.
  • the command includes the identification of the first virtual machine and the need to create it.
  • the ID of the snapshot is the name of the snapshot.
  • the parameter validity check is performed on the command to determine whether the first virtual machine corresponding to the command supports the creation of internal snapshots; specifically, the parameter validity check is performed on the command, include:
  • Step S011 Query whether the first virtual machine identifier corresponding to the command and the snapshot identifier exist according to the first virtual machine identifier and the snapshot identifier to be created;
  • Step S013 Determine a file path for saving dirty memory data and virtual disk status data of the first virtual machine based on the snapshot name, and create a target snapshot save file based on the file path.
  • the first virtual machine identifier corresponding to the command does not exist or the snapshot identifier exists, it is determined that the first virtual machine does not support the creation of internal snapshots, and an error message is sent to the user.
  • the virtual machine identifier can be UUID (Universally Unique Identifier (Universal Unique Identifier), as long as it can uniquely identify a virtual machine in the current physical host
  • the target save file can be a local file, a network file, or a shared block device, such as rbd, iscsi block device, etc.
  • the first virtual machine Since the first virtual machine does not pause but continues to run during the time it takes to copy the dirty data in the memory, new dirty data will be generated when the memory of the first virtual machine has a write operation. Therefore, the newly generated dirty memory data will be copied to the transit virtual machine in the next round of iterative copying process, until it is determined that the current remaining dirty memory data can be saved in a short period of time. The virtual machine is paused. At this time, the first virtual machine will no longer generate new dirty memory data. After the first virtual machine is paused, after the first virtual machine copies the current remaining dirty memory data to the transit virtual machine, you can jump out of iteration .
  • the initialization process includes marking the memory page storing the memory data of the first virtual machine as a dirty page, where the memory data corresponding to the dirty page is the dirty memory data, specifically: Initialize the memory dirty page bitmap, set the dirty bits represented by all the memory pages corresponding to the first virtual machine in the memory dirty bitmap to true, and set the record memory dirty page flag as true.
  • step S03 at the end of each iteration of copying, the copy duration of the current remaining dirty memory data is estimated. If the estimated copy duration of the current remaining dirty memory data is less than or equal to the preset time threshold, the first virtual machine Pause, in which, when the dirty memory data to be copied in each round of iterative copying is all copied to the transit virtual machine, it is determined that the round of iterative copying ends;
  • the current remaining memory dirty data copy duration includes:
  • Step S021 Calculate the copy rate of each round of iterative copying according to the data amount of the dirty memory data copied in each round of iterative copying and the duration of each round of iterative copying;
  • C(i) M(i)/t(i), where C(i) is the copy rate of dirty memory data during the i-th iterative copy, and M(i) is the memory dirty data during the i-th iterative copy
  • the amount of data, t(i) is the copy duration of the i-th iterative copy.
  • Step S022 Determine the data amount of the current remaining dirty memory data, where the current remaining dirty memory data is the newly generated dirty memory data during each iteration of copying;
  • Step S023 Estimate the current remaining dirty memory data copy duration based on the data amount of the newly generated memory dirty data in each round of iterative copying and the copy rate of each round of iterative copying.
  • t(i+1) S(i+1)/C(i), where t(i+1) is the copy duration of the i+1th round of iterative copying, and S(i+1) is the i+1th round
  • the amount of dirty data in memory during iterative copying that is, the amount of dirty data in memory remaining after the i-th iterative copy (that is, the amount of memory data newly generated by the i-th iterative copy);
  • C(i) It is the copy rate of dirty data in the memory during the i-th iterative copy.
  • the internal CPU Central Processing Unit / Processor, central processing unit
  • the rate is higher, and the current rate of copying dirty memory data is slow, that is, when the copy rate of dirty memory data is low, the iterative copy process of the first virtual machine will be difficult to pause, and iterative migration will continue to be difficult to end.
  • the virtual machine when the virtual machine generates dirty memory data at a high rate (such as greater than 2GB/s), and the copy rate of dirty memory data is low (such as less than 1GB/s), the first virtual machine is always in the process of iterative copying. , It is difficult to stop or difficult to stop in a short time.
  • the virtual machine snapshot creation also includes:
  • Step S050 If at the end of each round of iterative copying, it is estimated that the copy duration of the remaining dirty memory data is greater than the preset time threshold, then according to the amount of newly generated memory dirty data in each round of iterative copying and the amount of data used in each round of iterative copying Calculate the generation rate of new dirty memory data in each round of iterative copying;
  • O(i) is the new dirty memory data in the i-th iterative copy
  • the generation rate of, L(i) is the data volume of the newly generated memory data in the i-th iterative copy (that is, the amount of dirty memory data remaining after the i-th iterative copy)
  • t(i) is the i-th iteration
  • the copy duration of the copy is:
  • Step S060 Determine the sleep time ratio of the first virtual machine in the next round of iterative copying according to the ratio between the generation rate of new dirty memory data in each round of iterative copying and the copy rate of each round of iterative copying, and according to the sleep time ratio
  • the first virtual machine is controlled to sleep, and the sleep time ratio is the ratio of the sleep time within a preset period of time.
  • the ratio between the generation rate of new dirty memory data and the copy rate and the corresponding relationship between the sleep time ratio can be preset. Normally, the ratio between the generation rate of new dirty memory data and the copy rate is higher. Higher, the higher the proportion of sleep time. Of course, you can also set a threshold (such as 0.8 or other values less than 1).
  • the sleep time ratio is the ratio of sleep time within a preset duration.
  • the preset duration is usually in milliseconds. For example, assuming that the preset duration is 100ms, when the sleep time ratio is 0.3, it means that the first virtual machine sleeps for 30ms in each preset duration of 100ms.
  • the embodiment of the present application calculates the generation rate of new dirty memory data in each round of iterative copying by calculating the data amount of the newly generated dirty memory data in each round of iterative copying and the time spent in each round of iterative copying after each round of iterative copying is completed. , And then calculate the generation rate of new dirty memory data in each iteration copy according to the amount of newly generated dirty memory data in each iteration copy and the duration of each iteration copy.
  • the ratio between the generation rate and the copy rate of each iteration copy determines the sleep time ratio of the first virtual machine in the next iteration copy, so that the virtual machine determines the sleep time according to the sleep time ratio, and then sleeps according to the sleep time.
  • the first virtual machine when the first virtual machine is under different service loads, by controlling the first virtual machine to sleep according to a determined sleep time, the current generation rate of the dirty memory data and the dirty memory data of the first virtual machine can be changed.
  • the ratio of the copy rate is controlled within a reasonable range, which avoids the problem that the iterative copy process is difficult to end. At the same time, it can also prevent the business from being interrupted for a long time due to a longer sleep time, which is flexible and more practical.
  • step S04 Copy the currently remaining dirty memory data to the transit virtual machine and copy the virtual disk state data of the first virtual machine to the transit virtual machine; wherein the data transmission from the first virtual machine to the transit virtual machine is realized through a local interface
  • the transfer virtual machine After the transfer virtual machine receives the dirty memory data of the first virtual machine, it saves the dirty memory data of the first virtual machine in the memory space of the operating system corresponding to the transfer virtual machine in real time, where the transfer virtual machine and the first virtual machine Located in the same physical host;
  • the steps of copying the currently remaining dirty memory data to the transit virtual machine and the steps of copying the virtual disk state data of the first virtual machine to the transit virtual machine may be performed simultaneously or sequentially. If it is performed sequentially, the embodiment of the present application does not limit the sequence.
  • the transfer virtual machine After the transfer virtual machine receives the dirty memory data of the first virtual machine, it saves the dirty memory data of the first virtual machine in the memory space of the operating system corresponding to the transfer virtual machine in real time. At the same time, the transfer virtual machine receives the first virtual machine. After the virtual disk status data of a virtual machine, the virtual disk status data of the first virtual machine will also be saved in the virtual disk device status cache space corresponding to the transit virtual machine in real time.
  • copying the virtual disk state data of the first virtual machine to the transit virtual machine includes:
  • Step S041 Determine whether the virtual disk of the first virtual machine still has an IO event being processed
  • Step S042 if not, block the newly generated IO events of the virtual disk of the first virtual machine, and insert the newly generated IO events of the virtual disk during the blocking process into the blocking queue;
  • Step S043 Copy the virtual disk state data of the first virtual machine to the transit virtual machine
  • Step S044 Wake up the newly generated IO event blocked in the blocking queue to execute the newly generated IO event blocked in the blocking queue.
  • a traditional virtual machine takes a snapshot of a virtual disk, it only supports synchronization. That is, after the virtual machine receives an external command to create an internal snapshot from the monitoring interface, it will first poll whether the current virtual disk is still available. There are IO events being processed. If they exist, continue polling until the IO event operations of all currently processed virtual disks are completed; when there are no IO events being processed, the internal program of the virtual disk is created, and the virtual disk is created according to the internal program of the virtual disk. When taking a snapshot of the internal disk, it is necessary to read and write the metadata of the virtual disk to realize the backup of the data inside the virtual disk.
  • the main process of the running virtual machine cannot respond to each read/write IO request event of the external command, nor can it respond to the user's out-of-band operation on the virtual machine, such as the system of the virtual machine.
  • the IO event of the virtual disk of the first virtual machine is blocked.
  • the IO blocking flag is changed to true, and the corresponding IO blocking queue is initialized to be empty. If the virtual machine system or user out-of-band operation generates a new IO event for the virtual disk, the IO event will be blocked and saved in the IO blocking queue.
  • the IO blocking flag is reset to false, and Wake up the IO events blocked by the snapshot creation in the IO blocking queue in turn to execute the blocked IO events in the blocking queue, so as to realize the function of responding to IO events or user out-of-band operations at the same time during the creation of the virtual disk internal snapshot. Significantly improve the efficiency of the virtual machine.
  • step S05 save the dirty memory data and virtual disk state data of the first virtual machine saved in the transit virtual machine to the target snapshot save file.
  • the dirty memory data in the memory space of the operating system corresponding to the transit virtual machine is saved in the target snapshot save file
  • the virtual disk state data saved in the virtual disk device state cache space corresponding to the first virtual machine is saved in the target
  • the snapshot is saved in the file.
  • the memory dirty page identifier that has completed the migration is changed to false, the memory dirty page bitmap is released, and the first virtual machine is restored to the running state, thereby completing the snapshot creation of the first virtual machine.
  • an embodiment of the present application provides a virtual machine snapshot creation device 1, including:
  • the receiving module 11 is configured to receive a command for taking a snapshot of the first virtual machine, and create a target snapshot save file according to the command;
  • the first copy module 12 is used to copy the dirty memory data of the first virtual machine to the transit virtual machine for cyclic iterative copying;
  • the first calculation module 13 is used to estimate the copy duration of the current remaining dirty memory data at the end of each iteration of copying. If the estimated copy duration of the current remaining dirty memory data is less than or equal to the preset time threshold, then The first virtual machine pauses, wherein when the dirty memory data to be copied in each round of iterative copying is all copied to the transit virtual machine, it is determined that the round of iterative copying ends;
  • the second copy module 14 is used to copy the remaining dirty memory data to the transit virtual machine and copy the virtual disk state data of the first virtual machine to the transit virtual machine; wherein, data transmission from the first virtual machine to the transit virtual machine Through the local interface, after the transfer virtual machine receives the dirty memory data of the first virtual machine, it saves the dirty memory data of the first virtual machine in the memory space of the operating system corresponding to the transfer virtual machine in real time; and
  • the first calculation module 13 includes:
  • the second calculation unit is used for predicting the current remaining dirty memory data copy duration based on the amount of newly generated memory dirty data in each round of iterative copying and the copy rate of each round of iterative copying.
  • the virtual machine snapshot creation device 1 further includes:
  • the second calculation module is used to, if at the end of each iteration of copying, the current remaining memory dirty data copy duration is expected to be greater than the preset time threshold, according to the data volume of the newly generated memory dirty data of each iteration copy and each time The length of time for the iterative copy to calculate the generation rate of new memory dirty data in each iterative copy;
  • the first determining module is configured to determine the ratio of the sleep time of the first virtual machine in the next round of iterative copying according to the ratio between the generation rate of new dirty memory data in each round of iterative copying and the copy rate of each round of iterative copying, and
  • the first virtual machine is controlled to sleep according to the sleep time ratio, and the sleep time ratio is the ratio of the sleep time within a preset time period.
  • the second copy module 14 further includes:
  • the judging unit is used to judge whether the virtual disk of the first virtual machine still has an IO event being processed
  • the blocking unit is used to block the newly generated IO event of the virtual disk of the first virtual machine if there is no IO event being processed on the virtual disk of the first virtual machine, and insert the newly generated IO event of the virtual disk during the blocking process into Blocking queue;
  • the first copy unit is used to copy the virtual disk state data of the first virtual machine to the transit virtual machine.
  • the wake-up unit is used to wake up the newly generated IO events that are blocked in the blocking queue to execute the newly generated IO events that are blocked in the blocking queue.
  • the receiving module 11 further includes:
  • the determining unit is configured to determine that the first virtual machine supports the creation of an internal snapshot if the first virtual machine identifier corresponding to the command exists and the snapshot identifier does not exist;
  • the creation unit is used to determine a file path for saving dirty memory data and virtual disk state data of the first virtual machine based on the snapshot name, and create a target snapshot save file based on the file path.
  • the embodiment of the present application utilizes the feature of real-time perception of new dirty memory data during online migration of virtual machines, and copies the memory data of the first virtual machine to the transit virtual machine for cyclic iterative copying.
  • cyclic iterative copying Save the new dirty memory data in real-time, and pause the virtual machine until the remaining dirty memory data can be saved in a short period of time. Therefore, the virtual machine system can be minimized during the process of creating a snapshot of the virtual machine.
  • the embodiment of the present application provides for setting a transit virtual machine, and the dirty memory data received by the transit virtual machine is loaded into the memory space of the operating system of the physical machine, and then sent to the target snapshot save file. Since the data migration from the first virtual machine to the transit virtual machine can perform memory operations through the local interface, the pause phase of the first virtual machine can be reached faster, and the virtual machine snapshot operation can also be successfully completed with a higher probability.
  • the transit virtual machine can load data into the memory address space of the corresponding physical machine operating system in real time, the same memory area is modified multiple times during the copy process. The transit virtual machine must finally present the final data. Since the transit virtual machine is only used as a transit and will not run, the amount of data finally saved to the target snapshot save file is smaller than the current solution, so the storage space for the target snapshot save file can be greatly reduced. use.
  • the embodiment of the present application provides a storage medium.
  • the storage medium may be a non-volatile storage medium or a volatile storage medium.
  • the storage medium includes a stored program, where the storage medium is controlled when the program is running.
  • the device executes the virtual machine snapshot creation method in the implementation embodiment.
  • the transit virtual machine After the transit virtual machine receives the dirty memory data of the first virtual machine, it saves the dirty memory data of the first virtual machine to the transit in real time.
  • the virtual machine corresponds to the memory space of the operating system; and saves the dirty memory data and virtual disk state data of the first virtual machine saved in the transit virtual machine into the target snapshot save file.
  • the computer device 50 may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • the computer device 50 may include but is not limited to a processor 51 and a memory 52.
  • FIG. 3 is only an example of the computer device 50 and does not constitute a limitation on the computer device 50. It may include more or less components than those shown in the figure, or a combination of certain components, or different components.
  • computer equipment may also include input and output devices, network access devices, buses, and so on.
  • the so-called processor 51 may be a central processing unit (Central Processing Unit, CPU), other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请提供一种虚拟机快照创建方法、装置、存储介质及计算机设备,方法包括:接收对第一虚拟机进行快照的命令,将第一虚拟机的内存脏数据向中转虚拟机进行循环迭代拷贝;在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,如果预计的当前剩余的内存脏数据的拷贝时长小于或等于预设时间阈值,则将第一虚拟机暂停;将当前剩余的内存脏数据拷贝至中转虚拟机以及将第一虚拟机的虚拟磁盘状态数据拷贝至中转虚拟机;将中转虚拟机中保存的第一虚拟机的内存脏数据以及虚拟磁盘状态数据保存到目标快照保存文件中。上述方法可将虚拟机快照操作时虚拟机暂停的时间缩短至毫秒级,提高创建虚拟机快照时虚拟机的可用性。

Description

虚拟机快照创建方法、装置、存储介质及计算机设备
本申请要求于2020年03月04日提交中国专利局、申请号为202010141938.0,发明名称为“虚拟机快照创建方法、装置、存储介质及计算机设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及大数据领域中的云计算领域,具体涉及一种虚拟机快照创建方法、装置、存储介质及计算机设备。
背景技术
目前云计算环境中,快照功能是其不可或缺的一部分:当系统崩溃或出现异常时,可以通过恢复到所备份的快照数据来恢复虚拟机磁盘文件系统和系统存储。
现有的虚拟机创建虚拟机快照通常在保存虚拟机设备状态和内存状态前,首先会先将虚拟机暂停,待虚拟机设备状态数据和虚拟机内存数据保存到文件完成及所有可写虚拟磁盘创建磁盘快照结束后,再将虚拟机恢复为运行状态。
如此,发明人意识到,在整个创建虚拟机快照过程中,虚拟机都处于暂停状态,这期间虚拟机系统不可用,这很大程度上限制了虚拟机快照的使用场景。
技术问题
本申请实施例提供一种虚拟机快照创建方法、装置、存储介质及计算机设备,用于解决现有技术中虚拟机在创建快照的过程中断虚拟机服务时间较长的问题。
技术解决方案
第一方面,本申请实施例提供一种虚拟机快照创建方法,所述方法包括:
接收对第一虚拟机进行快照的命令,根据所述命令创建目标快照保存文件;
将所述第一虚拟机的内存脏数据向所述中转虚拟机进行循环迭代拷贝;
在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,如果预计的当前剩余的内存脏数据的拷贝时长小于或等于预设时间阈值,则将所述第一虚拟机暂停,其中,当每一轮迭代拷贝中所要拷贝的内存脏数据全部拷贝至所述中转虚拟机时则确定该轮迭代拷贝结束;
将当前剩余的内存脏数据拷贝至所述中转虚拟机以及将所述第一虚拟机的虚拟磁盘状态数据拷贝至所述中转虚拟机;其中,所述第一虚拟机到所述中转虚拟机的数据传输通过本地接口实现,所述中转虚拟机接收到所述第一虚拟机的内存脏数据后,实时将所述第一虚拟机的内存脏数据保存至所述中转虚拟机对应操作系统的内存空间内;
将所述中转虚拟机中保存的所述第一虚拟机的内存脏数据以及虚拟磁盘状态数据保存到所述目标快照保存文件中。
第二方面,本申请实施例提供了一种虚拟机快照创建装置,包括:
接收模块,用于接收对第一虚拟机进行快照的命令,根据所述命令创建目标快照保存文件;
第一拷贝模块,用于将所述第一虚拟机的内存脏数据向所述中转虚拟机进行循环迭代拷贝;
第一计算模块,用于在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,如果预计的当前剩余的内存脏数据的拷贝时长小于或等于预设时间阈值,则将所述第一虚拟机暂停,其中,当每一轮迭代拷贝中所要拷贝的内存脏数据全部拷贝至所述中转虚拟机时则确定该轮迭代拷贝结束;
第二拷贝模块,用于将当前剩余的内存脏数据拷贝至所述中转虚拟机以及将所述第一虚拟机的虚拟磁盘状态数据拷贝至所述中转虚拟机;其中,所述第一虚拟机到所述中转虚拟机的数据传输通过本地接口实现,所述中转虚拟机接收到所述第一虚拟机的内存脏数据后,实时的将所述第一虚拟机的内存脏数据保存至所述中转虚拟机对应操作系统的内存空间内;及
保存模块,用于将所述中转虚拟机中保存的所述第一虚拟机的内存脏数据以及虚拟磁盘状态数据保存到所述目标快照保存文件中。
第三方面,本申请实施例提供了一种存储介质,所述存储介质包括存储的程序,其中,在所述程序运行时控制所述存储介质所在设备执行一种虚拟机快照创建方法,其中所述虚拟机快照创建方法包括:
接收对第一虚拟机进行快照的命令,根据所述命令创建目标快照保存文件;
将所述第一虚拟机的内存脏数据向所述中转虚拟机进行循环迭代拷贝;
在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,如果预计的当前剩余的内存脏数据的拷贝时长小于或等于预设时间阈值,则将所述第一虚拟机暂停,其中,当每一轮迭代拷贝中所要拷贝的内存脏数据全部拷贝至所述中转虚拟机时则确定该轮迭代拷贝结束;
将当前剩余的内存脏数据拷贝至所述中转虚拟机以及将所述第一虚拟机的虚拟磁盘状态数据拷贝至所述中转虚拟机;其中,所述第一虚拟机到所述中转虚拟机的数据传输通过本地接口实现,所述中转虚拟机接收到所述第一虚拟机的内存脏数据后,实时将所述第一虚拟机的内存脏数据保存至所述中转虚拟机对应操作系统的内存空间内;
将所述中转虚拟机中保存的所述第一虚拟机的内存脏数据以及虚拟磁盘状态数据保存到所述目标快照保存文件中。
第四方面,本申请实施例提供了一种计算机设备,包括:
一个或多个处理器;
存储器;
一个或多个计算机程序,其中所述一个或多个计算机程序被存储在所述存储器中并被配置为由所述一个或多个处理器执行,所述一个或多个计算机程序配置用于执行一种虚拟机快照创建方法,其中所述虚拟机快照创建方法包括:
接收对第一虚拟机进行快照的命令,根据所述命令创建目标快照保存文件;
将所述第一虚拟机的内存脏数据向所述中转虚拟机进行循环迭代拷贝;
在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,如果预计的当前剩余的内存脏数据的拷贝时长小于或等于预设时间阈值,则将所述第一虚拟机暂停,其中,当每一轮迭代拷贝中所要拷贝的内存脏数据全部拷贝至所述中转虚拟机时则确定该轮迭代拷贝结束;
将当前剩余的内存脏数据拷贝至所述中转虚拟机以及将所述第一虚拟机的虚拟磁盘状态数据拷贝至所述中转虚拟机;其中,所述第一虚拟机到所述中转虚拟机的数据传输通过本地接口实现,所述中转虚拟机接收到所述第一虚拟机的内存脏数据后,实时将所述第一虚拟机的内存脏数据保存至所述中转虚拟机对应操作系统的内存空间内;
将所述中转虚拟机中保存的所述第一虚拟机的内存脏数据以及虚拟磁盘状态数据保存到所述目标快照保存文件中。
有益效果
可以理解,本申请实施例所提供的虚拟机拷贝方法进行虚拟机拷贝时采用迭代拷贝的方式,利用虚拟机在线拷贝时可实时感知新的内存脏数据的这一特点,在虚拟机快照创建保存内存状态时实时将新的内存脏数据保存下来,直到内存脏数据在一个很短暂的时间内可以保存下来时才暂停虚拟机,因此,解决了现有技术中虚拟机在创建快照的过程中断虚拟机服务时间较长的问题,增加了虚拟机快照的使用场景。同时,本申请实施例提供设置中转虚拟机,中转虚拟机接收到的内存脏数据加载到应物理机操作系统的内存空间内,然后再发送给目标快照保存文件。由于第一虚拟机到中转虚拟机的数据迁徙可以通过本地接口进行内存操作,因此能够更快地达到第一虚拟机的暂停阶段,也能够更高概率成功完成虚拟机快照操作。同时,由于中转虚拟机能够实时将数据加载到对应物理机操作系统的内存地址空间中,因此,拷贝过程中针对相同内存区域的多次修改,在中转虚拟机最终呈现的一定是最后的数据,由于中转虚拟机仅作为中转不会运行,因此,最终保存到目标快照保存文件中的数据量同目前的方案相比,数据量更小,因此可以大幅度减少对目标快照保存文件的存储空间的利用。
附图说明
图1为本申请实施例提供的一种虚拟机快照创建方法的流程图;
图2为本申请实施例提供的一种虚拟机快照创建装置的示意框图;
图3为本申请实施例提供的一种计算机设备的示意框图。
本发明的最佳实施方式
现有技术中的虚拟机快照创建方法,在保存虚拟机设备状态和内存状态前,首先会先将虚拟机暂停,待虚拟机设备状态和虚拟机内存状态保存到文件完成,及所有可写虚拟磁盘创建磁盘快照结束后,再将虚拟机恢复为运行状态。如此,整个创建虚拟机快照过程中,虚拟机都处于暂停状态,这期间虚拟机系统不可用,这很大程度上限制了虚拟机快照的使用场景。
而本申请实施例所提供的虚拟机快照创建方法,进行虚拟机拷贝时采用迭代拷贝的方式,利用虚拟机在线拷贝时可实时感知新的内存脏数据的这一特点,在虚拟机快照创建保存内存脏数据时实时将新的内存脏数据保存下来,直到内存脏数据在一个很短暂的时间内可以保存下来时才暂停虚拟机,因此,解决了现有技术中虚拟机在创建快照的过程中断虚拟机服务时间较长的问题,增加了虚拟机快照的使用场景。
请参阅附图1,本申请实施例提供一种虚拟机快照创建方法,应用于虚拟机快照创建装置,虚拟机快照创建装置可以包括但不限于个人计算机、服务器计算机、手持设备或便携式设备、平板型设备等,
其中,手持设备或便携式设备包括但不限于诸如具有触摸敏感表面(例如,触摸屏显示器和/或触摸板)的移动电话、膝上型计算机或平板计算机之类的其它便携式设备。虚拟机快照创建方法包括:
步骤S01:接收对第一虚拟机进行快照的命令,根据命令创建目标快照保存文件。
步骤S02:将第一虚拟机的内存脏数据向中转虚拟机进行循环迭代拷贝。
步骤S03:在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,如果预计的当前剩余的内存脏数据的拷贝时长小于或等于预设时间阈值,则将虚拟机暂停,其中,当每一轮迭代拷贝中所要拷贝的内存脏数据全部拷贝至中转虚拟机时则确定该轮迭代拷贝结束。
步骤S04:将当前剩余的内存脏数据拷贝至中转虚拟机以及将第一虚拟机的虚拟磁盘状态数据拷贝至中转虚拟机;其中,第一虚拟机到中转虚拟机的数据传输通过本地接口实现,中转虚拟机接收到第一虚拟机的内存脏数据后,实时的将第一虚拟机的内存脏数据保存至中转虚拟机对应操作系统的内存空间内。
步骤S05:将中转虚拟机中保存的第一虚拟机的内存脏数据以及虚拟磁盘状态数据保存到目标快照保存文件中。
可以理解,本申请实施例所提供的虚拟机拷贝方法进行虚拟机拷贝时采用迭代拷贝的方式,利用虚拟机在线拷贝时可实时感知新的内存脏数据的这一特点,在虚拟机快照创建保存内存状态时实时将新的内存脏数据保存下来,直到内存脏数据在一个很短暂的时间内可以保存下来时才暂停虚拟机,因此,解决了现有技术中虚拟机在创建快照的过程中断虚拟机服务时间较长的问题,增加了虚拟机快照的使用场景。同时,本申请实施例提供设置中转虚拟机,中转虚拟机接收到的内存脏数据加载到应物理机操作系统的内存空间内,然后再发送给目标快照保存文件。由于第一虚拟机到中转虚拟机的数据传输可以通过本地接口进行内存操作,因此能够更快地达到第一虚拟机的暂停阶段,也能够更高概率成功完成虚拟机快照操作。同时,由于中转虚拟机能够实时将数据加载到对应物理机操作系统的内存地址空间中,因此,拷贝过程中针对相同内存区域的多次修改,在中转虚拟机最终呈现的一定是最后的数据,由于中转虚拟机仅作为中转不会运行,因此,最终保存到目标快照保存文件中的数据量同目前的方案相比,数据量更小,因此可以大幅度减少对目标快照保存文件的存储空间的利用。
下面再次结合附图1对本实施例提供的虚拟机快照创建方法的具体技术方案进行详细的说明。
针对步骤S01:接收对第一虚拟机进行快照的命令,根据命令创建目标快照保存文件。
在实际应用中,对第一虚拟机进行快照的命令可以是相关操作人员下发的,也可以是虚拟机快照创建装置根据某种策略自主发出的,该命令包括第一虚拟机标识及需要创建的快照标识。
在接收到第一虚拟机进行快照的命令后,首先会对命令进行参数合法性检查以判断与该命令对应的第一虚拟机是否支持创建内部快照;具体地,对命令进行参数合法性检查,包括:
步骤S011:根据第一虚拟机标识及需要创建的快照标识查询与命令对应的第一虚拟机标识以及快照标识是否存在;
步骤S012:如果命令对应的第一虚拟机标识存在且快照标识未存在,则判定第一虚拟机支持创建内部快照;基于快照名称确定用于保存第一虚拟机的内存脏数据以及虚拟磁盘状态数据的文件路径,并基于文件路径创建目标快照保存文件。
步骤S013:基于快照名称确定用于保存第一虚拟机的内存脏数据以及虚拟磁盘状态数据的文件路径,并基于文件路径创建目标快照保存文件。
反之,如果命令对应的第一虚拟机标识不存在或快照标识存在,则判定第一虚拟机不支持创建内部快照,则向用户发送错误信息。
其中,虚拟机标识可以是UUID(Universally Unique Identifier,通用唯一识别码),只要在当前物理主机当中能唯一标识某个虚拟机均可,目标保存文件可以是本地文件,也可以是网络文件,或者是某个共享块设备,如rbd、iscsi块设备等。
针对步骤S02:将第一虚拟机的内存脏数据向中转虚拟机进行循环迭代拷贝。
在接收到对第一虚拟机进行快照的命令后,将第一虚拟机中当前所有的内存数据作为内存脏数据,进行第一轮迭代拷贝,将第一虚拟机当前的所有内存脏数据拷贝到中转虚拟机。
由于在拷贝内存脏数据所用时长中,第一虚拟机未暂停而是继续运行,因此当第一虚拟机的内存有写操作时会产生新的内存脏数据。因此,需要将新产生的内存脏数据将会在下一轮的迭代拷贝过程中拷贝到中转虚拟机,直到确定当前剩余的内存脏数据能够在一个很短暂的时间内可以保存下来时才将第一虚拟机暂停,此时,第一虚拟机不再会产生新的内存脏数据,第一虚拟机暂停后,将第一虚拟机将当前剩余的内存脏数据拷贝到中转虚拟机后,即可跳出迭代。
在进行迭代拷贝之前,需要先进行初始化,初始化的过程包括将存储有第一虚拟机的内存数据的内存页标记为脏页,其中,脏页对应的内存数据即为内存脏数据,具体为:初始化内存脏页位图,置第一虚拟机对应的所有内存页在内存脏位位图中所代表的脏位为真,置记录内存脏页标识为真。
针对步骤S03:在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,如果预计的当前剩余的内存脏数据的拷贝时长小于或等于预设时间阈值,则将第一虚拟机暂停,其中,当每一轮迭代拷贝中所要拷贝的内存脏数据全部拷贝至中转虚拟机时则确定该轮迭代拷贝结束;
具体地,在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,包括:
步骤S021:根据每轮迭代拷贝所拷贝的内存脏数据的数据量和每轮迭代拷贝所用时长计算每轮迭代拷贝的拷贝速率;
其中,计算迭代拷贝的拷贝速率所利用的公式为:
C(i)=M(i)/t(i),其中,C(i)为第i轮迭代拷贝时内存脏数据的拷贝速率,M(i)为第i轮迭代拷贝时内存脏数据的数据量,t(i)为第i轮迭代拷贝的拷贝时长。
步骤S022:确定当前剩余的内存脏数据的数据量,其中,当前剩余的内存脏数据为每轮迭代拷贝所用时长内新产生的内存脏数据;
步骤S023:根据每轮迭代拷贝所用时长内新产生的内存脏数据的数据量与每轮迭代拷贝的拷贝速率预计当前剩余的内存脏数据的拷贝时长。
其中,预计当前剩余的内存脏数据的拷贝时长所利用的公式为:
t(i+1)=S(i+1)/C(i),其中,t(i+1)为第i+1轮迭代拷贝的拷贝时长,S(i+1)为第i+1轮迭代拷贝时内存脏数据的数据量,即进行第i轮迭代拷贝后所剩余的内存脏数据的数据量(也即第i轮迭代拷贝新产生的内存数据的数据量);C(i)为第i轮迭代拷贝时内存脏数据的拷贝速率。
进一步地,在一些场景下,如果当前第一虚拟机目前虚拟机内部业务的处理比较频繁,内部CPU(Central Processing Unit / Processor,中央处理器)写内存的操作比较频繁,从而产生内存脏数据的速率较高,而当前拷贝内存脏数据的速率较慢,即内存脏数据的拷贝速率较低时,第一虚拟机的迭代拷贝过程将难以暂停,会一直进行迭代迁徙,难以结束。比如,当虚拟机产生内存脏数据的速率较大(如大于2GB/s),内存脏数据的拷贝速率较小(如小于1GB/s)时,第一虚拟机会一直处在迭代拷贝的过程中,难以停止或者难以在短时间内停止。
为了防止第一虚拟机一直处于迭代拷贝的过程而难以结束或者难以在短时间内结束的情况,本申请实施例提供了一种控制第一虚拟机进行休眠的机制,采用控制第一虚拟机休眠部分时间的方式,由于虚拟机在休眠状态时,内部CPU不工作,因此第一虚拟机在休眠时间内不会产生新的内存脏数据,可以降低第一虚拟机产生内存脏数据的速率,以达到使第一虚拟机迁移过程结束的目的。
具体地,虚拟机快照创建还包括:
步骤S050:如果在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长大于预设时间阈值,则根据每轮迭代拷贝新产生的内存脏数据的数据量和每轮迭代拷贝所用时长计算每轮迭代拷贝中新的内存脏数据的产生速率;
其中,计算新的内存脏数据的产生速率所利用的公式为:O(i)=L(i)/t(i),其中,O(i)为第i轮迭代拷贝中新的内存脏数据的产生速率,L(i)为第i轮迭代拷贝新产生的内存数据的数据量(即第i轮迭代拷贝后所剩余的内存脏数据的数据量),t(i)为第i轮迭代拷贝的拷贝时长。
步骤S060:根据每轮迭代拷贝中新的内存脏数据的产生速率与每轮迭代拷贝的拷贝速率之间的比值确定下一轮迭代拷贝时第一虚拟机的休眠时间比例,以及根据休眠时间比例控制第一虚拟机休眠,休眠时间比例为一个预设时长内休眠时间所占的比例。
具体实现中,可以预先设置新的内存脏数据的产生速率与拷贝速率之间的比值与休眠时间比例的对应关系,通常情况下,新的内存脏数据的产生速率与拷贝速率之间的比值越高,休眠时间比例越高。当然,还可以设置一个阈值(例如0.8或者其它小于1的值),当新的内存脏数据的产生速率与拷贝速率之间的比值小于或者等于该阈值时,休眠时间比例为0(第一虚拟机无需进行休眠);当新的内存脏数据的产生速率与拷贝速率之间的比值大于该阈值时,休眠时间比例逐级递增,例如按照0.1,0.2,0.3等逐级递增,其中,需要说明的是,为了防止第一虚拟机长时间难以工作,可以对与休眠时间比例设置一个上限值,例如0.6,以将新的内存脏数据的产生速率控制在合理范围内。
在实际应用中,休眠时间比例为一个预设时长内休眠时间所占的比例。预设时长通常以毫秒作为单位,例如,假设预设时长为100ms,那么当休眠时间比例为0.3时,表示在每个预设时长100ms内第一虚拟机进行休眠的时长为30ms。
可以理解,本申请实施例通过在每轮迭代拷贝完毕后,每轮迭代拷贝新产生的内存脏数据的数据量和每轮迭代拷贝所用时长计算每轮迭代拷贝中新的内存脏数据的产生速率,然后再根据每轮迭代拷贝新产生的内存脏数据的数据量和每轮迭代拷贝所用时长计算每轮迭代拷贝中新的内存脏数据的产生速率根据每轮迭代拷贝中新的内存脏数据的产生速率与每轮迭代拷贝的拷贝速率之间的比值确定下一轮迭代拷贝时第一虚拟机的休眠时间比例,使得虚拟机按休眠时间比例确定休眠时间,再根据休眠时间进行休眠。与现有技术相比,当第一虚拟机处于不同的业务负载时,通过控制第一虚拟机按照确定的休眠时间进行休眠,可以将第一虚拟机当前内存脏数据的产生速率和内存脏数据的拷贝速率的比值控制在一个合理的范围内,避免了迭代拷贝的过程难以结束的问题,同时也可以防止因休眠时间较大导致的业务较长时间的中断,灵活性强且更为实用。
针对步骤S04:将当前剩余的内存脏数据拷贝至中转虚拟机以及将第一虚拟机的虚拟磁盘状态数据拷贝至中转虚拟机;其中,第一虚拟机到中转虚拟机的数据传输通过本地接口实现,中转虚拟机接收到第一虚拟机的内存脏数据后,实时的将第一虚拟机的内存脏数据保存至中转虚拟机对应操作系统的内存空间内,其中,中转虚拟机与第一虚拟机位于同一物理主机内;
具体地,本申请实施例执行将当前剩余的内存脏数据拷贝至中转虚拟机的步骤以及将第一虚拟机的虚拟磁盘状态数据拷贝至中转虚拟机的步骤可以是同步进行,也可以分先后进行,如果是分先后进行,那么本申请实施例对先后顺序不进行限制。
具体地,中转虚拟机接收到第一虚拟机的内存脏数据后,实时的将第一虚拟机的内存脏数据保存至中转虚拟机对应操作系统的内存空间内,同时,中转虚拟机接收到第一虚拟机的虚拟磁盘状态数据后,也会实时的将第一虚拟机的虚拟磁盘状态数据保存至中转虚拟机对应虚拟磁盘设备状态缓存空间中内。
由于第一虚拟机到中转虚拟机的数据迁徙可以通过本地接口进行内存操作,因此能够更快地达到第一虚拟机的暂停阶段,也能够更高概率成功完成虚拟机快照操作。同时,由于中转虚拟机能够实时将数据加载到对应物理机操作系统的内存地址空间中,因此,拷贝过程中针对相同内存区域的多次修改,在中转虚拟机最终呈现的一定是最后的数据,由于中转虚拟机仅作为中转不会运行,因此,最终保存到目标快照保存文件中的数据量同目前的方案相比,数据量更小,因此可以大幅度减少对目标快照保存文件的存储空间的利用。
可选地,将第一虚拟机的虚拟磁盘状态数据拷贝至中转虚拟机,包括:
步骤S041:判断第一虚拟机的虚拟磁盘是否还有正在处理的IO事件;
步骤S042:如果否,阻塞第一虚拟机的虚拟磁盘新产生的IO事件,并将阻塞过程中虚拟磁盘新产生的IO事件插入至阻塞队列中;
步骤S043:将第一虚拟机的虚拟磁盘状态数据拷贝至中转虚拟机;
步骤S044:唤醒阻塞队列中被阻塞的新产生的IO事件,以执行阻塞队列中被阻塞的新产生的IO事件。
可以理解,由于传统的虚拟机对虚拟磁盘进行快照时,只支持同步的实现方式,即虚拟机在从监听接口处接收来自外部的创建内部快照的命令后,首先会轮询当前虚拟磁盘是否还有IO事件正在处理,如果存在,则继续轮询,直到当前所有正在处理的虚拟磁盘的IO事件操作完成;当没有正在处理的IO事件时,创建虚拟磁盘内部程序,根据虚拟磁盘内部程序创建虚拟磁盘内部快照时,需要读写虚拟磁盘的元数据实现对虚拟磁盘内部的数据进行备份,由于虚拟机内部快照程序处于主线程中而不是处于虚拟机协程运行时的环境中,因此,在整个虚拟磁盘内部快照的创建过程中,对于外部指令的每个读写IO的请求事件,运行的虚拟机的主进程无法响应,也无法响应用户对虚拟机的带外操作,如来自虚拟机系统对块设备的IO事情、网络设备IO事情等。而本申请实施例通过对第一虚拟机的虚拟磁盘的IO事件进行阻塞处理,在对虚拟磁盘进行快照时,将该IO阻塞标识更改为true,将对应的IO阻塞队列初始化为空。若虚拟机系统或者用户带外操作新生成针对该虚拟磁盘的IO事件时,该IO事件将被阻塞并保存到IO阻塞队列中,当内部快照完成后,将IO阻塞标识重置为false,并依次唤醒IO阻塞队列中由快照创建所阻塞的IO事件,以执行阻塞队列中被阻塞的IO事件,从而实现了在创建虚拟磁盘内部快照过程中可以同时响应IO事件或者用户带外操作的功能,显著提高了虚拟机的工作效率。
针对步骤S05:将中转虚拟机中保存的第一虚拟机的内存脏数据以及虚拟磁盘状态数据保存到目标快照保存文件中。
具体地,将中转虚拟机对应的操作系统的内存空间内的内存脏数据保存在目标快照保存文件中,将第一虚拟机对应的虚拟磁盘设备状态缓存空间中保存的虚拟磁盘状态数据保存在目标快照保存文件中。
接下来,将已完成迁徙的内存脏页标识变为false,释放内存脏页位图,以及将第一虚拟机恢复为运行状态,从而完成第一虚拟机的快照创建。
请参阅附图2,本申请实施例提供一种虚拟机快照创建装置1,包括:
接收模块11,用于接收对第一虚拟机进行快照的命令,根据命令创建目标快照保存文件;
第一拷贝模块12,用于将第一虚拟机的内存脏数据向中转虚拟机进行循环迭代拷贝;
第一计算模块13,用于在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,如果预计的当前剩余的内存脏数据的拷贝时长小于或等于预设时间阈值,则将第一虚拟机暂停,其中,当每一轮迭代拷贝中所要拷贝的内存脏数据全部拷贝至中转虚拟机时则确定该轮迭代拷贝结束;
第二拷贝模块14,用于将当前剩余的内存脏数据拷贝至中转虚拟机以及将第一虚拟机的虚拟磁盘状态数据拷贝至中转虚拟机;其中,第一虚拟机到中转虚拟机的数据传输通过本地接口实现,中转虚拟机接收到第一虚拟机的内存脏数据后,实时的将第一虚拟机的内存脏数据保存至中转虚拟机对应操作系统的内存空间内;及
保存模块15,用于将中转虚拟机中保存的第一虚拟机的内存脏数据以及虚拟磁盘状态数据保存到目标快照保存文件中。。
可选地,第一计算模块13包括:
第一计算单元,用于根据每轮迭代拷贝所拷贝的内存脏数据的数据量和每轮迭代拷贝所用时长计算每轮迭代拷贝的拷贝速率;
第一确定单元,用于确定当前剩余的内存脏数据的数据量,其中,当前剩余的内存脏数据为每轮迭代拷贝所用时长内新产生的内存脏数据;及
第二计算单元,用于根据每轮迭代拷贝所用时长内新产生的内存脏数据的数据量与每轮迭代拷贝的拷贝速率预计当前剩余的内存脏数据的拷贝时长。
可选地,虚拟机快照创建装置1还包括:
第二计算模块,用于如果在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长大于预设时间阈值时,根据每轮迭代拷贝新产生的内存脏数据的数据量和每轮迭代拷贝所用时长计算每轮迭代拷贝中新的内存脏数据的产生速率;及
第一确定模块,用于根据每轮迭代拷贝中新的内存脏数据的产生速率与每轮迭代拷贝的拷贝速率之间的比值确定下一轮迭代拷贝时第一虚拟机的休眠时间比例,以及根据休眠时间比例控制第一虚拟机休眠,休眠时间比例为一个预设时长内休眠时间所占的比例。
可选地,第二拷贝模块14还包括:
判断单元,用于判断第一虚拟机的虚拟磁盘是否还有正在处理的IO事件;
阻塞单元,用于如果第一虚拟机的虚拟磁盘没有正在处理的IO事件时,阻塞第一虚拟机的虚拟磁盘的新产生的IO事件,并将阻塞过程中虚拟磁盘新产生的IO事件插入至阻塞队列中;
第一拷贝单元,用于将第一虚拟机的虚拟磁盘状态数据拷贝至中转虚拟机;及
唤醒单元,用于唤醒阻塞队列中被阻塞的新产生的IO事件,以执行阻塞队列中被阻塞的新产生的IO事件。
可选地,接收模块11还包括:
查询单元,用于根据第一虚拟机标识及需要创建的快照标识查询与命令对应的第一虚拟机标识以及快照标识是否存在;
判定单元,用于如果命令对应的第一虚拟机标识存在且快照标识未存在时,判定第一虚拟机支持创建内部快照;及
创建单元,用于基于快照名称确定用于保存第一虚拟机的内存脏数据以及虚拟磁盘状态数据的文件路径,并基于文件路径创建目标快照保存文件。
可以理解,本申请实施例通过利用虚拟机在线迁移时可实时感知新的内存脏数据的这一特点,将第一虚拟机的内存数据向中转虚拟机进行循环迭代拷贝,在循环迭代拷贝的过程中实时将新的内存脏数据保存下来,直到剩余的内存脏数据在一个很短暂的时间内可以保存下来时才暂停虚拟机,因此,可以最大程度的减少虚拟机创建快照的过程中虚拟机系统中止运行的时间,再结合虚拟磁盘支持快照这一特征,在此时对所有虚拟磁盘打内部快照,保存虚拟磁盘状态,从而可将虚拟机进行快照操作时,第一虚拟机暂停的时间缩短至毫秒级,极大提高创建虚拟机快照时虚拟机的可用性。
同时,本申请实施例提供设置中转虚拟机,中转虚拟机接收到的内存脏数据加载到应物理机操作系统的内存空间内,然后再发送给目标快照保存文件。由于第一虚拟机到中转虚拟机的数据迁徙可以通过本地接口进行内存操作,因此能够更快地达到第一虚拟机的暂停阶段,也能够更高概率成功完成虚拟机快照操作。同时,由于中转虚拟机能够实时将数据加载到对应物理机操作系统的内存地址空间中,因此,拷贝过程中针对相同内存区域的多次修改,在中转虚拟机最终呈现的一定是最后的数据,由于中转虚拟机仅作为中转不会运行,因此,最终保存到目标快照保存文件中的数据量同目前的方案相比,数据量更小,因此可以大幅度减少对目标快照保存文件的存储空间的利用。
应该知道,为避免重复,本申请实施例中提供的虚拟机快照创建装置中的其它实现方式或者进一步的具体细节可以参考本申请中其它实施例,例如方法实施例的相应内容。
本申请实施例提供了一种存储介质,所述存储介质可以是非易失性存储介质,也可以是易失性存储介质,该存储介质包括存储的程序,其中,在程序运行时控制存储介质所在设备执行实现实施例中的虚拟机快照创建方法。
应该知道,为避免重复,本申请实施例中提供的存储介质中的其它实现方式或者进一步的具体细节可以参考本申请中其它实施例,例如方法实施例的相应内容。
请参阅附图3,本申请实施例提供了一种计算机设备,该实施例的计算机设备50包括:处理器51、存储器52以及存储在存储器52中并可在处理器51上运行的计算机程序53,该计算机程序53被处理器51执行时实现实施例中的虚拟机快照创建方法,其中所述虚拟机快照创建方法包括:接收对第一虚拟机进行快照的命令,根据所述命令创建目标快照保存文件;将所述第一虚拟机的内存脏数据向所述中转虚拟机进行循环迭代拷贝;在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,如果预计的当前剩余的内存脏数据的拷贝时长小于或等于预设时间阈值,则将所述第一虚拟机暂停,其中,当每一轮迭代拷贝中所要拷贝的内存脏数据全部拷贝至所述中转虚拟机时则确定该轮迭代拷贝结束;将当前剩余的内存脏数据拷贝至所述中转虚拟机以及将所述第一虚拟机的虚拟磁盘状态数据拷贝至所述中转虚拟机;其中,所述第一虚拟机到所述中转虚拟机的数据传输通过本地接口实现,所述中转虚拟机接收到所述第一虚拟机的内存脏数据后,实时将所述第一虚拟机的内存脏数据保存至所述中转虚拟机对应操作系统的内存空间内;将所述中转虚拟机中保存的所述第一虚拟机的内存脏数据以及虚拟磁盘状态数据保存到所述目标快照保存文件中。
计算机设备50可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。计算机设备50可包括但不仅限于处理器51、存储器52。本领域技术人员可以理解,图3仅仅是计算机设备50的示例,并不构成对计算机设备50的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如计算机设备还可以包括输入输出设备、网络接入设备、总线等。
所称处理器51可以是中央处理单元(Central Processing Unit,CPU),还可以是其它通用处理器、数字信号处理器 (Digital Signal Processor,DSP)、专用集成电路 (Application Specific Integrated Circuit,ASIC)、现场可编程门阵列 (Field-Programmable Gate Array,FPGA) 或者其它可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
存储器52可以是计算机设备50的内部存储单元,例如计算机设备50的硬盘或内存。存储器52也可以是计算机设备50的外部存储设备,例如计算机设备50上配备的插接式硬盘,智能存储卡(Smart Media Card, SMC),安全数字(Secure Digital, SD)卡,闪存卡(Flash Card)等。进一步地,存储器52还可以既包括计算机设备50的内部存储单元也包括外部存储设备。存储器52用于存储计算机程序以及计算机设备所需的其它程序和数据。存储器52还可以用于暂时地存储已经输出或者将要输出的数据。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。

Claims (20)

  1. 一种虚拟机快照创建方法,包括:
    接收对第一虚拟机进行快照的命令,根据所述命令创建目标快照保存文件;
    将所述第一虚拟机的内存脏数据向所述中转虚拟机进行循环迭代拷贝;
    在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,如果预计的当前剩余的内存脏数据的拷贝时长小于或等于预设时间阈值,则将所述第一虚拟机暂停,其中,当每一轮迭代拷贝中所要拷贝的内存脏数据全部拷贝至所述中转虚拟机时则确定该轮迭代拷贝结束;
    将当前剩余的内存脏数据拷贝至所述中转虚拟机以及将所述第一虚拟机的虚拟磁盘状态数据拷贝至所述中转虚拟机;其中,所述第一虚拟机到所述中转虚拟机的数据传输通过本地接口实现,所述中转虚拟机接收到所述第一虚拟机的内存脏数据后,实时将所述第一虚拟机的内存脏数据保存至所述中转虚拟机对应操作系统的内存空间内;
    将所述中转虚拟机中保存的所述第一虚拟机的内存脏数据以及虚拟磁盘状态数据保存到所述目标快照保存文件中。
  2. 如权利要求1所述的方法,所述接收对第一虚拟机进行快照的命令,根据所述命令创建目标快照保存文件的步骤之后还包括:
    根据第一虚拟机标识及需要创建的快照标识查询与命令对应的第一虚拟机标识以及快照标识是否存在;
    如果命令对应的第一虚拟机标识存在且快照标识未存在,则判定第一虚拟机支持创建内部快照;基于快照名称确定用于保存第一虚拟机的内存脏数据以及虚拟磁盘状态数据的文件路径,并基于文件路径创建目标快照保存文件;
    基于快照名称确定用于保存第一虚拟机的内存脏数据以及虚拟磁盘状态数据的文件路径,并基于文件路径创建目标快照保存文件。
  3. 如权利要求1所述的方法,所述在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,包括:
    根据每轮迭代拷贝所拷贝的内存脏数据的数据量和每轮迭代拷贝所用时长计算每轮迭代拷贝的拷贝速率;
    确定当前剩余的内存脏数据的数据量,其中,所述当前剩余的内存脏数据为每轮迭代拷贝所用时长内新产生的内存脏数据;
    根据每轮迭代拷贝所用时长内新产生的内存脏数据的数据量与每轮迭代拷贝的拷贝速率预计当前剩余的内存脏数据的拷贝时长。
  4. 如权利要求3所述的方法,还包括:
    如果在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长大于预设时间阈值,则根据每轮迭代拷贝新产生的内存脏数据的数据量和每轮迭代拷贝所用时长计算每轮迭代拷贝中新的内存脏数据的产生速率;
    根据每轮迭代拷贝中新的内存脏数据的产生速率与每轮迭代拷贝的拷贝速率之间的比值确定下一轮迭代拷贝时所述第一虚拟机的休眠时间比例,以及根据所述休眠时间比例控制所述第一虚拟机休眠,所述休眠时间比例为一个预设时长内休眠时间所占的比例。
  5. 如权利要求1所述的方法,所述将所述第一虚拟机的虚拟磁盘状态数据拷贝至所述中转虚拟机,包括:
    判断所述第一虚拟机的虚拟磁盘是否还有正在处理的IO事件;
    如果否,阻塞所述第一虚拟机的虚拟磁盘新产生的IO事件,并将阻塞过程中所述虚拟磁盘新产生的IO事件插入至阻塞队列中;
    将所述第一虚拟机的虚拟磁盘状态数据拷贝至所述中转虚拟机;
    唤醒所述阻塞队列中被阻塞的所述新产生的IO事件,以执行所述阻塞队列中被阻塞的所述新产生的IO事件。
  6. 如权利要求1所述的方法,所述命令包括第一虚拟机标识及需要创建的快照标识,所述根据所述命令创建目标快照保存文件,包括:
    根据所述第一虚拟机标识及需要创建的快照标识查询与所述命令对应的第一虚拟机标识以及所述快照标识是否存在;
    如果所述命令对应的第一虚拟机标识存在且所述快照标识未存在,则判定所述第一虚拟机支持创建内部快照;
    基于所述快照名称确定用于保存所述第一虚拟机的内存脏数据以及虚拟磁盘状态数据的文件路径,并基于所述文件路径创建所述目标快照保存文件。
  7. 一种虚拟机快照创建装置,包括:
    接收模块,用于接收对第一虚拟机进行快照的命令,根据所述命令创建目标快照保存文件;
    第一拷贝模块,用于将所述第一虚拟机的内存脏数据向所述中转虚拟机进行循环迭代拷贝;
    第一计算模块,用于在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,如果预计的当前剩余的内存脏数据的拷贝时长小于或等于预设时间阈值,则将所述第一虚拟机暂停,其中,当每一轮迭代拷贝中所要拷贝的内存脏数据全部拷贝至所述中转虚拟机时则确定该轮迭代拷贝结束;
    第二拷贝模块,用于将当前剩余的内存脏数据拷贝至所述中转虚拟机以及将所述第一虚拟机的虚拟磁盘状态数据拷贝至所述中转虚拟机;其中,所述第一虚拟机到所述中转虚拟机的数据传输通过本地接口实现,所述中转虚拟机接收到所述第一虚拟机的内存脏数据后,实时的将所述第一虚拟机的内存脏数据保存至所述中转虚拟机对应操作系统的内存空间内;及
    保存模块,用于将所述中转虚拟机中保存的所述第一虚拟机的内存脏数据以及虚拟磁盘状态数据保存到所述目标快照保存文件中。
  8. 如权利要求7所述的装置,所述接收模块11还包括:
    查询单元,用于根据第一虚拟机标识及需要创建的快照标识查询与命令对应的第一虚拟机标识以及快照标识是否存在;
    判定单元,用于如果命令对应的第一虚拟机标识存在且快照标识未存在时,判定第一虚拟机支持创建内部快照;及
    创建单元,用于基于快照名称确定用于保存第一虚拟机的内存脏数据以及虚拟磁盘状态数据的文件路径,并基于文件路径创建目标快照保存文件。
  9. 如权利要求7所述的装置,所述第一计算模块包括:
    第一计算单元,用于根据每轮迭代拷贝所拷贝的内存脏数据的数据量和每轮迭代拷贝所用时长计算每轮迭代拷贝的拷贝速率;
    第一确定单元,用于确定当前剩余的内存脏数据的数据量,其中,所述当前剩余的内存脏数据为每轮迭代拷贝所用时长内新产生的内存脏数据;及
    第二计算单元,用于根据每轮迭代拷贝所用时长内新产生的内存脏数据的数据量与每轮迭代拷贝的拷贝速率预计当前剩余的内存脏数据的拷贝时长。
  10. 如权利要求9所述的装置,还包括:
    第二计算模块,用于如果在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长大于预设时间阈值时,根据每轮迭代拷贝新产生的内存脏数据的数据量和每轮迭代拷贝所用时长计算每轮迭代拷贝中新的内存脏数据的产生速率;及
    第一确定模块,用于根据每轮迭代拷贝中新的内存脏数据的产生速率与每轮迭代拷贝的拷贝速率之间的比值确定下一轮迭代拷贝时所述第一虚拟机的休眠时间比例,以及根据所述休眠时间比例控制所述第一虚拟机休眠,所述休眠时间比例为一个预设时长内休眠时间所占的比例。
  11. 一种存储介质,其中,所述存储介质包括存储的程序,所述程序运行时控制所述存储介质所在设备执行一种虚拟机快照创建方法,其中所述虚拟机快照创建方法包括:
    接收对第一虚拟机进行快照的命令,根据所述命令创建目标快照保存文件;
    将所述第一虚拟机的内存脏数据向所述中转虚拟机进行循环迭代拷贝;
    在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,如果预计的当前剩余的内存脏数据的拷贝时长小于或等于预设时间阈值,则将所述第一虚拟机暂停,其中,当每一轮迭代拷贝中所要拷贝的内存脏数据全部拷贝至所述中转虚拟机时则确定该轮迭代拷贝结束;
    将当前剩余的内存脏数据拷贝至所述中转虚拟机以及将所述第一虚拟机的虚拟磁盘状态数据拷贝至所述中转虚拟机;其中,所述第一虚拟机到所述中转虚拟机的数据传输通过本地接口实现,所述中转虚拟机接收到所述第一虚拟机的内存脏数据后,实时将所述第一虚拟机的内存脏数据保存至所述中转虚拟机对应操作系统的内存空间内;
    将所述中转虚拟机中保存的所述第一虚拟机的内存脏数据以及虚拟磁盘状态数据保存到所述目标快照保存文件中。
  12. 如权利要求11所述的存储介质,所述在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,包括:
    根据每轮迭代拷贝所拷贝的内存脏数据的数据量和每轮迭代拷贝所用时长计算每轮迭代拷贝的拷贝速率;
    确定当前剩余的内存脏数据的数据量,其中,所述当前剩余的内存脏数据为每轮迭代拷贝所用时长内新产生的内存脏数据;
    根据每轮迭代拷贝所用时长内新产生的内存脏数据的数据量与每轮迭代拷贝的拷贝速率预计当前剩余的内存脏数据的拷贝时长。
  13. 如权利要求12所述的存储介质,还包括:
    如果在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长大于预设时间阈值,则根据每轮迭代拷贝新产生的内存脏数据的数据量和每轮迭代拷贝所用时长计算每轮迭代拷贝中新的内存脏数据的产生速率;
    根据每轮迭代拷贝中新的内存脏数据的产生速率与每轮迭代拷贝的拷贝速率之间的比值确定下一轮迭代拷贝时所述第一虚拟机的休眠时间比例,以及根据所述休眠时间比例控制所述第一虚拟机休眠,所述休眠时间比例为一个预设时长内休眠时间所占的比例。
  14. 如权利要求11所述的存储介质,所述将所述第一虚拟机的虚拟磁盘状态数据拷贝至所述中转虚拟机,包括:
    判断所述第一虚拟机的虚拟磁盘是否还有正在处理的IO事件;
    如果否,阻塞所述第一虚拟机的虚拟磁盘新产生的IO事件,并将阻塞过程中所述虚拟磁盘新产生的IO事件插入至阻塞队列中;
    将所述第一虚拟机的虚拟磁盘状态数据拷贝至所述中转虚拟机;
    唤醒所述阻塞队列中被阻塞的所述新产生的IO事件,以执行所述阻塞队列中被阻塞的所述新产生的IO事件。
  15. 如权利要求11所述的存储介质,所述命令包括第一虚拟机标识及需要创建的快照标识,所述根据所述命令创建目标快照保存文件,包括:
    根据所述第一虚拟机标识及需要创建的快照标识查询与所述命令对应的第一虚拟机标识以及所述快照标识是否存在;
    如果所述命令对应的第一虚拟机标识存在且所述快照标识未存在,则判定所述第一虚拟机支持创建内部快照;
    基于所述快照名称确定用于保存所述第一虚拟机的内存脏数据以及虚拟磁盘状态数据的文件路径,并基于所述文件路径创建所述目标快照保存文件。
  16. 一种计算机设备,包括:
    一个或多个处理器;
    存储器;
    一个或多个计算机程序,其中所述一个或多个计算机程序被存储在所述存储器中并被配置为由所述一个或多个处理器执行,所述一个或多个计算机程序配置用于执行一种虚拟机快照创建方法,其中所述虚拟机快照创建方法包括:
    接收对第一虚拟机进行快照的命令,根据所述命令创建目标快照保存文件;
    将所述第一虚拟机的内存脏数据向所述中转虚拟机进行循环迭代拷贝;
    在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,如果预计的当前剩余的内存脏数据的拷贝时长小于或等于预设时间阈值,则将所述第一虚拟机暂停,其中,当每一轮迭代拷贝中所要拷贝的内存脏数据全部拷贝至所述中转虚拟机时则确定该轮迭代拷贝结束;
    将当前剩余的内存脏数据拷贝至所述中转虚拟机以及将所述第一虚拟机的虚拟磁盘状态数据拷贝至所述中转虚拟机;其中,所述第一虚拟机到所述中转虚拟机的数据传输通过本地接口实现,所述中转虚拟机接收到所述第一虚拟机的内存脏数据后,实时将所述第一虚拟机的内存脏数据保存至所述中转虚拟机对应操作系统的内存空间内;
    将所述中转虚拟机中保存的所述第一虚拟机的内存脏数据以及虚拟磁盘状态数据保存到所述目标快照保存文件中。
  17. 如权利要求16所述的计算机设备,所述在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长,包括:
    根据每轮迭代拷贝所拷贝的内存脏数据的数据量和每轮迭代拷贝所用时长计算每轮迭代拷贝的拷贝速率;
    确定当前剩余的内存脏数据的数据量,其中,所述当前剩余的内存脏数据为每轮迭代拷贝所用时长内新产生的内存脏数据;
    根据每轮迭代拷贝所用时长内新产生的内存脏数据的数据量与每轮迭代拷贝的拷贝速率预计当前剩余的内存脏数据的拷贝时长。
  18. 如权利要求17所述的计算机设备,还包括:
    如果在每一轮迭代拷贝结束时,预计当前剩余的内存脏数据的拷贝时长大于预设时间阈值,则根据每轮迭代拷贝新产生的内存脏数据的数据量和每轮迭代拷贝所用时长计算每轮迭代拷贝中新的内存脏数据的产生速率;
    根据每轮迭代拷贝中新的内存脏数据的产生速率与每轮迭代拷贝的拷贝速率之间的比值确定下一轮迭代拷贝时所述第一虚拟机的休眠时间比例,以及根据所述休眠时间比例控制所述第一虚拟机休眠,所述休眠时间比例为一个预设时长内休眠时间所占的比例。
  19. 如权利要求16所述的计算机设备,所述将所述第一虚拟机的虚拟磁盘状态数据拷贝至所述中转虚拟机,包括:
    判断所述第一虚拟机的虚拟磁盘是否还有正在处理的IO事件;
    如果否,阻塞所述第一虚拟机的虚拟磁盘新产生的IO事件,并将阻塞过程中所述虚拟磁盘新产生的IO事件插入至阻塞队列中;
    将所述第一虚拟机的虚拟磁盘状态数据拷贝至所述中转虚拟机;
    唤醒所述阻塞队列中被阻塞的所述新产生的IO事件,以执行所述阻塞队列中被阻塞的所述新产生的IO事件。
  20. 如权利要求16所述的计算机设备,所述命令包括第一虚拟机标识及需要创建的快照标识,所述根据所述命令创建目标快照保存文件,包括:
    根据所述第一虚拟机标识及需要创建的快照标识查询与所述命令对应的第一虚拟机标识以及所述快照标识是否存在;
    如果所述命令对应的第一虚拟机标识存在且所述快照标识未存在,则判定所述第一虚拟机支持创建内部快照;
    基于所述快照名称确定用于保存所述第一虚拟机的内存脏数据以及虚拟磁盘状态数据的文件路径,并基于所述文件路径创建所述目标快照保存文件。
PCT/CN2020/093384 2020-03-04 2020-05-29 虚拟机快照创建方法、装置、存储介质及计算机设备 WO2021174698A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010141938.0A CN111290836A (zh) 2020-03-04 2020-03-04 虚拟机快照创建方法、装置、存储介质及计算机设备
CN202010141938.0 2020-03-04

Publications (1)

Publication Number Publication Date
WO2021174698A1 true WO2021174698A1 (zh) 2021-09-10

Family

ID=71027012

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/093384 WO2021174698A1 (zh) 2020-03-04 2020-05-29 虚拟机快照创建方法、装置、存储介质及计算机设备

Country Status (2)

Country Link
CN (1) CN111290836A (zh)
WO (1) WO2021174698A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111857966A (zh) * 2020-07-28 2020-10-30 山东海量信息技术研究院 虚拟机快照创建方法、装置及计算机可读存储介质
CN113052532B (zh) * 2021-03-24 2024-02-27 浙江大华技术股份有限公司 物料清单检测方法、装置、设备及介质
CN113268311B (zh) * 2021-05-12 2024-01-12 西安交通大学 基于用时感知的虚拟机群高效快照方法

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103577249A (zh) * 2013-11-13 2014-02-12 中国科学院计算技术研究所 虚拟机在线迁移方法与系统
CN104572248A (zh) * 2014-12-17 2015-04-29 中电科华云信息技术有限公司 虚拟机动态保存快照的方法
CN105446834A (zh) * 2015-11-30 2016-03-30 华为技术有限公司 虚拟机快照的生成方法和装置
CN108228311A (zh) * 2016-12-22 2018-06-29 中兴通讯股份有限公司 一种跨存储池迁移虚拟机的方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103577249A (zh) * 2013-11-13 2014-02-12 中国科学院计算技术研究所 虚拟机在线迁移方法与系统
CN104572248A (zh) * 2014-12-17 2015-04-29 中电科华云信息技术有限公司 虚拟机动态保存快照的方法
CN105446834A (zh) * 2015-11-30 2016-03-30 华为技术有限公司 虚拟机快照的生成方法和装置
CN108228311A (zh) * 2016-12-22 2018-06-29 中兴通讯股份有限公司 一种跨存储池迁移虚拟机的方法

Also Published As

Publication number Publication date
CN111290836A (zh) 2020-06-16

Similar Documents

Publication Publication Date Title
US11068409B2 (en) Method and system for user-space storage I/O stack with user-space flash translation layer
US10338834B1 (en) Application performance in replication environments
US10133668B2 (en) Technologies for providing cross data storage device communications
US9122503B1 (en) Systems and methods for adaptive throttling of input/output requests in a virtual environment
JP7379669B2 (ja) アプリケーション整合性ポイントインタイムをマークするためのシステム及び方法
WO2021174698A1 (zh) 虚拟机快照创建方法、装置、存储介质及计算机设备
US20150089287A1 (en) Event-triggered storage of data to non-volatile memory
US20130007488A1 (en) Power management of a storage device including multiple processing cores
US20130111103A1 (en) High-speed synchronous writes to persistent storage
US9354907B1 (en) Optimized restore of virtual machine and virtual disk data
WO2014190806A1 (en) Application backup and restore
WO2021104383A1 (zh) 数据备份的方法和装置、设备和存储介质
US11436086B2 (en) Raid storage-device-assisted deferred parity data update system
WO2019226303A1 (en) Time-based mechanism supporting flush operation
US9619336B2 (en) Managing production data
US10049116B1 (en) Precalculation of signatures for use in client-side deduplication
US20170123657A1 (en) Systems and methods for back up in scale-out storage area network
US11435955B1 (en) System and method for offloading copy processing across non-volatile memory express (NVMe) namespaces
US20140304428A1 (en) Self-detecting storage bottleneck while handling sequential i/o operations
US11157322B2 (en) Hyper-converged infrastructure (HCI) ephemeral workload/data provisioning system
US20150312165A1 (en) Temporal based collaborative mutual exclusion control of a shared resource
US20240095076A1 (en) Accelerating data processing by offloading thread computation
US10101940B1 (en) Data retrieval system and method
CN112003860B (zh) 适用于远程直接内存访问的内存管理方法、系统及介质
US11720551B1 (en) Method and system for streaming data from portable storage devices

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20922920

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20922920

Country of ref document: EP

Kind code of ref document: A1