CN110704161B - Virtual machine creation method and device and computer equipment - Google Patents

Virtual machine creation method and device and computer equipment Download PDF

Info

Publication number
CN110704161B
CN110704161B CN201910923750.9A CN201910923750A CN110704161B CN 110704161 B CN110704161 B CN 110704161B CN 201910923750 A CN201910923750 A CN 201910923750A CN 110704161 B CN110704161 B CN 110704161B
Authority
CN
China
Prior art keywords
virtual machine
memory
memory data
data
target
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201910923750.9A
Other languages
Chinese (zh)
Other versions
CN110704161A (en
Inventor
闻征涛
汪权
李蕾
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Lenovo Beijing Ltd
Original Assignee
Lenovo Beijing Ltd
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 Lenovo Beijing Ltd filed Critical Lenovo Beijing Ltd
Priority to CN201910923750.9A priority Critical patent/CN110704161B/en
Publication of CN110704161A publication Critical patent/CN110704161A/en
Application granted granted Critical
Publication of CN110704161B publication Critical patent/CN110704161B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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
    • 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/45583Memory management, e.g. access or allocation

Abstract

The embodiment creates a virtual machine template for reserving the running state of a source virtual machine, writes first memory data of a minimum data set for ensuring normal running of the source virtual machine into a host file system after the running of the source virtual machine is stopped, and can read the first memory data to write into a first memory of an obtained target virtual machine after the virtual machine template is instantiated, so that the target virtual machine can be enabled to be started normally to run, and a user can be connected with the target virtual machine to be normally used. Therefore, according to the embodiment, all the memory data of the source virtual machine do not need to be written into a host file system, and a disk does not need to be subjected to snapshot, so that the memory data storage time is greatly reduced, the virtual machine creation efficiency is improved, and the use requirements of users on the virtual machine can be met.

Description

Virtual machine creation method and device and computer equipment
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for creating a virtual machine, and a computer device.
Background
In computers, with the rapid development and deep application of virtualization technology, virtual machines have gradually replaced physical machines to become a support environment for the operation of key business systems of enterprises. In practical applications, for example, in an application process of a Virtual Desktop Infrastructure (VDI), a Platform-as-a-Service (Platform or Service), a software test, or in a case that a source Virtual machine used by a user is faulty or down, one or more new Virtual machines need to be created to meet the user requirements.
In contrast, currently, a Hot Snapshot (Hot Snapshot) of a virtual machine is usually adopted to compress all memory information of a source virtual machine and store the compressed memory information to a file system of a host, and when a new virtual machine is created, all memory information of the source virtual machine is recovered from the file system, which often takes a long time.
Disclosure of Invention
In view of this, the present application provides a virtual machine creating method, apparatus, and computer device, where a virtual machine template that preserves an operating state of a source virtual machine is used to perform instantiation, and a target virtual machine is created, and in this process, only a minimum data set for ensuring normal start and operation of the virtual machine needs to be saved to a file system, so that memory data saving time is shortened, virtual machine creating efficiency is improved, and occupation of space resources of the file system is reduced.
In order to achieve the above object, the present application provides the following technical solutions:
in one aspect, the present application provides a virtual machine creation method, where the method includes:
in response to a virtual machine creation request, creating a virtual machine template for reserving the running state of a source virtual machine, wherein the source virtual machine comprises a first memory and a second memory, first memory data stored in the first memory comprises a minimum data set for normal running of the source virtual machine, and the first memory data and second memory data of the second memory can jointly represent the running state of the source virtual machine;
controlling the source virtual machine to stop running, and writing the first memory data into a host machine file system;
instantiating the virtual machine template to obtain a target virtual machine;
and responding to a starting request aiming at the target virtual machine, reading the first memory data from the host machine file system, writing the first memory data into the first memory of the target virtual machine, and controlling the target virtual machine to enter a running state.
In an implementation manner of some embodiments, the creating, in response to the virtual machine creation request, a virtual machine template that preserves a running state of the source virtual machine includes:
responding to a virtual machine creation request, and obtaining running state data of a source virtual machine, wherein the running state data comprises the first memory data and the second memory data of the source virtual machine;
and creating a virtual machine template by using the running state data, wherein the configuration information of the virtual machine template comprises first memory configuration information and second memory configuration information for configuring the memory of the virtual machine.
In an implementation of some embodiments, after writing the first memory data to the host file system, the method further comprises:
deleting the configuration information of the source virtual machine except the second memory data.
In an implementation manner of some embodiments, the reading the first memory data from the host file system and writing the first memory data into the first memory of the target virtual machine in response to the start request for the target virtual machine, and controlling the target virtual machine to enter a running state includes:
triggering the target virtual machine to run in response to a starting request aiming at the target virtual machine;
and reading the first memory data from the host file system, writing the first memory data into the first memory of the target virtual machine, and controlling the target virtual machine to copy the running state of the source virtual machine when the source virtual machine stops running.
In an implementation of some embodiments, the method further comprises:
reading target memory data required by the target virtual machine from the second memory data according to a page missing loading mechanism;
and writing the target memory data into a second memory of the target virtual machine.
In some embodiments, the first memory data includes virtual machine device state information, BIOS configuration information, and memory page table information;
the second memory data includes program codes for loading kernel space and user space, stack data generated by application program operation, and data loaded from a host disk.
In an implementation of some embodiments, the method further comprises:
responding to an operation request of any application program running on the source virtual machine, and controlling the requested application program to execute corresponding operation;
generating the virtual machine creation request in response to a replication instruction or a sharing instruction for the source virtual machine.
In an implementation manner of some embodiments, the instantiating the virtual machine template to obtain the target virtual machine includes:
and repeating the instantiation of the virtual machine template for multiple times to obtain a plurality of target virtual machines, wherein the instantiation processes of the plurality of target virtual machines are mutually independent.
In another aspect, the present application further provides a virtual machine creating apparatus, including:
the virtual machine template creating module is used for responding to a virtual machine creating request and creating a virtual machine template for reserving the running state of a source virtual machine, wherein the source virtual machine comprises a first internal memory and a second internal memory, first internal memory data stored in the first internal memory comprise a minimum data set of the source virtual machine in normal running, and the first internal memory data and second internal memory data of the second internal memory can jointly represent the running state of the source virtual machine;
the first control module is used for controlling the source virtual machine to stop running and writing the first memory data into a host machine file system;
the instantiation module is used for instantiating the virtual machine template to obtain a target virtual machine;
and the virtual machine running module is used for responding to a starting request aiming at the target virtual machine, reading the first memory data from the host machine file system, writing the first memory data into the first memory of the target virtual machine, and controlling the target virtual machine to enter a running state.
In yet another aspect, the present application further provides a computer device comprising at least one memory and at least one processor, wherein:
the memory is used for storing a program for realizing the virtual machine creating method;
the processor is configured to load and execute the program stored in the memory to implement the steps of the virtual machine creation method.
Therefore, compared with the prior art, the application provides a virtual machine creating method, a virtual machine creating device and computer equipment, the application divides the memory of a source virtual machine into two parts, that is, the first memory and the second memory, in a scenario where the source virtual machine needs to be copied or shared to be used by others, the present embodiment creates the target virtual machine by using the virtual machine template, specifically creates the virtual machine template that retains the running state of the source virtual machine, and after the running of the source virtual machine is stopped, writing the first memory data of the minimum data set for ensuring the normal operation of the source virtual machine into a host machine file system, and after instantiating a virtual machine template, the first memory data can be read and written into the first memory of the obtained target virtual machine, so that the target virtual machine can be enabled to normally start and run, and a user can be enabled to connect the target virtual machine for normal use. Therefore, in the embodiment, all the memory data of the source virtual machine does not need to be written into a host file system, and a disk does not need to be subjected to snapshot.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 illustrates a flow chart of an alternative example of a virtual machine creation method as set forth herein;
FIG. 2 is a flow chart illustrating yet another alternative example of a virtual machine creation method as set forth herein;
fig. 3 is a schematic diagram illustrating a storage manner of two portions of memory data of a source virtual machine in a virtual machine creation method provided by the present application;
fig. 4 is a block diagram showing an alternative example of a virtual machine creation apparatus proposed in the present application;
fig. 5 is a block diagram showing still another alternative example of the virtual machine creation apparatus proposed in the present application;
fig. 6 shows a schematic structural diagram of a computer device proposed in the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without making any creative effort belong to the protection scope of the present application.
It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings. The embodiments and features of the embodiments in the present application may be combined with each other without conflict.
It should be understood that "system", "apparatus", "unit" and/or "module" as used herein is a method for distinguishing different components, elements, parts or assemblies at different levels. However, other words may be substituted by other expressions if they accomplish the same purpose.
As used in this application and the appended claims, the terms "a," "an," "the," and/or "the" are not intended to be inclusive in the singular, but rather are intended to be inclusive in the plural unless the context clearly dictates otherwise. In general, the terms "comprises" and "comprising" merely indicate that steps and elements are included which are explicitly identified, that the steps and elements do not form an exclusive list, and that a method or apparatus may include other steps or elements. An element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
In the description of the embodiments herein, "/" means "or" unless otherwise specified, for example, a/B may mean a or B; "and/or" herein is merely an association describing an associated object, and means that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present application, "a plurality" means two or more than two. The terms "first", "second" and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.
Additionally, flow charts are used herein to illustrate operations performed by systems or devices according to embodiments of the present application. It should be understood that the preceding or following operations are not necessarily performed in the exact order in which they are performed. Rather, the various steps may be processed in reverse order or simultaneously. Meanwhile, other operations may be added to the processes, or a certain step or several steps of operations may be removed from the processes.
The method for creating a Virtual machine by using a hot snapshot, which is described in the background art section, can meet the usage requirements of applications such as a Virtual Desktop (VDI), a software test, and a Paas (Platform or Service) on the Virtual machine, but since all memory data of the Virtual machine needs to be stored in a file system of a host, taking an 8G memory-sized Virtual machine as an example, even if the 8G memory data is compressed first, the size of the compressed file is always in the MB level, which results in that the time spent in the storage and compression processes of the memory data of the source Virtual machine is also in the minute level and the time is longer, thereby reducing the usage experience of the Virtual machine by a user.
Moreover, as described in the background art section, the hot snapshot technology not only stores the memory data, but also performs snapshot on the disk, which is often not needed for copying the scene of the virtual machine, which may cause unnecessary time consumption and reduce the virtual machine creation efficiency.
In this regard, the present application finds that the existing virtual machine creation method, which is used to adopt a hot snapshot technique designed for a save/restore mechanism, is not suitable for a scenario of a duplicate source virtual machine. Therefore, the method and the device for storing and managing the source virtual machine to be copied utilize a virtual machine template mode, meanwhile, the memory of the source virtual machine is divided into a larger part and a smaller part, the smaller part of the memory (marked as a first memory) is persisted, namely, the first memory data in the first memory is written into a file system of a host, compared with the prior art that all the memory data are written into the file system, the time consumption of the memory data storing process is greatly reduced, the virtual machine creating efficiency is improved, and the resource consumption is reduced. With regard to a specific implementation process of the virtual machine creation method proposed in the present application, reference may be made to the description of the following embodiments.
Referring to fig. 1, a flowchart of an alternative example of a virtual machine creation method proposed by the present application may be applied to a computer device, where the computer device may be a server or a terminal device with strong data processing capability as required, and the present application does not limit the product type of the computer device, as shown in fig. 1, the method may include, but is not limited to, the following steps:
step S11, responding to the virtual machine creating request, creating a virtual machine template for reserving the running state of the source virtual machine;
in the process, in order to meet the scenario requirement for copying or sharing the source virtual machine, the source virtual machine may be cloned as a virtual machine template, and details about the specific creation process of the virtual machine template are not described.
As can be seen, the virtual machine creation request of this embodiment may be generated in a scenario that a source virtual machine needs to be copied or shared, but the specific generation method is not limited. In some embodiment implementations, the computer device may control, in response to an operation request for any application program run by the source virtual machine, the requested application program to perform a corresponding operation, and after the user uses the source virtual machine to run for a period of time, if the source virtual machine needs to be copied or shared, the user may send, to the computer device through the terminal device, a copy instruction or a share instruction for the source virtual machine, so that the computer device generates a virtual machine creation request in response to the copy instruction or the share instruction, and accordingly, creation of the virtual machine is implemented.
In an actual application, the virtual machine creation request may include identification information of a source virtual machine, so that the computer device determines, by using the identification information, which virtual machine is copied or shared in the current request, and records the virtual machine in the current request as the source virtual machine. The content included in the virtual machine creation request is not limited in the present application.
For the memory structure of the source virtual machine, it needs to be noted that, in order to improve the virtual machine creation efficiency and implement selective persistent storage of memory data, the memory of the source virtual machine is divided into two parts, namely a first memory and a second memory, specifically, a minimum data set that ensures normal operation of the source virtual machine may be used as one part, and other data generated during operation of the source virtual machine may be used as another part, and the two parts of data are stored in different memory spaces, and when storing memory data, only the part of memory data of the minimum data set needs to be persistently stored.
As for the above division of the memory data, the first memory data stored in the first memory divided by the memory of the source virtual machine may include: the minimum data set for normal operation of the source virtual machine, and the second memory data stored in the second memory may include: the user uses various application data generated in the process of the source virtual machine. It should be understood that the first memory data and the second memory data may collectively represent the operating state of the source virtual machine, so that after the source virtual machine stops working, the computer device can recover the operating state of the source virtual machine on the target virtual machine according to the operating state, and the use requirement of the user on the virtual machine is met.
In some embodiments, the first memory data may include virtual machine device state information, basic Input Output system (bios) configuration information, memory page table information, and the like, and the second memory data may include program codes for loading kernel space and user space, stack data generated by running an application, data loaded from a host disk, and the like. It should be noted that specific contents included in the first memory data and the second memory data are not limited to those listed in this embodiment.
In this embodiment, the state information of the virtual machine device may include: the virtualization management device creates memory mapping block data for the virtual machine device, connection configuration data between the device and the virtual machine, various configuration parameters required by the device during operation, a simulated on-chip memory and the like; the BIOS Configuration information may be data for implementing BIOS initialization, and may include a table created in the BIOS initialization stage, such as an ACPI (Advanced Configuration and Power Interface) table. The page table is a special data structure, is placed in a page table area of a system space, stores a corresponding relation between a logical page and a physical page frame, each process has a page table of its own, and the memory page table information can be data recorded by a virtual machine memory page table.
Step S12, controlling the source virtual machine to stop running, and writing the first memory data into the host machine file system;
in practical application of this embodiment, a newly created target virtual machine needs to be capable of copying a source virtual machine, so before memory data is saved, the operation of the source virtual machine is stopped first, for example, the operation is stopped after a virtual machine template is determined to be created, or the source virtual machine is controlled to be stopped when a virtual machine creation request is responded, and the like.
After the source virtual machine stops operating, as analyzed above, in this embodiment, in order to ensure that the created target virtual machine can be started and operated normally, the first memory data playing a crucial role in starting the virtual machine is written into the host file system for persistent storage, and the second memory data of the source virtual machine resides in the host memory in a shared manner and is no longer written into the host file system. Because the data size of the first memory data is very small relative to the data size of the whole memory data of the source virtual machine, even the first memory data is only in the size of the KB level, compared with the file size of the MB level even after all the memory data are compressed in the prior art, the method and the device greatly reduce the time spent on writing the memory data into the file system, and further improve the virtual machine creating efficiency.
It should be noted that, in this embodiment, a specific implementation method for writing the first memory data into the host file system for storage is not limited, and the first memory data may be compressed and then stored, or may be directly written into the host file system for storage due to a small data amount of the first memory data, and the like, and may be determined according to actual requirements.
Step S13, instantiating the virtual machine template to obtain a target virtual machine;
in this embodiment, after the memory data of the source virtual machine is saved according to the above manner, the virtual machine recovery stage is entered, and when the virtual machine is created in this stage, the virtual machine is instantiated by using the above-mentioned constructed virtual machine template without using the hot snapshot manner, so as to implement creation of the target virtual machine, thereby avoiding various technical problems caused by creating the virtual machine by using the hot snapshot manner.
In practical application, if a source virtual machine needs to be copied in multiple copies or shared to multiple users for use, the virtual machine template can be instantiated repeatedly for multiple times to obtain multiple target virtual machines, and the instantiation processes of the multiple target virtual machines are independent and do not interfere with each other.
It should be understood that, since the virtual machine template may be obtained by cloning the source virtual machine, which preserves the running state of the source virtual machine and also embodies that the memory of the source virtual machine is composed of two parts, i.e., the first memory and the second memory, when the virtual machine is instantiated according to the virtual machine template, the obtained memory space of the target virtual machine is also divided into two parts, i.e., the first memory and the second memory.
Step S14, in response to the start request for the target virtual machine, read the first memory data from the host file system, write the first memory data into the first memory of the target virtual machine, and control the target virtual machine to enter the running state.
After the instantiation of the virtual machine is completed, when a user starts the target virtual machine, and copies or shares the running state of the source virtual machine, a starting request for the target virtual machine can be sent to the computer device, and the computer device can start the target virtual machine in response to the starting request.
Certainly, in practical applications, after the computer device completes instantiation of the virtual machine, the computer device may directly respond to the start request, read and execute the first memory data of the corresponding source virtual machine stored in the host file system, to start the created target virtual machine, so that the running state of the target virtual machine is automatically recovered from the virtual machine template without manual operation. Therefore, the present application does not limit the generation method of the aforementioned start request for the target virtual machine.
In the starting stage of the target virtual machine, in order to ensure that the target virtual machine is normally started and operated, first memory data of the source virtual machine stored in a host file system needs to be read, so that the target virtual machine is reliably started by using the first memory data, for example, the device state is restored, BIOS initialization is realized, a memory page table is created, and the like, and a foundation is laid for subsequently restoring a specific application state of the virtual machine, that is, the virtual machine can usually restore the system operation state first, and restore the operation state of each application and the like based on the system operation under the condition that the system can normally operate. Therefore, in this embodiment, after the read first memory data is written into the first memory of the target virtual machine, the first memory data may be executed to control the system of the target virtual machine to start and operate normally, and then, the terminal device of the user may be connected to the target virtual machine to use normally.
To sum up, in this embodiment, the memory of the source virtual machine is divided into two parts, that is, a first memory and a second memory, and in a scenario where the source virtual machine needs to be copied or shared to be used by others, in this embodiment, a target virtual machine is created in a manner of using a virtual machine template, a virtual machine template that preserves the running state of the source virtual machine is specifically created, after the running of the virtual machine is stopped, first memory data of a minimum data set that ensures normal running of the source virtual machine is written into a host file system, and after the virtual machine template is instantiated, the first memory data can be read and written into the first memory of the obtained target virtual machine, so that the target virtual machine can be started and run normally, so that a user can connect with the target virtual machine for normal use. Therefore, in the embodiment, all the memory data of the source virtual machine does not need to be written into the file system of the host machine, and the snapshot of the disk is also not needed, because the data volume of the first memory data relative to all the memory data is very small, the storage mode greatly reduces the memory data storage time, improves the virtual machine creation efficiency, and can also meet the use requirements of users on the virtual machine.
Referring to fig. 2, a flowchart of yet another optional example of the virtual machine creation method proposed in the present application, which may still be applied to a computer device, may be an implementation manner of implementing a refinement scheme of the virtual machine creation method described in the foregoing embodiment, but is not limited to this implementation manner, and as shown in fig. 2, the method may include:
step S21, responding to the virtual machine establishing request, and obtaining the running state data of the source virtual machine;
in the present application, the memory space of the source virtual machine is divided into two parts, namely, a first memory and a second memory, and according to the requirements of the two memory spaces for the stored data, the operating state data obtained in the operating process of the source virtual machine can be written into the first memory or the second memory, so that the operating state data of the source virtual machine can include the first memory data and the second memory data of the source virtual machine, in other words, the operating state of the source virtual machine can be determined by the first memory data and the second memory data together, and the operating state of the system and the operating state of the running application thereof are ensured. For the contents of the first memory data and the second memory data, reference may be made to the description of the corresponding parts in the foregoing embodiments, and details are not repeated.
In practical applications of some embodiments, when the source virtual machine needs to be copied or shared, a plurality of templates may be output on a display interface of a terminal device used by a user for selection and configuration by the user, and then the user may click a "create" button, generate a virtual machine creation request and send the virtual machine creation request to the computer device, so that the computer device executes step S21 to implement creation of a virtual machine template, thereby implementing creation of a virtual machine.
Step S22, creating a virtual machine template by using the running state data;
the method for creating the virtual machine template is not limited, and the created virtual machine template is required to be capable of reserving the running state of the source virtual machine, so that the target virtual machine after the virtual machine is instantiated can copy or share the running state of the source virtual machine.
Because the memory of the source virtual machine is divided into the first memory and the second memory, in order to ensure that the subsequently created target virtual machine can also have the memory space structure, the configuration information of the created virtual machine template may include: the method and the device for configuring the virtual machine memory comprise the steps of configuring first memory configuration information and second memory configuration information of the virtual machine memory, and thus, in the instantiation process of the virtual machine, configuring the first memory of the created virtual machine by using the first memory configuration information, and configuring the second memory of the created virtual machine by using the second memory configuration information.
Step S23, controlling the source virtual machine to stop running, and writing the first memory data of the source virtual machine into the host machine file system;
regarding the implementation process of step S23, reference may be made to the description of the corresponding parts in the foregoing embodiments, and details are not repeated.
Step S24, deleting the configuration information of the source virtual machine except the second memory data;
as a result, compared with the storage of the whole memory data of the source virtual machine, the embodiment only performs persistent storage on the first memory data with a smaller data size, so that the memory data storage speed is increased, and the space resource is saved; and for other memory data of the source virtual machine, namely second memory data, the other memory data is reserved in the memory of the host machine in a sharing mode.
In order to protect the used memory data from being modified, so as to ensure that the created target virtual machine executes the memory data, and can copy or share the running state of the source virtual machine, after the creation of the virtual machine template is completed, the embodiment may delete the source virtual machine, that is, delete the configuration information of the source virtual machine except for the second memory data, so that the user cannot use the source virtual machine any more, and cannot modify the memory data of the source virtual machine.
Step S25, responding to a starting request aiming at the target virtual machine, reading first memory data from a host machine file system, writing the first memory data into the first memory of the target virtual machine, and controlling the target virtual machine to start and run;
in combination with the above analysis of the first memory data, starting the created target virtual machine generally enters a system initialization stage, at which the embodiment acquires the first memory data of the pre-stored source virtual machine and writes the first memory data into the first memory of the target virtual machine, so that the target virtual machine executes the first memory data at the starting stage to complete the system initialization configuration. It should be understood that, since the memory data used at this time is the first memory data stored when the source vm stops operating, the system operating state when the source vm stops operating, including the device state, the configuration state after the BIOS is initialized, the state of the memory page table, and the like, can be copied after the target vm is initialized for startup.
Therefore, in the embodiment, the created target virtual machine can be ensured to be started and operated normally by using the first operation state of the pre-stored source virtual machine, and at this time, the user can be connected to the target virtual machine normally for use.
Step S26, according to the page missing loading mechanism, reading target memory data required by the target virtual machine from the second memory data;
in practical application, the virtual memory provides a consistent and private address space for each process, each process has a continuous and complete memory space, and data generated by application operation of the process is called and can be stored as memory data in the memory space corresponding to the process, and a specific implementation process is not described in detail.
The page missing mechanism of the memory is that when a virtual address is a non-existent memory, a processor of a host may be triggered to generate a page-out fault abnormal interrupt, at this time, a page may be loaded into a physical memory from a secondary storage space (such as a hard disk), and if the physical memory is completely occupied at this time, a part of the storage space of the secondary storage space may be used as a swap buffer area, a page that is temporarily not used in the page is swapped into the secondary buffer area, and then a requested page is swapped into the memory, which does not describe in detail the specific implementation process of step S26.
Step S27, writing the target memory data into the second memory of the target virtual machine, and controlling the target virtual machine to copy the running state of the source virtual machine when the source virtual machine stops running.
After the target virtual machine is determined to be started and operated normally, a user uses the target virtual machine, according to specific application use requirements of different users and according to a page missing loading mechanism, required target memory data are selectively read from second memory data of a source virtual machine and written into a second memory of the target virtual machine, so that the target virtual machine executes the target memory data, the operation state of the source virtual machine relative to the application before the stop of the operation is copied, the target virtual machine is enabled to work in place of the source virtual machine, and the use requirements of the user on the application are met. Therefore, in the process, the source virtual machine is paused for a period of time and then resumed to continue to work, so that the operation which is completed by the source virtual machine before the user is not influenced, and the user can continue to perform subsequent operations.
Based on this, after the virtual machine manager uses the first memory data of the source virtual machine to restore the target virtual machine to the system running state before the source virtual machine stops running, on this basis, the virtual machine manager can continuously copy the target virtual machine to other running states of the source virtual machine, such as the running state of any application running before the source virtual machine stops running, and the like, by reading the target memory data in the second memory data, so as to meet the application use requirement of the user.
In summary, in this embodiment, a manner of creating a virtual machine template that preserves an operating state of a source virtual machine is adopted, and a virtual machine is instantiated to create at least one required target virtual machine, and in this embodiment, a virtual machine memory is divided into a first memory and a second memory, referring to fig. 3, only first memory data is written into a file system, so that memory data storage time is greatly shortened, second memory data of the source virtual machine is stored in a shared manner, so that a user selectively recovers the operating state of the target virtual machine, and while an application requirement of the user is met, occupation of space resources by storing all memory data is avoided. In addition, the mode provided by the embodiment does not need to store the whole disk data, and the virtual machine creation efficiency is further improved.
Referring to fig. 4, a block diagram of an alternative example of the virtual machine creation apparatus proposed in the present application is shown, where the apparatus may be applied to a computer device, but the specific product type of the computer device is not limited, and as shown in fig. 4, the virtual machine creation apparatus may include:
a virtual machine template creating module 11, configured to create, in response to a virtual machine creation request, a virtual machine template that reserves an operating state of a source virtual machine;
in this application, the source virtual machine may include a first memory and a second memory, the first memory data stored in the first memory may include a minimum data set in which the source virtual machine normally operates, and the first memory data and the second memory data in the second memory may jointly represent an operation state of the source virtual machine.
In some embodiments, the first memory data may include device state information of the virtual machine, BIOS configuration information of the basic input output system, memory page table information, and the like, and the virtual machine executes the first memory data, so that normal start and operation of the virtual machine can be ensured, and then other application programs can be operated. The second memory data may include program codes for loading kernel space and user space, stack data generated by application program operation, data loaded from a host disk, and the like. Therefore, in the process that the user runs various application programs by using the source virtual machine, various generated data can be stored as second memory data, and after the source virtual machine is copied subsequently, the target memory data corresponding to the required application is selected from the second memory data and executed, so that the application can be restored to the running state of the source virtual machine.
It should be understood that, in the present application, the data content of the first memory data and the second memory data is not limited, and in general, the data amount of the first memory data is very small, and for virtual machines of the same system architecture, the corresponding first memory data is substantially the same, and the second memory data is dynamically changed based on the use of the user.
In practical applications, the virtual machine creation apparatus provided by the present application may further include:
the operation request response module is used for responding to an operation request of any application program running aiming at the source virtual machine and controlling the requested application program to execute corresponding operation;
and the virtual machine creation request generation module is used for responding to the replication instruction or the sharing instruction aiming at the source virtual machine and generating a virtual machine creation request.
The first control module 12 is used for controlling the source virtual machine to stop running and writing the first memory data into a host machine file system;
the instantiation module 13 is configured to instantiate the virtual machine template to obtain a target virtual machine;
in this embodiment, before the memory data of the source virtual machine is saved, the source virtual machine is paused, and then, as shown in fig. 3, only the first memory data in the first memory of the source virtual machine is written into the file system of the host to perform persistent storage, whereas the second memory data in the second memory is not the critical data for ensuring the virtual machine to start running, so the present application may be saved in the memory in a shared manner for the user to selectively read.
Therefore, the memory data storage method provided by the embodiment, namely the method for storing the memory data to the host file system, greatly shortens the memory data storage time, reduces the occupation of space resources, and improves the virtual machine creation efficiency compared with the permanent storage of all the memory data in the conventional scheme.
In some embodiments, especially in a scenario that a source virtual machine needs to be replicated for multiple times or shared for use by multiple other users, the instantiation module 13 may be further configured to: and repeating the instantiation of the virtual machine template for multiple times to obtain a plurality of target virtual machines, wherein the instantiation processes of the plurality of target virtual machines are mutually independent.
It should be noted that the present application does not describe in detail how to implement the specific implementation process of instantiating the virtual machine according to the virtual machine template.
The virtual machine running module 14 is configured to, in response to a start request for the target virtual machine, read first memory data from a host file system, write the first memory data into the first memory of the target virtual machine, and control the target virtual machine to enter a running state.
Therefore, in this embodiment, after the target virtual machine is created, the target virtual machine may be started, and in the starting stage, the first memory data of the source virtual machine may be read and executed, so as to ensure that the target virtual machine can be started and operated normally, and a user may connect to the target virtual machine for use.
In combination with the above analysis, in the memory data storage stage, in this embodiment, the first memory data is persistently stored instead of storing all the memory data, so that the memory data storage time is shortened, and the virtual machine creation efficiency is improved; in addition, in the stage of starting the target virtual machine, the first memory data required by the system operation can be read more accurately and rapidly, the virtual machine starting time is shortened, and the user experience is improved.
In some embodiments, according to actual requirements, a user may desire the created target virtual machine and may also copy the running state of the running application before the source virtual machine stops running, so that the application does not need to be operated again when the target virtual machine is used. Based on this, referring to fig. 5, the virtual machine creation apparatus may further include:
a target memory data reading module 15, configured to read target memory data required by the target virtual machine from the second memory data according to a page missing loading mechanism;
and a target memory data writing module 16, configured to write the target memory data into a second memory of the target virtual machine, and control the target virtual machine to copy the running state of the target application run by the source virtual machine.
It should be understood that, in practical applications, if a plurality of target virtual machines are obtained through multiple instantiations, target memory data read by a user using different target virtual machines may be different, and may be determined specifically according to an operation request initiated by a terminal device currently connected to each target virtual machine, and the specific content of the target memory data is not limited in the present application.
In some embodiments, as shown in fig. 5, after writing the first memory data to the host file system and before instantiating the virtual machine, the virtual machine creating apparatus may further include:
and the virtual machine deleting module 17 is configured to delete the configuration information of the source virtual machine except the second memory data.
That is to say, after the virtual machine template is created, the source virtual machine can be automatically deleted to ensure that the memory used by the source virtual machine is not modified any more, and further ensure that the target virtual machine used by the user can be restored to the running state before the source virtual machine stops running, so that the source virtual machine can be copied and shared, and the application operation requirements of different users can be met.
It should be noted that, various modules, units, and the like in the embodiments of the foregoing apparatuses may be stored in the memory as program modules, and the processor executes the program modules stored in the memory to implement corresponding functions, and for the functions implemented by the program modules and their combinations and the achieved technical effects, reference may be made to the description of corresponding parts in the embodiments of the foregoing methods, which is not described in detail in this embodiment.
The present application also provides a storage medium on which a computer program may be stored, where the computer program may be called and loaded by a processor to implement the steps of the virtual machine creation method described in the above embodiments.
Referring to fig. 6, a schematic structural diagram of a computer device according to an embodiment of the present application is shown, where the computer device may be a server or a terminal device with a relatively high data processing capability, and as shown in fig. 6, the computer device may include: at least one communication interface 21, at least one memory 22, and at least one processor 23, wherein:
the at least one communication interface 21, the at least one memory 22 and the at least one processor 23 may be capable of data interaction with each other via a communication bus.
The communication interface 21 may be an interface of a communication module, such as an interface of a GSM (Global System for Mobile Communications ) module, an interface of a WIFI module, an interface of a GRPS (General Packet Radio Service ) module, and the like, and may implement data interaction with other devices, and may further include an interface such as a USB (Universal Serial Bus) interface, a Serial/parallel interface, and the like, for implementing data interaction between internal components of a computer device, and may be determined according to a product type of the computer device, which is not described in detail herein.
In this embodiment, the communication interface 21 may be used to implement data interaction between the computer device and the terminal device of the user, and may also implement data transmission between hardware devices such as a processor and a memory in the computer device, which may be determined specifically according to actual requirements.
The memory 22 may be used for storing a program for implementing the virtual machine creation method as described above, and the program may include a plurality of computer instructions, details of which are not described in detail.
In this embodiment, the memory 22 may include a high speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device or other volatile solid state storage device.
In an implementation of some embodiments, the memory 22 may include a program storage area and a data storage area, and the program storage area may store an operating system, and application programs required for at least one function (various application functions such as image processing, data processing, and the like), programs that implement the virtual machine creation method proposed in the present application, and the like; the data storage area can store data generated in the use process of the computer equipment, such as memory data, configuration information and the like.
The processor 23 may be configured to load and execute the program stored in the memory 22 to implement the steps of the virtual machine creation method, and the specific implementation process may refer to the description of the corresponding parts of the above method embodiments.
In practical applications, the processor 23 may be a Central Processing Unit (CPU), an application-specific integrated circuit (ASIC), a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device.
It should be understood that the structure of the computer device shown in fig. 6 is not limited to the computer device in the embodiment of the present application, and may include more or less components than those shown in fig. 6 or some components in combination according to actual needs, which is not listed here.
It should be noted that the present application has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In addition, in the present specification, each embodiment is described in a progressive or parallel manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. For the device disclosed by the embodiment, the description is relatively simple because the device corresponds to the method disclosed by the embodiment, and the relevant part can be referred to the method part for description.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A virtual machine creation method, the method comprising:
in response to a virtual machine creation request, creating a virtual machine template for reserving the running state of a source virtual machine, wherein the source virtual machine comprises a first memory and a second memory, first memory data stored in the first memory comprises a minimum data set for normal running of the source virtual machine, and the first memory data and second memory data of the second memory can jointly represent the running state of the source virtual machine;
controlling the source virtual machine to stop running, and writing the first memory data into a host machine file system; wherein the second memory data resides in the host memory;
instantiating the virtual machine template to obtain a target virtual machine;
and responding to a starting request aiming at the target virtual machine, reading the first memory data from the host machine file system, writing the first memory data into the first memory of the target virtual machine, and controlling the target virtual machine to enter a running state.
2. The method of claim 1, the creating, in response to the virtual machine creation request, a virtual machine template that preserves a running state of the source virtual machine, comprising:
responding to a virtual machine creation request, and obtaining running state data of a source virtual machine, wherein the running state data comprises the first memory data and the second memory data of the source virtual machine;
and creating a virtual machine template by using the running state data, wherein the configuration information of the virtual machine template comprises first memory configuration information and second memory configuration information for configuring the memory of the virtual machine.
3. The method of claim 1, after writing the first memory data to a host file system, the method further comprising:
deleting the configuration information of the source virtual machine except the second memory data.
4. The method of claim 1, wherein the reading the first memory data from the host file system, writing the first memory data to the first memory of the target virtual machine, and controlling the target virtual machine to enter a running state in response to the boot request for the target virtual machine comprises:
triggering the target virtual machine to run in response to a starting request aiming at the target virtual machine;
and reading the first memory data from the host file system, writing the first memory data into the first memory of the target virtual machine, and controlling the target virtual machine to copy the running state of the source virtual machine when the source virtual machine stops running.
5. The method of claim 3, further comprising:
reading target memory data required by the target virtual machine from the second memory data according to a page missing loading mechanism;
and writing the target memory data into a second memory of the target virtual machine.
6. The method of any of claims 1 to 5, wherein the first memory data comprises virtual machine device state information, BIOS configuration information, and memory page table information;
the second memory data includes program codes for loading kernel space and user space, stack data generated by application program operation, and data loaded from a host disk.
7. The method of any of claims 1-5, further comprising:
responding to an operation request of any application program running on the source virtual machine, and controlling the requested application program to execute corresponding operation;
generating the virtual machine creation request in response to a replication instruction or a sharing instruction for the source virtual machine.
8. The method according to any one of claims 1 to 5, wherein instantiating the virtual machine template to obtain a target virtual machine comprises:
and repeating the instantiation of the virtual machine template for multiple times to obtain a plurality of target virtual machines, wherein the instantiation processes of the plurality of target virtual machines are mutually independent.
9. An apparatus for virtual machine creation, the apparatus comprising:
the virtual machine template creating module is used for responding to a virtual machine creating request and creating a virtual machine template for reserving the running state of a source virtual machine, wherein the source virtual machine comprises a first internal memory and a second internal memory, first internal memory data stored in the first internal memory comprise a minimum data set of the source virtual machine in normal running, and the first internal memory data and second internal memory data of the second internal memory can jointly represent the running state of the source virtual machine;
the first control module is used for controlling the source virtual machine to stop running and writing the first memory data into a host machine file system; wherein the second memory data resides in the host memory;
the instantiation module is used for instantiating the virtual machine template to obtain a target virtual machine;
and the virtual machine running module is used for responding to a starting request aiming at the target virtual machine, reading the first memory data from the host machine file system, writing the first memory data into the first memory of the target virtual machine, and controlling the target virtual machine to enter a running state.
10. A computer device comprising at least one memory and at least one processor, wherein:
the memory is used for storing a program for realizing the virtual machine creating method according to any one of claims 1 to 8;
the processor is used for loading and executing the program stored in the memory so as to realize the steps of the virtual machine creation method according to any one of claims 1 to 8.
CN201910923750.9A 2019-09-27 2019-09-27 Virtual machine creation method and device and computer equipment Active CN110704161B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910923750.9A CN110704161B (en) 2019-09-27 2019-09-27 Virtual machine creation method and device and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910923750.9A CN110704161B (en) 2019-09-27 2019-09-27 Virtual machine creation method and device and computer equipment

Publications (2)

Publication Number Publication Date
CN110704161A CN110704161A (en) 2020-01-17
CN110704161B true CN110704161B (en) 2022-05-31

Family

ID=69196632

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910923750.9A Active CN110704161B (en) 2019-09-27 2019-09-27 Virtual machine creation method and device and computer equipment

Country Status (1)

Country Link
CN (1) CN110704161B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111506389A (en) * 2020-03-25 2020-08-07 新华三大数据技术有限公司 Virtual machine starting method and device
CN113886027B (en) * 2021-12-07 2022-03-08 广州锦和科技有限公司 Virtual machine template creation method, virtual machine access method, virtual machine template creation device and storage medium
CN114385076B (en) * 2021-12-09 2023-08-25 苏州浪潮智能科技有限公司 Method and device for accelerating cloning of virtual machine disk based on shared storage
CN117234658A (en) * 2022-06-08 2023-12-15 中兴通讯股份有限公司 Virtual machine creation method, remote device, server device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107193633A (en) * 2017-05-23 2017-09-22 郑州云海信息技术有限公司 A kind of batch creates the method and device of virtual machine
CN108710527A (en) * 2018-04-09 2018-10-26 广东睿江云计算股份有限公司 A kind of virtual machine template management system, method based on xen
CN109634713A (en) * 2018-11-02 2019-04-16 新华三云计算技术有限公司 A kind of virtual machine starting method and device
CN109885377A (en) * 2018-11-23 2019-06-14 中国银联股份有限公司 The method of unified resource scheduling coordinator and its creation virtual machine and/or container, unified resource dispatch system

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
IN2013MU03236A (en) * 2013-10-15 2015-07-03 Tata Consultancy Services Ltd
US9619268B2 (en) * 2014-08-23 2017-04-11 Vmware, Inc. Rapid suspend/resume for virtual machines via resource sharing
CN107807838B (en) * 2016-09-08 2021-11-23 阿里巴巴集团控股有限公司 Virtual machine processing method, device and equipment
US10691477B2 (en) * 2016-09-27 2020-06-23 Red Hat Israel, Ltd. Virtual machine live migration using intelligent order of pages to transfer
CN109753341A (en) * 2017-11-07 2019-05-14 龙芯中科技术有限公司 The creation method and device of virtual interface
CN109189546B (en) * 2018-07-11 2021-04-06 新华三云计算技术有限公司 Method and device for making online snapshot of virtual machine

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107193633A (en) * 2017-05-23 2017-09-22 郑州云海信息技术有限公司 A kind of batch creates the method and device of virtual machine
CN108710527A (en) * 2018-04-09 2018-10-26 广东睿江云计算股份有限公司 A kind of virtual machine template management system, method based on xen
CN109634713A (en) * 2018-11-02 2019-04-16 新华三云计算技术有限公司 A kind of virtual machine starting method and device
CN109885377A (en) * 2018-11-23 2019-06-14 中国银联股份有限公司 The method of unified resource scheduling coordinator and its creation virtual machine and/or container, unified resource dispatch system

Also Published As

Publication number Publication date
CN110704161A (en) 2020-01-17

Similar Documents

Publication Publication Date Title
CN110704161B (en) Virtual machine creation method and device and computer equipment
US8473462B1 (en) Change tracking for shared disks
US9552168B2 (en) Virtual machine backup from storage snapshot
US9870288B2 (en) Container-based processing method, apparatus, and system
US20170286153A1 (en) Managing Container Pause And Resume
KR101636870B1 (en) Method and apparatus for generating minimal boot image
US20170322824A1 (en) Cloning Computing Device Containers
US9354907B1 (en) Optimized restore of virtual machine and virtual disk data
CN111488241A (en) Method and system for realizing agent-free backup and recovery operation on container arrangement platform
US20110093437A1 (en) Method and system for generating a space-efficient snapshot or snapclone of logical disks
US9164856B2 (en) Persistent messaging mechanism
CN110262893B (en) Method and device for configuring mirror image memory and computer storage medium
CN112596950A (en) Virtual machine data backup method, device, equipment and storage medium
JP6464288B2 (en) Program, apparatus, server, and storage medium for deleting a cloud host in a cloud computing environment
CN112711469A (en) Cloud host migration method and device, computer equipment and storage medium
CN111414240B (en) Kernel state process copying method and device, container expanding method and device
US20220374256A1 (en) Information processing system, information processing apparatus, method of controlling the same, and storage medium
WO2022242665A1 (en) Data storage method and related device
US11500741B2 (en) Data write method and storage system
KR101552580B1 (en) Method for system recovery including mobile device and backup supporting multi operation system
CN110704249A (en) Method, device and system for ensuring application consistency
CN111208947A (en) Data migration method and device, physical machine, cloud platform and computer storage medium
CN111435299A (en) Application processing method and device
CN104461382A (en) Internal writing method for file server operating multiple file systems and server
US8799616B2 (en) Method and system for preferred CPU binding on virtual partitions

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant