Virtual machine deletion rollback method and device, storage medium and electronic equipment

By deleting only the front-end page and moving it to the recycling area when deleting the virtual machine, the problem of inefficient recovery in the existing technology is solved, and the deleted virtual machine is quickly restored.

CN119690575APending Publication Date: 2025-03-25BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311236396.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-22
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

In the prior art, the recovery efficiency after deleting a virtual machine is inefficient, and it is impossible to quickly restore the deleted virtual machine.

Method used

When receiving the delete instruction, only delete the front-end page of the virtual machine, rather than directly delete the virtual machine. Move the virtual machine to the recycling area and add the recycled tag. If the user wants to recover, move out of the recycling area and delete the tag, and recreate the front-end page.

Benefits of technology

The rapid recovery of deleted virtual machines is achieved, improving recovery efficiency, and users can quickly recover virtual machines without waiting for a long recovery process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119690575A_ABST
    Figure CN119690575A_ABST
Patent Text Reader

Abstract

The invention relates to a deletion rollback method and device of a virtual machine, a storage medium and electronic equipment. The method comprises the steps of deleting a front-end page of a target virtual machine under the condition that a first deletion instruction used for deleting the target virtual machine is received; the target virtual machine is moved to a recycling area, a recycled label is added to the target virtual machine, and the recycling area is used for storing the target virtual machine; under the condition that a recovery instruction used for recovering the target virtual machine is received, the target virtual machine is moved out of the recovery area, and the recovered label of the target virtual machine is deleted; and creating a front-end page for the target virtual machine. The technical problem that the recovery efficiency is low after the virtual machine is deleted is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of virtual machines, and in particular to a method, device, storage medium and electronic device for deleting and rolling back a virtual machine. Background Art

[0002] In the prior art, after a user deletes a virtual machine, if he wants to restore it, he can only recreate the same virtual machine or reinstall a virtual machine based on the system disk snapshot. If this method is adopted, the virtual machine recovery cycle is long and the efficiency is low. Summary of the invention

[0003] The present application provides a method, device, storage medium and electronic device for deleting and rolling back a virtual machine, so as to solve the technical problem of low recovery efficiency after deleting a virtual machine.

[0004] In a first aspect, the present application provides a method for deleting and rolling back a virtual machine, comprising: upon receiving a first deletion instruction for deleting a target virtual machine, deleting the front-end page of the target virtual machine; moving the target virtual machine to a recycling area and adding a recycled tag for the target virtual machine, wherein the recycling area is used to store the target virtual machine; upon receiving a recovery instruction for recovering the target virtual machine, moving the target virtual machine from the recycling area and deleting the recycled tag of the target virtual machine; and creating the front-end page for the target virtual machine.

[0005] In the second aspect, the present application provides a deletion and rollback device for a virtual machine, comprising: a first deletion module, used to delete the front-end page of the target virtual machine when a first deletion instruction for deleting the target virtual machine is received; a move-in module, used to move the target virtual machine to a recycling area and add a recycled tag for the target virtual machine, wherein the recycling area is used to store the target virtual machine; a move-out module, used to move the target virtual machine out of the recycling area and delete the recycled tag of the target virtual machine when a recovery instruction for recovering the target virtual machine is received; and a creation module, used to create the front-end page for the target virtual machine.

[0006] As an optional example, the migration module includes: a first processing unit, used to, when the target virtual machine is in a powered-on state, clear the tasks running on the target virtual machine and perform a shutdown operation on the target virtual machine, and move the target virtual machine to the recycling area after the target virtual machine is shut down; when the target virtual machine is in a powered-off state or creates an error state, move the target virtual machine to the recycling area.

[0007] As an optional example, the migration module includes: a second processing unit, used to unmount the data disk when the target virtual machine is in a power-on state or a power-off state and the data disk of the target virtual machine is a cloud hard disk, and after unmounting the data disk, move the target virtual machine to the recycling area; when the target virtual machine is in a creation error state and the data disk of the target virtual machine is a cloud hard disk, retain the data disk and move the target virtual machine to the recycling area.

