Virtual machine creation method, apparatus and device, and computer readable storage medium
By creating multiple snapshots of the base volume and cloning them concurrently, the problem of time-consuming batch creation of virtual machines is solved, achieving efficient concurrent creation of virtual machines and improving system resource utilization efficiency.
Patent Information
- Application Number
- CN202410822465.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-24
- Publication Date
- 2025-12-26
AI Technical Summary
When creating a large number of virtual machines, using cloud disk snapshots for multiple cloning operations is time-consuming, resulting in low efficiency in batch creation of virtual machines.
By creating multiple base volume snapshots and cloning them concurrently, multiple cloned volumes are obtained, which in turn create multiple virtual machines concurrently. By utilizing multiple base volume snapshots to perform cloning operations simultaneously, the creation time is shortened.
In scenarios involving the batch creation of virtual machines, this significantly reduces the time required to create virtual machines, improves creation efficiency, and enhances the flexibility and rationality of concurrent virtual machine creation.
Smart Images

Figure CN121210018A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of virtual machines, and particularly relates to a virtual machine creation method, device, equipment and computer readable storage medium. BACKGROUND
[0002] With the continuous development of virtual machine technology, users have more and more demands for virtual machines, and often need to create virtual machines in batches when virtual machines are needed.
[0003] Generally, when the virtual machine system disk is a cloud disk, the cloud disk is created based on an image file when creating a virtual machine, and then a cloud disk snapshot is used for cloning, and the disk obtained after cloning is used as the system disk of the virtual machine to support the booting of the virtual machine.
[0004] However, since the operation of using a cloud disk snapshot for multiple cloning needs to be executed in series, when a large number of virtual machines need to be created, the time consumption is serious. SUMMARY
[0005] In order to solve the above technical problems, the present disclosure provides a virtual machine creation method, device, equipment and computer readable storage medium to save the time of batch creation of virtual machines.
[0006] In a first aspect, the embodiments of the present disclosure provide a virtual machine creation method, comprising:
[0007] creating a plurality of base volume snapshots on a base volume;
[0008] cloning according to the plurality of base volume snapshots to obtain at least one cloned volume corresponding to each base volume snapshot;
[0009] concurrently creating a plurality of virtual machines based on the plurality of cloned volumes, wherein the virtual machines correspond one-to-one to the cloned volumes.
[0010] In some embodiments, the creating a plurality of base volume snapshots on a base volume comprises:
[0011] when receiving a virtual machine creation instruction, determining the number of virtual machines to be created corresponding to the virtual machine creation instruction;
[0012] if the number of virtual machines to be created exceeds a batch creation threshold, creating a plurality of base volume snapshots on the base volume.
[0013] In some embodiments, the cloning according to the plurality of base volume snapshots to obtain at least one cloned volume corresponding to each base volume snapshot comprises:
[0014] obtaining the number of cloning tasks of each base volume snapshot;
[0015] For each of the to-be-created virtual machines, a target snapshot with the least number of cloning tasks is determined from the plurality of base volume snapshots;
[0016] Cloning is performed according to the target snapshot, to obtain a target cloned volume corresponding to the to-be-created virtual machine.
[0017] In some embodiments, the concurrently creating a plurality of virtual machines based on the plurality of cloned volumes comprises:
[0018] For each of the to-be-created virtual machines, the to-be-created virtual machine is created based on the target cloned volume corresponding to the to-be-created virtual machine.
[0019] In some embodiments, the method further comprises:
[0020] Every preset time period, the time when each base volume snapshot in the system was last cloned is obtained;
[0021] For any one base volume snapshot, if the time when the base volume snapshot was last cloned is earlier than a preset time point, the base volume snapshot and a target base volume corresponding to the base volume snapshot are recycled.
[0022] In some embodiments, before the plurality of base volume snapshots are created for the base volume, the method further comprises:
[0023] If the number of base volumes in the system does not exceed a preset base volume number threshold, and the size of the occupied space of the base volumes in the system does not exceed a preset space threshold, the base volume is created based on the image file.
[0024] In some embodiments, the creating a plurality of base volume snapshots for the base volume comprises:
[0025] A capacity expansion image base volume interface is invoked to create a plurality of base volume snapshots for the base volume.
[0026] In a second aspect, the embodiments of the present disclosure provide a virtual machine creation device, comprising:
[0027] A first creation module configured to create a plurality of base volume snapshots for a base volume;
[0028] A cloning module configured to perform cloning according to the plurality of base volume snapshots, to obtain at least one cloned volume corresponding to each base volume snapshot, respectively;
[0029] A second creation module configured to concurrently create a plurality of virtual machines based on the plurality of cloned volumes, the virtual machines corresponding to the cloned volumes one by one.
[0030] In a third aspect, the embodiments of the present disclosure provide an electronic device, comprising:
[0031] A memory;
[0032] a processor; and
[0033] a computer program;
[0034] The computer program is stored in the memory and is configured to be executed by the processor to implement the method according to the first aspect.
[0035] In a fourth aspect, the embodiments of the present disclosure provide a computer readable storage medium, which stores a computer program. The computer program is executed by a processor to implement the method according to the first aspect.
[0036] In a fifth aspect, the embodiments of the present disclosure further provide a computer program product, which includes a computer program or instructions. The computer program or instructions are executed by a processor to implement the virtual machine creation method according to the above.
[0037] The virtual machine creation method, device, equipment and computer readable storage medium provided by the embodiments of the present disclosure can obtain multiple cloned volumes by simultaneously cloning multiple base volume snapshots, and then perform concurrent creation of virtual machines based on the multiple cloned volumes, thereby greatly shortening the time required for creating virtual machines in the batch creation scenario of virtual machines. BRIEF DESCRIPTION OF DRAWINGS
[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and serve to explain the principles of the present disclosure together with the specification.
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, those skilled in the art can obtain other drawings according to these drawings without creative labor.
[0040] Figure 1 A virtual machine creation method flowchart provided by the embodiments of the present disclosure;
[0041] Figure 2 A virtual machine creation method flowchart provided by another embodiment of the present disclosure;
[0042] Figure 3 A virtual machine creation method flowchart provided by another embodiment of the present disclosure;
[0043] Figure 4 A base volume snapshot creation flowchart provided by the embodiments of the present disclosure;
[0044] Figure 5 A cloned volume creation flowchart provided by the embodiments of the present disclosure;
[0045] Figure 6 A cold snapshot recovery process schematic diagram provided by an embodiment of the present disclosure;
[0046] Figure 7 A structure schematic diagram of a virtual machine creation device provided by an embodiment of the present disclosure;
[0047] Figure 8 A structure schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0048] In order to enable a person skilled in the art to more clearly understand the above-mentioned purposes, features and advantages of the present disclosure, the solutions of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0049] In the following description, many specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present disclosure can also be implemented in other ways different from those described herein; obviously, the embodiments in the description are only some of the embodiments of the present disclosure, not all the embodiments.
[0050] An embodiment of the present disclosure provides a virtual machine creation method, which will be introduced below in combination with specific embodiments.
[0051] Figure 1 A flowchart of a virtual machine creation method provided by an embodiment of the present disclosure. The method can be applied to a terminal with a data processing function, for example, a cloud computing platform, a smart phone, a palm computer, a tablet computer, a wearable device with a display screen, a desktop computer, a notebook computer, an all-in-one machine, a smart home device, etc. It can be understood that the virtual machine creation method provided by an embodiment of the present disclosure can also be applied in other scenarios.
[0052] The virtual machine creation method shown in the above Figure 1 The virtual machine creation method shown in the above includes the following specific steps:
[0053] S101, creating multiple base volume snapshots for a base volume.
[0054] The base volume is a template or source volume containing an operating system, application programs and configuration information, which can serve as the basis for creating a new virtual machine. The base volume is created based on an image file in the system.
[0055] The snapshot is a time-point-based data copying technology, and the base volume snapshot records various data and configuration information in the base volume at a specified time point, including but not limited to the base volume operating system, application programs and configuration information.
[0056] In this step, multiple base volume snapshots are created for the base volume and saved respectively.
[0057] Specifically, a capacity expansion mirror image base volume interface is invoked to create multiple base volume snapshots for the base volume. The created base volume snapshots each have a specific prefix to facilitate acquisition when needed.
[0058] S102, cloning is performed according to the multiple base volume snapshots to obtain at least one cloned volume corresponding to each base volume snapshot.
[0059] Cloning refers to a process of creating a cloned volume according to a base volume snapshot. The data and configuration information contained in the cloned volume are the same as those recorded in the base volume snapshot. In the embodiments of the present disclosure, the data and configuration information contained in the cloned volume are the same as those in the base volume.
[0060] Specifically, the base volume snapshot includes a pointer to the data in the base volume. When cloning the snapshot, the data in the base volume is read according to the pointer to complete the creation of the cloned volume.
[0061] When a user needs to create virtual machines in batches, cloning is performed based on multiple base volume snapshots to obtain multiple cloned volumes. Each base volume snapshot can be used to clone one or more cloned volumes, and the specific number is allocated to each base volume snapshot for cloning according to the number of virtual machines that the user needs to create.
[0062] S103, multiple virtual machines are concurrently created based on the multiple cloned volumes, and the virtual machines correspond one-to-one to the cloned volumes.
[0063] Multiple base volume snapshots can be concurrently cloned to obtain multiple cloned volumes in a short period of time, and each cloned volume can be used as a system disk of a virtual machine to support the creation and startup of the virtual machine. In this way, multiple virtual machines can be created in a short period of time.
[0064] The embodiments of the present disclosure create multiple base volume snapshots from a base volume, clone according to the multiple base volume snapshots to obtain at least one cloned volume corresponding to each base volume snapshot, and concurrently create multiple virtual machines based on the multiple cloned volumes, wherein the virtual machines correspond one-to-one to the cloned volumes. Multiple cloned volumes are obtained by simultaneously cloning multiple base volume snapshots, and virtual machines are concurrently created based on the multiple cloned volumes. In the batch creation of virtual machines, the time required for creating virtual machines is greatly shortened.
[0065] Figure 2 A virtual machine creation method flowchart is provided for another embodiment of the present disclosure. As shown in FIG. 4, the method includes the following steps: Figure 2
[0066] S201, when receiving the virtual machine creation instruction, determine the number of virtual machines to be created corresponding to the virtual machine creation instruction.
[0067] The virtual machine creation instruction is a virtual machine batch start instruction issued by a user.
[0068] The virtual machine creation instruction carries the number of virtual machines to be created, that is, the number of virtual machines required to be created by the user.
[0069] S202, if the number of virtual machines to be created exceeds the batch creation threshold, create multiple base volume snapshots for the base volume.
[0070] When the number of virtual machines to be created exceeds the batch creation threshold, the demand for base volume snapshots is relatively large, and if serial cloning operations are performed based on a single base volume snapshot, a large amount of time will be consumed. At this time, multiple base snapshots are created for the base volume to support multiple cloning operations at the same time.
[0071] S203, get the number of cloning tasks of each base volume snapshot.
[0072] In the batch creation process, a single base volume snapshot will be used to clone one or more clone volumes, and a cloning task can be understood as a task of generating a clone volume.
[0073] S204, for each virtual machine to be created, determine the target snapshot with the least number of cloning tasks in the multiple base volume snapshots.
[0074] When the number of virtual machines to be created exceeds the number of base volume snapshots, a single base volume snapshot needs to undertake multiple cloning tasks, and multiple cloning tasks form a cloning queue of the base volume snapshot in sequence. The related information of multiple base volume snapshots is saved as a cache base disk list in the image file with a specific prefix.
[0075] To ensure that the cloning task is completed as soon as possible, for each virtual machine to be created, select the base volume snapshot with the least number of cloning tasks as the target snapshot in the multiple base volume snapshots, that is, the base volume snapshot with the shortest cloning queue as the target snapshot.
[0076] Specifically, all base volume snapshots in the image file are obtained according to the specific prefix, and the base volume snapshot with the least number of cloning tasks is selected as the target snapshot.
[0077] S205, clone according to the target snapshot to obtain the target clone volume corresponding to the virtual machine to be created.
[0078] For each virtual machine to be created, clone according to the target snapshot corresponding to the virtual machine to obtain the corresponding target clone volume.
[0079] It can be understood that, based on the above steps, the corresponding relationship between the base volume, the base volume snapshot, the cloned volume, and the to-be-created virtual machine is: the base volume corresponds to multiple base volume snapshots; a single base volume snapshot corresponds to one or more cloned volumes, and a single cloned volume corresponds to a to-be-created virtual machine.
[0080] S206, for each of the to-be-created virtual machine, creating the to-be-created virtual machine based on the target cloned volume corresponding to the to-be-created virtual machine.
[0081] Taking the target cloned volume as the system disk of the to-be-created virtual machine supports the to-be-created virtual machine to boot up, that is, the creation of the to-be-created virtual machine is completed.
[0082] The above steps are performed for each to-be-created virtual machine until the virtual machine creation instruction is completed.
[0083] The embodiment of the present disclosure determines the number of to-be-created virtual machines corresponding to the virtual machine creation instruction when receiving the virtual machine creation instruction; if the number of to-be-created virtual machines exceeds the batch creation threshold, multiple base volume snapshots are created for the base volume; the number of cloning tasks of each base volume snapshot is obtained; for each of the to-be-created virtual machine, the target snapshot with the least number of cloning tasks is determined from the multiple base volume snapshots; the target cloned volume corresponding to the to-be-created virtual machine is obtained according to the target snapshot; for each of the to-be-created virtual machine, the to-be-created virtual machine is created based on the target cloned volume corresponding to the to-be-created virtual machine. Only when the number of to-be-created virtual machines exceeds the batch creation threshold, multiple base volume snapshots are created, and then the concurrent creation of virtual machines is realized based on the multiple base volume snapshots, which balances the consumption of system resources by creating base snapshots and concurrent cloning behavior and the time saved by concurrent creation of virtual machines, and further improves the flexibility of the virtual machine creation method.
[0084] Meanwhile, the embodiment of the present disclosure selects the base volume snapshot with the shortest cloning queue for the to-be-created virtual machine to perform the cloning behavior of the cloned volume, which further improves the efficiency of the virtual machine creation method.
[0085] On the basis of the above embodiment, the method further comprises: every predetermined time period, obtaining the time when each base volume snapshot in the system was cloned last time; for any one base volume snapshot, if the time when the base volume snapshot was cloned last time is earlier than the predetermined time point, the base volume snapshot and the target base volume corresponding to the base volume snapshot are recycled.
[0086] Since base volume snapshots also consume system resources, cold snapshots need to be periodically reclaimed. Specifically, if a base volume snapshot was last cloned before a preset time point, it means that the base volume snapshot has not been cloned for a certain period of time, and such a base volume snapshot is defined as a "cold snapshot". The preset time point can be a variable time point, for example, determined by deducing a certain time backward from the current time.
[0087] For a base volume snapshot that needs to be reclaimed, the target base volume corresponding to that base volume snapshot, as well as the base volume snapshot corresponding to the target base volume, are also reclaimed. When a batch creation of virtual machines occurs again, the base volume is recreated based on the image file, and then the virtual machine creation method described in the above embodiments is executed.
[0088] In other embodiments, a preset basic volume number threshold and a preset space threshold can also be set. If the number of basic volumes in the system does not exceed the preset basic volume number threshold, and the space occupied by the basic volumes in the system does not exceed the preset space threshold, then a basic volume is created based on the image file.
[0089] This embodiment of the disclosure obtains the last cloned time of each basic volume snapshot in the system at preset time intervals; for any basic volume snapshot, if the last cloned time of the basic volume snapshot is earlier than the preset time point, the basic volume snapshot and the target basic volume corresponding to the basic volume snapshot are reclaimed. The basic volume snapshots that have not been cloned for a long time and the corresponding basic volumes are reclaimed periodically to avoid cold snapshots occupying system resources for a long time and improve the rationality of the virtual machine creation method.
[0090] Meanwhile, this embodiment of the disclosure sets a preset basic volume quantity threshold and a preset space threshold to prevent the basic volume from occupying too much space and ensure that the system can operate normally.
[0091] In some embodiments, the virtual machine creation method can be applied to the OpenStack cloud platform. Figure 3 The flowchart of a virtual machine creation method provided in another embodiment of this disclosure is as follows: In the OpenStack cloud platform, Nova is a service responsible for the computing part, Cinder is a service responsible for cloud disk management; Nova-api is a component in Nova responsible for accepting requests; Nova-scheduler is a component in Nova responsible for virtual machine scheduling; Nova-compute is a component in Nova responsible for virtual machine lifecycle management; and Cinder-volume is a component in Cinder responsible for cloud disk lifecycle management.
[0092] like Figure 3 As shown, the methods for creating a virtual machine include:
[0093] S301, the Nova-api receives a virtual machine creation instruction.
[0094] S302, the Nova-scheduler determines a number of virtual machines to be created corresponding to the virtual machine creation instruction.
[0095] S303, it is judged whether the number of virtual machines to be created exceeds a batch creation threshold. If yes, S304 is executed; if no, S305 is executed.
[0096] S304, the Cinder creates and manages a clone volume.
[0097] S305, a base volume is created based on an image file.
[0098] S306, a virtual machine is created based on the base volume.
[0099] Figure 4 A base volume snapshot creation process schematic diagram provided by the embodiment of the present disclosure.
[0100] S304 can be implemented by a plurality of steps as shown in Figure 4 S401, the Cinder-api and the Cinder-volume are called.
[0101] S402, it is judged whether a base volume exists. If yes, S403 is executed; if no, S406 is executed.
[0102] S403, it is judged whether the number of base volumes exceeds a preset base volume number threshold. If no, S404 is executed; if yes, S406 is executed.
[0103] Optionally, the step can further judge whether the base volume occupies space exceeding a preset space threshold.
[0104] S404, a base volume is created based on an image file.
[0105] S405, a plurality of base volume snapshots are created for the base volume.
[0106] S406, the process is ended.
[0107]
[0108] A clone volume creation process schematic diagram provided by the embodiment of the present disclosure. Figure 5 S304 further includes a plurality of steps as shown in
[0109] Figure 5 S501, the Cinder-api and the Cinder-volume are called.
[0110]
[0111] S502, determine a plurality of base volume snapshots according to a specific prefix.
[0112] S503, determine a target snapshot with the least number of cloning tasks in the plurality of base volume snapshots to perform cloning, to obtain a cloned volume.
[0113] S504, end.
[0114] Figure 6 A cold snapshot recovery process schematic diagram is provided for the embodiments of the present disclosure. As shown in the figure, the process includes a plurality of steps: Figure 6
[0115] S601, call Cinder-volume.
[0116] S602, determine a plurality of base volume snapshots according to a specific prefix.
[0117] S603, obtain the time when each base volume snapshot was last cloned.
[0118] S604, determine whether the time when each base volume snapshot was last cloned exceeds a preset threshold. If yes, perform S605; if no, perform S606.
[0119] S605, recover the base volume snapshot and the target base volume corresponding to the base volume snapshot.
[0120] S606, end.
[0121] The embodiments of the present disclosure obtain a plurality of cloned volumes by cloning a plurality of base volume snapshots at the same time, and then perform concurrent creation of virtual machines based on the plurality of cloned volumes, which greatly shortens the time required for creating virtual machines in a virtual machine batch creation scenario.
[0122] Meanwhile, the embodiments of the present disclosure perform recovery operations on base volume snapshots that have not been cloned for a long time and corresponding base volumes at regular intervals, which avoids long-term occupation of system resources by cold snapshots and improves the rationality of the virtual machine creation method.
[0123] Figure 7 A structure schematic diagram of a virtual machine creation apparatus is provided for the embodiments of the present disclosure. The virtual machine creation apparatus can be a terminal with a data processing function as described in the above embodiments, or the virtual machine creation apparatus can be a component or assembly in the terminal with a data processing function. The virtual machine creation apparatus provided by the embodiments of the present disclosure can perform the processing flow provided by the virtual machine creation method embodiments, as shown in the figure. Figure 7 As shown, the virtual machine creation apparatus 70 comprises: a first creation module 71, a cloning module 72, and a second creation module 73. The first creation module 71 is configured to create a plurality of base volume snapshots for a base volume. The cloning module 72 is configured to clone according to the plurality of base volume snapshots to obtain at least one cloned volume corresponding to each base volume snapshot. The second creation module 73 is configured to concurrently create a plurality of virtual machines based on the plurality of cloned volumes, wherein the virtual machines correspond to the cloned volumes one by one.
[0124] Optionally, the first creation module 71 comprises a first determination unit 711 and a first creation unit 712. The first determination unit 711 is configured to determine the number of virtual machines to be created corresponding to a virtual machine creation instruction when the virtual machine creation instruction is received. The first creation unit 712 is configured to create a plurality of base volume snapshots for the base volume if the number of virtual machines to be created exceeds a batch creation threshold.
[0125] Optionally, the cloning module 72 comprises a first acquisition unit 721, a second determination unit 722, and a cloning unit 723. The first acquisition unit 721 is configured to acquire the number of cloning tasks of each base volume snapshot. The second determination unit 722 is configured to determine, for each virtual machine to be created, a target snapshot with the least number of cloning tasks from the plurality of base volume snapshots. The cloning unit 723 is configured to clone according to the target snapshot to obtain a target cloned volume corresponding to the virtual machine to be created.
[0126] Optionally, the second creation module 73 is configured to create, for each virtual machine to be created, the virtual machine to be created based on the target cloned volume corresponding to the virtual machine to be created.
[0127] Optionally, the virtual machine creation apparatus 70 further comprises a recycling module 74 configured to acquire, every predetermined time period, the time when each base volume snapshot in the system was last cloned. For any base volume snapshot, if the time when the base volume snapshot was last cloned is earlier than a predetermined time point, the base volume snapshot and a target base volume corresponding to the base volume snapshot are recycled.
[0128] Optionally, the first creation module 71 is further configured to create a base volume based on an image file if the number of base volumes in the system does not exceed a predetermined base volume number threshold and the size of the occupied space of the base volumes in the system does not exceed a predetermined space threshold.
[0129] Optionally, the first creation module 71 is further configured to invoke an expansion image base volume interface to create a plurality of base volume snapshots for the base volume.
[0130] Figure 7 The virtual machine creation apparatus of the embodiment can be used to execute the technical solutions of the method embodiments, and has similar principles and technical effects, which will not be described here again.
[0131] Figure 8 A structural schematic diagram of an electronic device is provided in the embodiments of the present disclosure. The electronic device can be a terminal with a data processing function as described in the above embodiments. The electronic device provided in the embodiments of the present disclosure can execute the processing flow provided in the embodiments of the virtual machine creation method, as shown in Figure 8 The electronic device 80 includes a memory 81, a processor 82, a computer program and a communication interface 83, as shown in the figure. The computer program is stored in the memory 81 and is configured to be executed by the processor 82 to execute the virtual machine creation method as described above.
[0132] In addition, the embodiments of the present disclosure also provide a computer readable storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement the virtual machine creation method described in the above embodiments.
[0133] It should be noted that the computer readable medium of the present disclosure described above can be a computer readable signal medium or a computer readable storage medium or any combination of the above two. The computer readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or component. In the present disclosure, the computer readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer readable program code. Such a propagated data signal can take various forms, including but not limited to an electromagnetic signal, an optical signal or any suitable combination of the above. The computer readable signal medium can also be any computer readable medium other than the computer readable storage medium, which can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or component. The program code contained in the computer readable medium can be transmitted by any suitable medium, including but not limited to a wire, a cable, an RF (radio frequency) or the like, or any suitable combination of the above.
[0134] In addition, the embodiments of the present disclosure also provide a computer program product, which includes a computer program or instructions, and the computer program or instructions are executed by a processor to implement the virtual machine creation method as described above.
[0135] The above description merely provides an overview of the presently preferred embodiments and applications of the present disclosure and is not intended to limit the scope of the disclosure. Indeed, those skilled in the art will recognize that the technology described herein can be practiced with modification and alteration, and that the technology described herein can be employed with a variety of other systems and applications. Accordingly, the description is to be regarded as illustrative in nature and is not intended as limiting the scope of the claims. The following claims set forth in particular combinations the inventions claimed.
[0136] Further, although operations are depicted in a particular, chronological sequence, this should not be understood as requiring such order unless specifically specified avowed. One of ordinary skill in the art will recognize that many of the operations can be performed in a different order, modified or eliminated altogether. Also, aspects can be implemented using software, hardware or both. In one embodiment, various tasks and operations are provided through the use of software programs in a modular fashion. As such, it should be noted that any rules, procedures, steps, or the like used to describe the aspects are meant to be implemented as software programs and / or computer readable code. However, implementing software and computer readable code can involve the use of hardware such as digital
[0137] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.
[0138] The flow diagrams and the block diagrams in the drawings are illustrations of architectures, functions, and operations that might be implemented in systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flow diagrams and the block diagrams can represent a module, a procedure, or a portion of code, which comprises one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or in the reverse order, depending on the functionality involved. Also, each block in the block diagrams and / or flow diagrams, and combinations of blocks in the block diagrams and / or flow diagrams can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and
[0139] The units described in the embodiments of the present disclosure can be implemented by software or by hardware. In some cases, the names of the units do not constitute a limitation on the units themselves.
[0140] It should be noted that, in this document, the terms such as "first" and "second" are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such a process, method, article or device. Without more limitations, the element defined by the statement "includes a" does not exclude the presence of other identical elements in the process, method, article or device that includes the element.
[0141] The above description is merely one specific implementation of the present disclosure, enabling those skilled in the art to understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to these embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for creating a virtual machine, characterized in that, The method includes: Create multiple base volume snapshots for the base volume; Cloning is performed based on the multiple base volume snapshots to obtain at least one cloned volume corresponding to each base volume snapshot; Multiple virtual machines are created concurrently based on the multiple cloned volumes, and each virtual machine corresponds one-to-one with a cloned volume.
2. The method according to claim 1, characterized in that, The creation of multiple base volume snapshots for the base volume includes: When a virtual machine creation instruction is received, the number of virtual machines to be created corresponding to the virtual machine creation instruction is determined; If the number of virtual machines to be created exceeds the batch creation threshold, then multiple base volume snapshots are created for the base volume.
3. The method according to claim 2, characterized in that, The step of cloning based on the multiple base volume snapshots to obtain at least one cloned volume corresponding to each base volume snapshot includes: Obtain the number of clone tasks for each of the aforementioned base volume snapshots; For each virtual machine to be created, determine the target snapshot with the fewest clone tasks among the plurality of base volume snapshots; The target snapshot is cloned to obtain the target clone volume corresponding to the virtual machine to be created.
4. The method according to claim 3, characterized in that, The method of concurrently creating multiple virtual machines based on multiple cloned volumes includes: For each virtual machine to be created, the virtual machine is created based on the target clone volume corresponding to the virtual machine to be created.
5. The method according to claim 1, characterized in that, The method further includes: At preset time intervals, obtain the time when each basic volume snapshot in the system was last cloned; For any base volume snapshot, if the base volume snapshot was last cloned earlier than a preset time point, then the base volume snapshot and the target base volume corresponding to the base volume snapshot are reclaimed.
6. The method according to claim 1, characterized in that, Before creating multiple base volume snapshots for the base volume, the method further includes: If the number of basic volumes in the system does not exceed the preset basic volume number threshold, and the space occupied by the basic volumes in the system does not exceed the preset space threshold, then a basic volume will be created based on the image file.
7. The method according to claim 1, characterized in that, The creation of multiple base volume snapshots for the base volume includes: Call the expansion mirror base volume interface to create multiple base volume snapshots for the base volume.
8. A virtual machine creation apparatus, characterized in that, include: The first creation module is used to create multiple base volume snapshots from the base volume; The cloning module is used to clone based on the multiple base volume snapshots to obtain at least one cloned volume corresponding to each base volume snapshot. The second creation module is used to concurrently create multiple virtual machines based on multiple cloned volumes, wherein each virtual machine corresponds one-to-one with a cloned volume.
9. An electronic device, characterized in that, include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and configured to be executed by the processor to implement the method as described in any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-7.