[0008] As an optional example, the move-in module includes: a first adjustment unit, used to insert a recycling record in the metadata of the target virtual machine and set the value of the recycling record to a first value when the target virtual machine is moved to the recycling area for the first time, wherein the first value is used to indicate that the target virtual machine has been recycled; when the target virtual machine is not moved to the recycling area for the first time, adjusting the value of the recycling record from a second value to the first value, wherein the second value is used to indicate that the target virtual machine has been moved out of the recycling area; the move-out module includes: a second adjustment unit, used to adjust the value of the recycling record from the first value to the second value.

[0009] As an optional example, the device also includes: a second deletion module, used to delete the target virtual machine in the reclaim area after the target virtual machine is moved to the reclaim area, upon receiving a second deletion instruction to delete the target virtual machine in the reclaim area; or, after the target virtual machine is moved to the reclaim area, upon not receiving a recovery instruction for recovering the target virtual machine within a predetermined time period, delete the target virtual machine in the reclaim area.

[0010] As an optional example, the device also includes: a processing module, used to, after moving the target virtual machine to the recycle area, delete the virtual machine that was first moved to the recycle area when the available space in the recycle area is insufficient; or, when the available space in the recycle area is insufficient, perform a capacity expansion operation on the recycle area according to the virtual machine size of the target virtual machine.

[0011] As an optional example, the device also includes: a classification module, which is used to classify all virtual machines in the recycling area after moving the target virtual machine to the recycling area; when receiving a batch recovery request, determine the category of the virtual machine requested to be restored by the batch recovery request; and move all virtual machines of the corresponding type in the recycling area out of the recycling area according to the category.

[0012] In a third aspect, the present application provides an electronic device comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, wherein the memory stores a computer program, and the processor is configured to implement the deletion and rollback method of the virtual machine described in any one of the above items when executing the computer program.

[0013] In a fourth aspect, the present application further provides a computer storage medium storing computer executable instructions, wherein the computer executable instructions are used to execute the virtual machine deletion rollback method described in any one of the above items of the present application.

[0014] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application, when a user sends a deletion command to delete a virtual machine, does not directly delete the virtual machine, but deletes the front-end page of the virtual machine. From the user's perspective, the virtual machine has been deleted, but actually at the bottom layer, the virtual machine has not been deleted, but moved to the recycling area, which is used to store the virtual machine and is labeled as having been recycled. If the user wants to restore the virtual machine, the virtual machine can be moved out of the recycling area and a corresponding front-end page can be created to restore the virtual machine, thereby achieving the effect of quickly restoring the deleted virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0016] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0017] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0018] Figure 1 A flowchart of a method for deleting and rolling back a virtual machine provided in an embodiment of the present application;

[0019] Figure 2 A system interaction diagram of a method for deleting and rolling back a virtual machine provided in an embodiment of the present application;

[0020] Figure 3 A flowchart of another method for deleting and rolling back a virtual machine provided in an embodiment of the present application;

[0021] Figure 4 A flowchart of another method for deleting and rolling back a virtual machine provided in an embodiment of the present application;

[0022] Figure 5 A flowchart of another method for deleting and rolling back a virtual machine provided in an embodiment of the present application;

[0023] Figure 6 A virtual machine processing schematic diagram of a virtual machine deletion rollback method provided in an embodiment of the present application;

[0024] Figure 7 A schematic diagram of the structure of a deletion rollback device for a virtual machine provided in an embodiment of the present application;

[0025] Figure 8 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0027] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0028] In order to solve the technical problem of low recovery efficiency after deleting a virtual machine in the prior art, the present application provides a virtual machine deletion rollback method, which can achieve the effect of quickly recovering the deleted virtual machine.

[0029] Figure 1 A flowchart of a method for deleting and rolling back a virtual machine provided in an embodiment of the present application. Figure 1 As shown, the deletion rollback method of the above virtual machine includes:

[0030] S102, upon receiving a first deletion instruction for deleting a target virtual machine, deleting a front-end page of the target virtual machine;

[0031] S104, moving the target virtual machine to a recycling area and adding a recycled tag to the target virtual machine, wherein the recycling area is used to store the target virtual machine;

[0032] S106, when receiving a recovery instruction for recovering the target virtual machine, removing the target virtual machine from the recycling area and deleting a recycled tag of the target virtual machine;

[0033] S108, creating a front-end page for the target virtual machine.

[0034] Optionally, the first deletion instruction in this embodiment may be an instruction initiated by the user through the console. If the user wants to delete the target virtual machine, the first deletion instruction is initiated. The first deletion instruction is used to delete the target virtual machine. If the prior art is used, the target virtual machine is deleted. In this application, what is deleted is the front-end page of the target virtual machine. The front-end page of the target virtual machine is used to interact with the user, and the user uses the target virtual machine through the front-end page. When the front-end page is deleted, the user will feel that the target virtual machine has been deleted, but in fact the target virtual machine still exists, only the front-end page has been deleted.

[0035] The above recycling area can be a storage area dedicated to storing the target virtual machine whose front-end page has been deleted. The virtual machine stored in the recycling area will have a recycled tag added to mark the virtual machine in the recycling area. If the virtual machine is moved out of the recycling area, the recycled tag can be deleted.

[0036] After the virtual machine is stored in the recycling area, a message can be sent to the console to indicate that the target virtual machine has been stored in the recycling area. The console can send a prompt message to the user to indicate that the target virtual machine has been deleted. If the user wants to restore the target virtual machine, a restore command can be issued, and the target virtual machine in the recycling area is removed, and the recycled label is deleted, indicating that the target virtual machine has been successfully removed from the recycling area. A message can be sent to the console, and the console can send a prompt message to the user to indicate that the target virtual machine has been restored. A front-end page is created for the restored target virtual machine, and the user can control the target virtual machine through the front-end page.

[0037] like Figure 2As shown in the figure, the user initiates a deletion command through the console, and the console notifies the underlying logic to shut down the target virtual machine. The underlying logic moves the target virtual machine into the recycling area, adds a recycled mark, and returns a message to the console. The console returns a message to the user, prompting that the target virtual machine has been deleted. If the user wants to restore the target virtual machine, a restore command is initiated. The underlying logic moves the target virtual machine out of the recycling area, deletes the recycled mark, creates a front-end page for the target virtual machine, and sends a message to the console.

[0038] The method provided in the embodiment of the present application does not directly delete the virtual machine when the user sends a delete command to delete the virtual machine, but deletes the front-end page of the virtual machine. From the user's perspective, the virtual machine has been deleted, but actually at the bottom layer, the virtual machine has not been deleted, but moved to the recycling area, which is used to store the virtual machine and is labeled as having been recycled. If the user wants to restore the virtual machine, the virtual machine can be moved out of the recycling area and a corresponding front-end page can be created to restore the virtual machine, thereby achieving the effect of quickly restoring the deleted virtual machine.

[0039] As an alternative example, Figure 3 As shown in the figure, moving the target virtual machine to the reclaim area includes:

[0040] S302, when the target virtual machine is in the powered-on state, clearing the tasks running on the target virtual machine and shutting down the target virtual machine, and after the target virtual machine is shut down, moving the target virtual machine to the recycling area;

[0041] S304: When the target virtual machine is in a shutdown state or a creation error state, move the target virtual machine to a recycling area.

[0042] In this embodiment, when moving the target virtual machine into the recycling area, the state of the target virtual machine is checked. The target virtual machine may have three states: the power-on state, indicating that the target virtual machine is running, the power-off state, indicating that the target virtual machine is not running, and the creation error state, indicating that an error occurred when the target virtual machine was created. Although it is in the power-on state, it cannot provide services. If the target virtual machine is in the power-on state, the tasks running on the target virtual machine must be cleared, and then the target virtual machine is shut down. After shutting down, the target virtual machine is moved into the recycling area. If the target virtual machine is in the power-off state, no further processing is required, and the target virtual machine is directly moved into the recycling area. If the target virtual machine is in the creation error state, it can be moved directly into the recycling area without shutting down.

[0043] The target virtual machine in the creation error state is directly moved to the recycling area without shutting down, because the target virtual machine may be maintained by the operation personnel to resolve the error information. After the error information is resolved, the target virtual machine will leave the creation error state and turn to the power-on state or the power-off state.

[0044] As an alternative example, Figure 4 As shown in the figure, moving the target virtual machine to the reclaim area includes:

[0045] S402, when the target virtual machine is in a powered-on state or a powered-off state and the data disk of the target virtual machine is a cloud hard disk, unmounting the data disk, and after unmounting the data disk, moving the target virtual machine to a recycling area;

[0046] S404: When the target virtual machine is in a creation error state and the data disk of the target virtual machine is a cloud hard disk, the data disk is retained and the target virtual machine is moved to a recycling area.

[0047] Since virtual machines will mount data disks when running, the data disks may be cloud disks or local disks. If the data disk mounted on the target virtual machine is a cloud disk, you must first unmount the data disk mounted on the target virtual machine before shutting down the target virtual machine and moving it to the recycle zone, and then shut down the target virtual machine and move it to the recycle zone.

[0048] If the data disk mounted on the target virtual machine is a local disk, you can directly move the target virtual machine into the recycle zone without uninstalling the data disk. If the target virtual machine is restored and moved out of the recycle zone, you can directly mount the local data disk.

[0049] As an optional example, adding a recycled tag to the target virtual machine includes: when the target virtual machine is moved to the recycling area for the first time, inserting a recycling record in the metadata of the target virtual machine and setting the value of the recycling record to a first value, wherein the first value is used to indicate that the target virtual machine has been recycled; when the target virtual machine is not moved to the recycling area for the first time, adjusting the value of the recycling record from the second value to the first value, wherein the second value is used to indicate that the target virtual machine has been moved out of the recycling area; deleting the recycled tag of the target virtual machine includes: adjusting the value of the recycling record from the first value to the second value.

[0050] In this embodiment, when the target virtual machine is moved into or out of the recycling area, the machine can be marked with a recycled tag. The metadata of the target virtual machine can be searched. If the target virtual machine is moved into the recycling area for the first time, there is no recycled tag in the metadata. At this time, the recycled tag can be inserted into the metadata. The recycled tag includes a numerical value. The first value represents that the target virtual machine is located in the recycling area, and the second value represents that the target virtual machine is located outside the recycling area. If the target virtual machine is moved out of the recycling area, the first value is adjusted to the second value. If the target virtual machine is moved into the recycling area again, since the recycled tag has been inserted into the metadata of the target virtual machine, the second value can be directly adjusted to the first value.

[0051] As an alternative example, Figure 5As shown, after moving the target virtual machine to the recycling area, the method further includes:

[0052] S502-1, upon receiving a second deletion instruction to delete the target virtual machine in the reclaim area, deleting the target virtual machine in the reclaim area; or,

[0053] S502-2: After the target virtual machine is moved to the reclaim area, if no recovery instruction for recovering the target virtual machine is received within a predetermined period of time, the target virtual machine in the reclaim area is deleted.

[0054] In this embodiment, if the target virtual machine is to be permanently deleted, the operator can initiate a permanent deletion instruction, and the instruction will delete the target virtual machine regardless of whether the target virtual machine is located outside or inside the recycling area. If the deleted target virtual machine is to be restored, it can only be restored by recreating or reinstalling it. Alternatively, if the target virtual machine is moved into the recycling area and has not been restored for a period of time, it can be deleted. In other words, virtual machines that have not been restored for a long time in the recycling area can be deleted.

[0055] As an optional example, after moving the target virtual machine to the recycle area, the above method also includes: when the available space in the recycle area is insufficient, deleting the virtual machine that was first moved to the recycle area; or, when the available space in the recycle area is insufficient, performing a capacity expansion operation on the recycle area according to the virtual machine size of the target virtual machine.

[0056] In this embodiment, since the target virtual machine will be moved into the recycling area, and the storage space of the recycling area is limited, there will be a situation where the available space in the recycling area is insufficient. If the available space in the recycling area is insufficient, the virtual machines in the recycling area are deleted from the beginning to the end according to the time of entering the recycling area until the available space in the recycling area can be used to move the target virtual machine.

[0057] Alternatively, this embodiment may also expand the capacity of the recycling area, or open up a new recycling area.

[0058] As an optional example, after moving the target virtual machine to the recycling area, the above method also includes: classifying all virtual machines in the recycling area; when receiving a batch recovery request, determining the category of the virtual machine requested to be restored by the batch recovery request; and moving all virtual machines of the corresponding type in the recycling area out of the recycling area according to the category.

[0059] In this embodiment, the virtual machines moved into the recycling area can be classified, and the virtual machines can be divided into different groups according to the types of the virtual machines, and the types of the virtual machines in each group are the same. When restoring the virtual machines, the virtual machines can be restored in batches, and a class of virtual machines can be restored in batches through a restoration instruction.

[0060] Figure 6: This is a virtual machine processing schematic diagram of this embodiment. When the virtual machine is in the power-on state, the virtual machine is running a task. If the user initiates a deletion command, the virtual machine is put into the power-off state and marked with a recycled label. The message to the user is that the virtual machine has been deleted. In fact, the virtual machine is moved to the recycling area. When the virtual machine is shut down, if the virtual machine is running, shut down the virtual machine first. After the virtual machine is shut down, set the recycled label and send an asynchronous message to the console. Since the virtual machine is mounted with a data disk, if the data disk is a cloud hard disk, the cloud hard disk needs to be uninstalled. If the data disk is a local disk, it can be uninstalled. In addition to the power-on state, the virtual machine also has a shutdown state and a creation error state, which is represented by the code as vm_state:[ACTIVE, STOPPED, ERROR] (corresponding to the power-on state, shutdown state and creation error state). If the virtual machine is in the power-on state and has a task running, the task running the virtual machine is cleared first. The code is task_state:[None], indicating that the task has been cleared. A virtual machine in a creation error state does not need to be shut down or the data disk needs to be uninstalled, and can be maintained by operation and maintenance personnel. After the virtual machine is shut down and moved into the recycling area, an instance_metadata record is added to the virtual machine: {'recycled':1}, and a message compute.instance.recycle.end is sent to the console, indicating that the virtual machine has been moved into the recycling area. The console can prompt the user that the virtual machine has been deleted. If the virtual machine is restored, 1 is adjusted to 0 (there are two methods in this embodiment, 1 is to adjust the value of the recycled tag to indicate that the virtual machine is moved in and out of the recycling area, and 2 is to add or delete the recycled tag to indicate that the virtual machine is moved in and out of the recycling area). The virtual machine moved out of the recycling area is still in the shutdown state.

[0061] When the virtual machine is moved out of the recycling area, the state of the virtual machine is shutdown or creation error state, the code is vm_state: [STOPPED, ERROR], no task is running on the virtual machine, the code is task_state: [None], and the console is notified that the virtual machine has been restored: compute.instance.restore.end. The message notifying the console can be an asynchronous message event_type message.

[0062] If you want to completely delete a virtual machine, the underlying and console logic deletes the resources of the virtual machine.

[0063] Figure 7 A schematic diagram of the structure of a virtual machine deletion rollback device provided in an embodiment of the present application. Figure 7 As shown, the deletion rollback device of the virtual machine includes:

[0064] A first deleting module 702, configured to delete a front-end page of a target virtual machine upon receiving a first deleting instruction for deleting the target virtual machine;

[0065] A move module 704 is used to move the target virtual machine to a recycling area and add a recycled tag to the target virtual machine, wherein the recycling area is used to store the target virtual machine;

[0066] A removal module 706, configured to remove the target virtual machine from the recycling area and delete a recycled tag of the target virtual machine when receiving a recovery instruction for recovering the target virtual machine;

[0067] The creation module 708 is used to create a front-end page for the target virtual machine.

[0068] Optionally, the first deletion instruction in this embodiment may be an instruction initiated by the user through the console. If the user wants to delete the target virtual machine, the first deletion instruction is initiated. The first deletion instruction is used to delete the target virtual machine. If the prior art is used, the target virtual machine is deleted. In this application, what is deleted is the front-end page of the target virtual machine. The front-end page of the target virtual machine is used to interact with the user, and the user uses the target virtual machine through the front-end page. When the front-end page is deleted, the user will feel that the target virtual machine has been deleted, but in fact the target virtual machine still exists, only the front-end page has been deleted.

[0069] The above recycling area can be a storage area dedicated to storing the target virtual machine whose front-end page has been deleted. The virtual machine stored in the recycling area will have a recycled tag added to mark the virtual machine in the recycling area. If the virtual machine is moved out of the recycling area, the recycled tag can be deleted.

[0070] After the virtual machine is stored in the recycling area, a message can be sent to the console to indicate that the target virtual machine has been stored in the recycling area. The console can send a prompt message to the user to indicate that the target virtual machine has been deleted. If the user wants to restore the target virtual machine, a restore command can be issued, and the target virtual machine in the recycling area is removed, and the recycled label is deleted, indicating that the target virtual machine has been successfully removed from the recycling area. A message can be sent to the console, and the console can send a prompt message to the user to indicate that the target virtual machine has been restored. A front-end page is created for the restored target virtual machine, and the user can control the target virtual machine through the front-end page.

[0071] like Figure 2As shown in the figure, the user initiates a deletion command through the console, and the console notifies the underlying logic to shut down the target virtual machine. The underlying logic moves the target virtual machine into the recycling area, adds a recycled mark, and returns a message to the console. The console returns a message to the user, prompting that the target virtual machine has been deleted. If the user wants to restore the target virtual machine, a restore command is initiated. The underlying logic moves the target virtual machine out of the recycling area, deletes the recycled mark, creates a front-end page for the target virtual machine, and sends a message to the console.

[0072] The method provided in the embodiment of the present application does not directly delete the virtual machine when the user sends a delete command to delete the virtual machine, but deletes the front-end page of the virtual machine. From the user's perspective, the virtual machine has been deleted, but actually at the bottom layer, the virtual machine has not been deleted, but moved to the recycling area, which is used to store the virtual machine and is labeled as having been recycled. If the user wants to restore the virtual machine, the virtual machine can be moved out of the recycling area and a corresponding front-end page can be created to restore the virtual machine, thereby achieving the effect of quickly restoring the deleted virtual machine.

[0073] For other examples of this embodiment, please refer to the above examples and will not be described in detail here.

[0074] like Figure 8 As shown, an embodiment of the present application provides an electronic device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.

[0075] Memory 113, used for storing computer programs;

[0076] In one embodiment of the present application, the processor 111 is used to implement the virtual machine deletion rollback method provided by any one of the aforementioned method embodiments when executing the program stored in the memory 113.

[0077] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of providing a method for deleting and rolling back a virtual machine as in any of the aforementioned method embodiments are implemented.

[0078] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0079] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0080] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.

[0081] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for deleting and rolling back a virtual machine, characterized in that: include: Upon receiving a first deletion instruction for deleting the target virtual machine, deleting a front-end page of the target virtual machine; Moving the target virtual machine to a recycling area and adding a recycled tag to the target virtual machine, wherein the recycling area is used to store the target virtual machine; Upon receiving a recovery instruction for recovering the target virtual machine, removing the target virtual machine from the recovery area and deleting a recovered tag of the target virtual machine; The front-end page is created for the target virtual machine.

2. The method according to claim 1, characterized in that The moving the target virtual machine to the recycling area comprises: When the target virtual machine is in a powered-on state, clearing the tasks running on the target virtual machine and shutting down the target virtual machine, and after the target virtual machine is shut down, moving the target virtual machine to the recycling area; When the target virtual machine is in a shutdown state or a creation error state, the target virtual machine is moved to the recycling area.

3. The method according to claim 1, characterized in that The moving the target virtual machine to the recycling area comprises: When the target virtual machine is in a powered-on state or a powered-off state and the data disk of the target virtual machine is a cloud hard disk, unmounting the data disk, and after unmounting the data disk, moving the target virtual machine to the recycling area; When the target virtual machine is in a creation error state and the data disk of the target virtual machine is a cloud hard disk, the data disk is retained and the target virtual machine is moved to the recycling area.

4. The method according to claim 1, characterized in that: The adding of the recycled tag to the target virtual machine comprises: when the target virtual machine is moved to the recycling area for the first time, inserting a recycling record in the metadata of the target virtual machine and setting the value of the recycling record to a first value, wherein the first value is used to indicate that the target virtual machine has been recycled; when the target virtual machine is not moved to the recycling area for the first time, adjusting the value of the recycling record from a second value to the first value, wherein the second value is used to indicate that the target virtual machine has been moved out of the recycling area; The deleting the recycled tag of the target virtual machine includes: adjusting the value of the recycling record from the first value to the second value.

5. The method according to claim 1, characterized in that After moving the target virtual machine to the reclaim area, the method further includes: Upon receiving a second deletion instruction to delete the target virtual machine in the reclaim area, deleting the target virtual machine in the reclaim area; or, After the target virtual machine is moved to the recycling area, if no recovery instruction for recovering the target virtual machine is received within a predetermined time period, the target virtual machine in the recycling area is deleted.

6. The method according to claim 1, characterized in that After moving the target virtual machine to the reclaim area, the method further includes: In the case where the available space in the reclaim area is insufficient, deleting the virtual machine that was first moved into the reclaim area; or, When the available space in the reclaim area is insufficient, the reclaim area is expanded according to the virtual machine size of the target virtual machine.

7. The method according to claim 1, characterized in that After moving the target virtual machine to the reclaim area, the method further includes: Classifying all virtual machines in the recycling area; In case of receiving a batch recovery request, determining the category of the virtual machine to be recovered by the batch recovery request; All virtual machines of a corresponding type in the recycling area are moved out of the recycling area according to the category.

8. A deletion rollback device for a virtual machine, characterized in that: include: A first deletion module, configured to delete a front-end page of a target virtual machine upon receiving a first deletion instruction for deleting the target virtual machine; A move-in module, used to move the target virtual machine to a recycling area and add a recycled tag to the target virtual machine, wherein the recycling area is used to store the target virtual machine; a removal module, configured to remove the target virtual machine from the recycling area and delete a recycled tag of the target virtual machine upon receiving a recovery instruction for recovering the target virtual machine; A creation module is used to create the front-end page for the target virtual machine.

9. An electronic device, characterized in that: include: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor coupled to the at least one bus; At least one memory connected to the at least one bus, wherein a computer program is stored in the memory, and when the processor executes the computer program, the method described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the method described in any one of claims 1 to 7 of the present application.