CN117742890A - Virtual machine creation method, device, equipment and storage medium - Google Patents

Virtual machine creation method, device, equipment and storage medium Download PDF

Info

Publication number
CN117742890A
CN117742890A CN202311758384.9A CN202311758384A CN117742890A CN 117742890 A CN117742890 A CN 117742890A CN 202311758384 A CN202311758384 A CN 202311758384A CN 117742890 A CN117742890 A CN 117742890A
Authority
CN
China
Prior art keywords
virtual machine
resource
machine
file
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.)
Pending
Application number
CN202311758384.9A
Other languages
Chinese (zh)
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.)
Kedong Guangzhou Software Technology Co Ltd
Original Assignee
Kedong Guangzhou Software Technology Co 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 Kedong Guangzhou Software Technology Co Ltd filed Critical Kedong Guangzhou Software Technology Co Ltd
Priority to CN202311758384.9A priority Critical patent/CN117742890A/en
Publication of CN117742890A publication Critical patent/CN117742890A/en
Pending legal-status Critical Current

Links

Abstract

The embodiment of the invention provides a method, a device, equipment and a storage medium for creating a virtual machine, wherein the method comprises the following steps: configuring hardware resources of the first virtual machine according to the resource configuration file of the first virtual machine, wherein the resource configuration file of each virtual machine is created on an offline host machine and comprises configuration information of the hardware resources of the virtual machine in the resource description file of the target machine; the method comprises the steps of starting an image of a first virtual machine on hardware resources of the first virtual machine by using a resource description file of the first virtual machine to create the first virtual machine, wherein the resource description file of each virtual machine is created on an offline host. According to the technical scheme provided by the embodiment of the invention, the virtual machine is created by occupying lower hardware resources on a hardware platform with lower performance through the resource configuration file and the resource description file of the virtual machine generated offline, and the resource consumption of the target machine is reduced.

Description

Virtual machine creation method, device, equipment and storage medium
Technical Field
The present invention relates to the field of embedded operating systems, and in particular, to a method, an apparatus, a device, and a storage medium for creating a virtual machine.
Background
The existing virtual machine hardware resource allocation technology is divided into three types, namely a graphical-based hardware resource allocation tool provided by software like virt-manager, vmware and the like; secondly, the hardware resource allocation based on text provided by the type1 virtualization systems such as xen and acrn is realized, and thirdly, the chip-level hardware resource partition is provided in a similar NXP IMX8 series.
The first type is a resource allocation method based on a server virtualization system, and the server virtualization technical scheme is mainly used for fully utilizing the computing power of hardware to achieve the aim of running as many services as possible on the same hardware platform, so that the resource allocation and the actual hardware resources are not in one-to-one correspondence, the set of the resources such as CPU, memory, io and the like allocated by all virtual machines is larger than the set of the actual hardware resources, and meanwhile, the hardware resources allocated by the virtual machine interface and the actual physical hardware resources have no direct association.
The second type1 virtualization technology is mostly evolved from a server virtualization technology, and besides the functions required in the embedded system scene are newly added, the second type1 virtualization technology also maintains the technical characteristics of many server virtualization, such as the start and stop of the creation configuration of the virtual machine based on dom0 (domain 0 or service operating system), and the configuration mode has higher requirements on configurators.
The third type is based on the hardware resource partitioning function provided by the chip manufacturer, must follow the configuration rules provided by the hardware manufacturer, lacks flexibility and versatility in use configuration, and is not applicable to chips that do not support the hardware resource partitioning function.
Disclosure of Invention
In view of this, the embodiments of the present invention provide a method, apparatus, device and storage medium for creating a virtual machine. The technical scheme of the embodiment of the invention is used for creating the virtual machine at the target machine virtualized by the tyrp 1, and the virtual machine is created by occupying lower hardware resources on a hardware platform with lower performance through the resource configuration file and the resource description file of the offline virtual machine, so that the resource consumption of the target machine is reduced.
In a first aspect, an embodiment of the present invention provides a method for creating a virtual machine, including: configuring hardware resources of the first virtual machine according to the resource configuration file of the first virtual machine, wherein the resource configuration file of each virtual machine is created on an offline host machine and comprises information of the hardware resources of the virtual machine in the resource description file of the target machine; the method comprises the steps of starting an image of a first virtual machine on hardware resources of the first virtual machine by using a resource description file of the first virtual machine to create the first virtual machine, wherein the resource description file of each virtual machine is created on an offline host.
By the method, the virtual machine is created on the embedded target machine based on the type1 virtualization, the resource configuration file and the resource description file of the virtual machine are generated offline, the resource configuration file comprises the information of the hardware resources of the virtual machine in the resource description file of the target machine, the resources of the virtual machine can be configured on the approximate bare machine, the virtual machine is started, and therefore the virtual machine can be created on a hardware platform with lower performance by occupying lower hardware resources, and the resource consumption of the target machine is reduced.
In one possible implementation manner of the first aspect, the hardware resource of each virtual machine includes an independent hardware resource of the virtual machine, where the independent hardware resource includes an independent CPU core, an independent memory section, and a physical device of the virtual machine. The physical device is an independent device of the virtual machine.
By the above, the partition isolation is realized by the independent hardware resources of each virtual machine including the independent CPU core, the independent memory section and the physical equipment of the virtual machine, and the virtual machine can be started on the bare machine.
In a possible implementation manner of the first aspect, the hardware resource of each virtual machine further includes a virtual hardware resource of the virtual machine, where the virtual hardware resource corresponds to a corresponding hardware resource in the kernel of the target machine; before configuring the hardware resources of the first virtual machine, further comprising: and configuring hardware resources of the target machine core according to the resource configuration file of the target machine core, starting the mirror image of the target machine core on the hardware resources, wherein the resource configuration file of the target machine core is created on the offline host and comprises configuration information of the hardware resources of the target machine core in the resource description file of the target machine.
By the method, the resource configuration file of the target machine kernel is generated offline, the resource configuration file comprises information of hardware resources of the target machine kernel in the resource description file of the target machine, and resources of the virtual machine can be configured on an approximate bare machine and the virtual machine can be started, so that the target machine kernel can be started on a hardware platform with lower performance by occupying lower hardware resources.
In a possible implementation manner of the first aspect, the resource configuration file of the target machine core further includes a mirror image of the target machine core and a loading address of the resource configuration file of each virtual machine; the resource configuration file for each virtual machine also includes the image of the virtual machine and the loading address of the resource description file.
By the method, the loading address of the related file is increased through the related resource configuration file, so that the related file can be loaded conveniently.
In a possible implementation manner of the first aspect, when the first virtual machine is already running and the second virtual machine is started, the method further includes: the target machine kernel loads a resource configuration file, a resource description file and a mirror image of the second virtual machine; and configuring hardware resources of the second virtual machine according to the resource configuration file of the second virtual machine, and starting the mirror image of the second virtual machine by utilizing the resource description file of the second virtual machine.
By the method, the virtual machine resource is configured and started through the resource configuration file of the virtual machine, which is generated in advance, so that a new virtual machine is started in a non-stop state.
In a possible implementation manner of the first aspect, the method further includes: and on the offline host, distributing the hardware resources of the target machine to the target machine and each virtual machine according to the resource description file of the target machine, and creating the resource configuration file of the target machine and the resource configuration file of each virtual machine.
By the method, partition isolation and configuration of the hardware resources of the target machine are realized on the offline host, the complexity of generating the resource configuration file created by the virtual machine and the resource description file started by the virtual machine is simplified, the requirements on a configurator are reduced, and the creation of the virtual machine is realized by occupying lower hardware resources on a hardware platform with lower performance.
In one possible implementation manner of the first aspect, the allocating, according to the resource description file of the target machine, hardware resources of the target machine to the target machine and each virtual machine includes: abstracting the allocable physical resources of the target machine from the resource description file of the target machine; and distributing the distributable hardware resources to the target machine core and each virtual machine according to the hardware resource requirements of the target machine core and each virtual machine to obtain resource information files of the target machine core and each virtual machine, wherein the resource information files of the virtual machine comprise the independent hardware resources and the identifiers of the resource description files of the virtual hardware resources in the target machine, and the resource information files of the target machine core comprise the identifiers of the resource description files of the hardware resources in the target machine.
By abstracting and distributing the simple resource information files of the target machine kernel and the virtual machine, the complexity of generating the resource configuration file is reduced.
In one possible implementation manner of the first aspect, creating a resource configuration file of the target machine kernel and each virtual machine includes: constructing corresponding configuration structures for each hardware resource in each resource information file of the target machine kernel and each virtual machine, and obtaining resource configuration files of the target machine kernel and each virtual machine when the configuration structures of each hardware resource comprise corresponding description messages in the resource description files of the target machine; and adding an interrupt configuration structure body in each resource configuration file, wherein the interrupt configuration structure body of the target machine kernel comprises an interrupt number of a hardware resource of the target machine kernel, and the interrupt configuration structure body of each virtual machine comprises an independent hardware resource of the virtual machine and an interrupt number of the virtual hardware resource.
By supplementing the resource description information of the resource description file of the target machine into the configuration structure of the hardware resources in each resource configuration file, the target machine core and each virtual machine can be created on the bare machine according to the resource configuration files of the target machine core and each virtual machine.
In one possible implementation manner of the first aspect, creating the resource description file of each virtual machine on the offline host includes: and copying a resource description file of a target machine for each virtual machine, and setting unassigned hardware resources of the virtual machine in the copied resource description file to be in an invalid state according to the resource information file of the virtual machine to obtain the resource description file of the virtual machine.
By setting the hardware resources which are not included in the resource information file of the corresponding virtual machine in the copied resource description file to be in an invalid state, the resource description file of the virtual machine is accurately and quickly obtained.
In a possible implementation manner of the first aspect, each resource description file includes a device tree or an APC I table.
From above, the creation of virtual machines on bare machines of various types of chips is supported by the resource description file including a device tree or APC I table.
In a second aspect, an embodiment of the present invention provides a device for creating a virtual machine, including: the virtual machine resource configuration module is used for configuring the hardware resources of the first virtual machine according to the resource configuration file of the first virtual machine, wherein the resource configuration file of each virtual machine is created on the offline host machine and comprises the information of the hardware resources of the virtual machine in the resource description file of the target machine; the virtual machine creation module is used for starting the mirror image of the first virtual machine by utilizing the resource description file of the first virtual machine on the hardware resource of the first virtual machine so as to create the first virtual machine, and the resource description file of each virtual machine is created on the offline host.
By the method, the target machine kernel or each virtual machine can be started on the approximate bare machine through the offline generated resource configuration file and resource description file of the target machine kernel and each virtual machine, wherein each resource configuration file comprises information of the hardware resources of the target machine kernel or each virtual machine in the resource description file of the target machine, so that the creation of the virtual machine can be realized by occupying lower hardware resources on a hardware platform with lower performance, and the resource consumption of the target machine is reduced.
By the method, the virtual machine is created on the embedded target machine based on the type1 virtualization, the resource configuration file of the virtual machine is generated offline, the resource configuration file comprises information of hardware resources of the virtual machine in the resource description file of the target machine, the resources of the virtual machine can be configured on the approximate bare machine, the virtual machine is started, and therefore the virtual machine can be created on a hardware platform with lower performance by occupying lower hardware resources, and the resource consumption of the target machine is reduced.
In one possible implementation manner of the second aspect, the hardware resource of each virtual machine includes an independent hardware resource of the virtual machine, where the independent hardware resource includes an independent CPU core, an independent memory section, and a physical device of the virtual machine.
By the above, the partition isolation is realized by the independent hardware resources of each virtual machine including the independent CPU core, the independent memory section and the physical equipment of the virtual machine, and the virtual machine can be started on the bare machine.
In one possible implementation manner of the second aspect, the hardware resource of each virtual machine further includes a virtual hardware resource of the virtual machine, where the virtual hardware resource corresponds to a corresponding hardware resource in the kernel of the target machine; further comprises: the kernel starting module is used for configuring the hardware resources of the target machine kernel according to the resource configuration file of the target machine kernel before configuring the hardware resources of the first virtual machine, starting the mirror image of the target machine kernel on the hardware resources of the target machine kernel, and creating the resource configuration file of the target machine kernel on the offline host.
By the method, the resource configuration file of the target machine kernel is generated offline, the resource configuration file comprises information of hardware resources of the target machine kernel in the resource description file of the target machine, and resources of the virtual machine can be configured on an approximate bare machine and the virtual machine can be started, so that the target machine kernel can be started on a hardware platform with lower performance by occupying lower hardware resources.
In one possible implementation manner of the second aspect, the resource configuration file of the target machine core further includes a mirror image of the target machine core and a loading address of the resource configuration file of each virtual machine; the resource configuration file for each virtual machine also includes the image of the virtual machine and the loading address of the resource description file.
By the method, the loading address of the related file is increased through the related resource configuration file, so that the related file can be loaded conveniently.
In a possible implementation manner of the second aspect, the method further includes: the virtual machine capacity expansion module is used for loading a resource configuration file, a mirror image and a resource description file of the second virtual machine by the target machine kernel when the first virtual machine is already operated and the second virtual machine is started; and configuring the hardware resources of the second virtual machine according to the resource configuration file of the second virtual machine, and starting the mirror image of the second virtual machine by utilizing the resource description file of the second virtual machine, wherein the mirror image comprises the configuration information of the hardware resources of the kernel of the target machine in the resource description file of the target machine.
By the method, the virtual machine resource is configured and started through the resource configuration file of the virtual machine, which is generated in advance, so that a new virtual machine is started in a non-stop state.
In a possible implementation manner of the second aspect, the method further includes: the virtualized file generation module is deployed on the offline host, and is used for distributing hardware resources of the target machine to the target machine and each virtual machine according to the resource description file of the target machine, and creating the resource configuration file of the target machine, the resource configuration file of each virtual machine and the resource description file.
By the method, partition isolation and configuration of the hardware resources of the target machine are realized on the offline host, the complexity of generating the resource configuration file created by the virtual machine and the resource description file started by the virtual machine is simplified, the requirements on a configurator are reduced, and the creation of the virtual machine is realized by occupying lower hardware resources on a hardware platform with lower performance.
In a possible implementation manner of the second aspect, the virtualized file generation module includes: the resource abstraction module is used for abstracting the allocable physical resources of the target machine from the resource description file of the target machine; the resource allocation module is used for allocating the allocatable hardware resources to the target machine core and each virtual machine according to the hardware resource requirements of the target machine core and each virtual machine, and obtaining resource information files of the target machine core and each virtual machine, wherein the resource information files of the virtual machine comprise the independent hardware resources and the identifiers of the resource description files of the virtual hardware resources in the target machine, and the resource information files of the target machine core comprise the identifiers of the resource description files of the hardware resources in the target machine.
By abstracting and distributing the simple resource information files of the target machine kernel and the virtual machine, the complexity of generating the resource configuration file is reduced.
In a possible implementation manner of the second aspect, the virtualized file generation module further includes: the configuration generating module is used for constructing corresponding configuration structural bodies for the hardware resources in each resource information file of the target machine kernel and each virtual machine, and acquiring the resource configuration files of the target machine kernel and each virtual machine by including corresponding description messages of the hardware resources in the resource description files of the target machine in the configuration structural bodies of the hardware resources; the configuration structure of the interrupt of the target machine kernel comprises the interrupt number of the hardware resource of the target machine kernel, and the configuration structure of the interrupt of each virtual machine comprises the independent hardware resource of the virtual machine and the interrupt number of the virtual hardware resource.
By supplementing the resource description information of the resource description file of the target machine into the configuration structure of the hardware resources in each resource configuration file, the target machine core and each virtual machine can be created on the bare machine according to the resource configuration files of the target machine core and each virtual machine.
In a possible implementation manner of the second aspect, the virtualized file generation module further includes: and the description generating module is used for copying a resource description file of a target machine for each virtual machine after the resource configuration file of each virtual machine is created on the offline host, and setting unassigned hardware resources of the virtual machine in the copied resource description file to be in an invalid state according to the resource description file of the virtual machine to obtain the resource description file of the virtual machine.
By setting the hardware resources which are not included in the resource information file of the corresponding virtual machine in the copied resource description file to be in an invalid state, the resource description file of the virtual machine is accurately and quickly obtained.
In a possible implementation manner of the second aspect, each resource description file includes a device tree or an APC I table.
From above, the creation of virtual machines on bare machines of various types of chips is supported by the resource description file including a device tree or APC I table.
In a third aspect, embodiments of the present invention provide a computing device comprising: a bus; a communication interface connected to the bus; at least one processor coupled to the bus; and at least one memory coupled to the bus and storing program instructions that, when executed by the at least one processor, cause the at least one processor to perform any of the embodiments of the first or second aspects of the invention.
In a fourth aspect, embodiments of the present invention provide a computer readable storage medium having stored thereon program instructions which when executed by a computer cause the computer to perform any of the embodiments of the first or second aspects of the present invention.
Drawings
FIG. 1 is a flowchart of a first embodiment of a method for creating a virtual machine according to the present invention;
FIG. 2 is a flowchart illustrating a method for creating a virtual machine according to a second embodiment of the present invention;
FIG. 3A is a flowchart of a method for generating a virtualized file according to a second embodiment of a method for creating a virtual machine of the present invention;
FIG. 3B is a diagram illustrating an example of resource allocation of a virtualized file generation method according to a second embodiment of a method for creating a virtual machine;
FIG. 4A is a flowchart illustrating a specific implementation manner of a virtualized file generation method according to a second embodiment of a virtual machine creation method of the present invention;
FIG. 4B is a schematic diagram illustrating a resource abstraction process of a specific implementation manner of a virtualized file generation method according to a second embodiment of a virtual machine creation method of the present invention;
FIG. 4C is a schematic diagram illustrating a resource allocation process of a specific implementation manner of a virtualized file generation method according to a second embodiment of a virtual machine creation method of the present invention;
FIG. 4D is a schematic diagram illustrating a resource configuration file generation process of a specific implementation manner of a virtualized file generation method according to a second embodiment of a virtual machine creation method of the present invention;
FIG. 4E is a schematic diagram illustrating a resource description file generation process of a specific implementation manner of a virtualized file generation method according to a second embodiment of a virtual machine creation method of the present invention;
FIG. 4F is a schematic diagram illustrating loading address pointing of each file in a resource configuration file of a specific implementation manner of a virtualized file generation method according to a second embodiment of a virtual machine creation method of the present invention;
FIG. 5 is a schematic diagram of a first embodiment of a virtual machine creating apparatus according to the present invention;
FIG. 6 is a schematic diagram of a second embodiment of a virtual machine creating apparatus according to the present invention;
FIG. 7 is a schematic diagram illustrating a configuration of an embodiment of a virtualized file generating apparatus for a virtual machine according to the present invention;
FIG. 8 is a schematic diagram of a computing device of the present invention.
Detailed Description
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is to be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with one another without conflict.
In the following description, references to the terms "first/second/third, etc." or module a, module B, module C, etc. are used merely to distinguish between similar objects or between different embodiments, and do not represent a particular ordering of the objects, it being understood that particular orders or precedence may be interchanged as permitted so that embodiments of the invention described herein can be implemented in an order other than that illustrated or described herein.
In the following description, reference numerals indicating steps such as S110, S120, … …, etc. do not necessarily indicate that the steps are performed in this order, and the order of the steps may be interchanged or performed simultaneously as allowed.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to be limiting of the invention.
The embodiment of the invention provides a method, a device, equipment and a storage medium for creating a virtual machine, wherein the method comprises the following steps: configuring hardware resources of the first virtual machine according to the resource configuration file of the first virtual machine, wherein the resource configuration file of each virtual machine is created on an offline host machine and comprises information of the hardware resources of the virtual machine in the resource description file of the target machine; the method comprises the steps of starting an image of a first virtual machine on hardware resources of the first virtual machine by using a resource description file of the first virtual machine to create the first virtual machine, wherein the resource description file of each virtual machine is created on an offline host.
The technical scheme of the embodiment of the invention is used for creating the virtual machine on the embedded target machine based on the type1 virtualization, and the resource configuration file and the resource description file of the virtual machine are generated offline, and the resource configuration file comprises the configuration information of the hardware resources of the virtual machine in the resource description file of the target machine, so that the resources of the virtual machine can be configured on the approximate bare machine and the virtual machine can be started, thereby realizing the creation of the virtual machine on a hardware platform with lower performance, occupying lower hardware resources and reducing the resource consumption of the target machine.
Embodiments of the present invention are described below with reference to the accompanying drawings. First, an embodiment of a method for creating a virtual machine according to the present invention will be described with reference to fig. 1.
A virtual machine creation method embodiment is used for creating a virtual machine on an embedded target machine of type1 virtualization, and the virtual machine is created by loading a resource configuration file of the virtual machine which is generated offline in advance, and occupying lower hardware resources on a hardware platform with lower performance.
Fig. 1 shows a flow of a first embodiment of a method for creating a virtual machine, including steps S110 to S130.
For convenience of description, taking the first virtual machine as an example, the first virtual machine is any virtual machine to be created by the target machine.
S110: and loading the resource configuration file, the resource description file and the mirror image of the first virtual machine in the target machine.
The method comprises the steps that a resource configuration file and a resource description file of a first virtual machine are created on an offline host in advance, configuration information of hardware resources of the first virtual machine is defined through a configuration structure body, and the configuration information comprises information of the hardware resources of the first virtual machine in the resource description file of a target machine.
The hardware resources of the first virtual machine comprise independent hardware resources and virtual hardware resources, and the independent hardware resources of each virtual machine comprise independent CPU cores, independent memory intervals and physical equipment of the virtual machine, wherein the physical equipment is independent equipment of the virtual machine. The virtual hardware resources of each virtual machine correspond to the corresponding hardware resources of the target machine kernel. The hardware resources of the target machine core comprise a physical CPU core, a memory interval and physical equipment, wherein the physical equipment at least comprises an interrupt controller and equipment corresponding to each virtual machine sharing equipment.
The target machine and the offline host are different computer systems, and the target machine core is a hypervisor of the target machine, which is also called a hypervisor.
The resource description file of the target machine comprises a device tree or an APCI table of the target machine, wherein the device tree or the APCI table comprises detailed hardware resource description information of a related system, and the content is more. Illustratively, in the computing system of the ARM chip, the resource description file is a device tree thereof, the identifier of each hardware resource is a node identifier, and in the computing system of the x86 chip, the resource description file is an APCI table thereof, and the support UEFI (Unified Extensible Firmware Interface) directly reads the ACPI table from the BIOS. By the above, the resource description file includes the device tree or the APCI table, so that the present embodiment supports the target machines of multiple chips.
In some embodiments, hardware resources of the target machine are allocated to each virtual machine on the offline host according to the resource description file of the target machine, and a resource configuration file of the target machine, a resource configuration file of each virtual machine, and a resource description file are created accordingly. The resource allocation is carried out according to the resource description file of the target machine, and the resource configuration files of the target machine kernel and each virtual machine are created, so that the resource configuration files comprise all configuration information and can be directly configured on the bare machine to configure resources for the target machine kernel and each virtual machine.
In some embodiments, the step further loads a resource configuration file of the target kernel, where the resource configuration file of the target kernel is also created in advance on the offline host, and defines configuration information of hardware resources of the target kernel, including information of the hardware resources of the target kernel in the resource description file of the target
In some embodiments, the allocatable physical resources of the target machine are abstracted from the resource description file of the target machine; and distributing the allocatable hardware resources to the target machine kernel and each virtual machine according to the hardware resource requirements of each virtual machine to obtain resource information files of the target machine kernel and each virtual machine, wherein the resource information files of the virtual machine comprise the independent hardware resources and the identifiers of the resource description files of the virtual hardware resources in the target machine, and the resource information files of the target machine kernel comprise the identifiers of the resource description files of the hardware resources in the target machine. By the method, the resource information files of the target machine kernel and each virtual machine, which are obtained during resource allocation, only comprise the identification of the abstracted hardware resources, so that the resource configuration file is conveniently created according to the identification.
In some embodiments, a corresponding configuration structure body is constructed for each hardware resource in each resource information file of the target machine kernel and each virtual machine, and the configuration structure body of each hardware resource comprises description information corresponding to the configuration structure body in the resource description file of the target machine, so as to obtain the resource configuration files of the target machine kernel and each virtual machine; and adding an interrupt configuration structure body in each resource configuration file, wherein the interrupt configuration structure body of the target machine kernel comprises an interrupt number of a hardware resource of the target machine kernel, and the interrupt configuration structure body of each virtual machine comprises an independent hardware resource of the virtual machine and an interrupt number of the virtual hardware resource. In this way, the configuration structure of each hardware resource includes the detailed information of the hardware resource in the resource description file of the target machine, so that the configuration structure can be used for resource configuration on the bare machine.
In some embodiments, a resource description file of a target machine is copied for each virtual machine on an offline host, and unallocated hardware resources of the virtual machine in the copied resource description file are set to be in an invalid state according to the resource information file of the virtual machine, so as to obtain the resource description file of the virtual machine. By setting the hardware resources which are not included in the resource information file of the corresponding virtual machine in the copied resource description file to be in an invalid state, the resource description file of the virtual machine is accurately and quickly obtained.
In some embodiments, the resource configuration file of the target machine kernel further includes a mirror image of the target machine kernel and a loading address of the resource configuration file of each virtual machine, and the resource configuration file of each virtual machine further includes a mirror image of the virtual machine and a loading address of the resource description file.
S120: and configuring hardware resources of the first virtual machine according to the resource configuration file of the first virtual machine.
The resource configuration file of the first virtual machine is generated in advance, and hardware resources of the first virtual machine are configured according to the resource configuration file of the first virtual machine, so that resource consumption of resource virtualization of the first virtual machine is reduced similarly to configuration on a bare machine.
In some embodiments, the target kernel runs this step.
In some embodiments, the hardware resources of the target machine kernel are also configured according to the resource configuration file of the target machine kernel prior to configuring the hardware resources of the first virtual machine. By the method, the resource configuration file of the target machine core is generated in advance, and is configured on the bare machine, so that the resource consumption of the resource virtualization of the target machine core is reduced.
S130: and starting the mirror image of the first virtual machine by using the resource description file of the first virtual machine on the hardware resource of the first virtual machine so as to create the first virtual machine.
Wherein the hardware resources of each virtual machine comprise independent hardware resources of the virtual machine. The independent hardware resources of each virtual machine comprise independent CPU cores, independent memories and physical devices, and the virtual hardware resources of each virtual machine comprise virtual CPUs and virtual devices. When each virtual machine is started, the mirror image of the virtual machine is started on the unique physical CPU core, so that each virtual machine can be started on a bare machine similarly, and the starting instantaneity of each virtual machine is improved.
The resource description file of each virtual machine comprises a device tree or an APC I table of the virtual machine, and an operating system of the first virtual machine knows the hardware resources supported by the operating system through the resource description file.
In some embodiments, the target kernel runs this step. In some embodiments, the hardware resources of each virtual machine further include virtual resources thereof, corresponding to corresponding hardware resources in the target machine kernel, the virtual hardware resources of each virtual machine including a virtual CPU, a virtual device. Before the first virtual machine is created, the mirror image of the target machine kernel is started on the hardware resources of the target machine kernel which are configured in advance.
In summary, the embodiment of the method for creating the virtual machine on the target machine is applied to the creation of the virtual machine of the embedded target system, and the resource configuration file comprises the information of the hardware resources of the virtual machine in the resource description file of the target machine through the resource configuration file of the virtual machine, so that the resources of the virtual machine can be configured on the approximate bare machine and the virtual machine can be started, thereby realizing the creation of the virtual machine on a hardware platform with lower performance and occupying lower hardware resources, and reducing the resource consumption of the target machine.
A second embodiment of a method for creating a virtual machine according to the present invention is described below with reference to fig. 2.
The method of the first embodiment of the creation method embodiment of the virtual machine inherits the method of the second embodiment of the creation method of the virtual machine, has all advantages, and increases the virtual machine elastic expansion of the mode of starting the kernel of the target machine, running the operating system of the virtual machine and not stopping the machine.
For convenience of description, taking a first virtual machine and a second virtual machine as examples, the first virtual machine is a virtual machine started for the first time on the target machine, and the second virtual machine is any virtual machine that is to be restarted after the target machine runs the first virtual machine.
Fig. 2 shows a flow of a second embodiment of a method for creating a virtual machine, including steps S210 to S240.
S210: and loading the resource configuration file and the mirror image of the kernel of the target machine, and the resource configuration file and the mirror image and the resource description file of the first virtual machine in the target machine.
Each piece of hardware in the resource configuration files of the target machine kernel and the first virtual machine comprises information of the resource in the resource description file of the target machine through the resource configuration body, and the resource description file of the target machine comprises a device tree or an APC I table of the resource description file.
The method for creating the resource configuration file of the target machine kernel, the resource configuration file of each virtual machine and the resource description file refers to a method for generating a virtualization file in the second embodiment of the method for creating a virtual machine.
The resource configuration file of the target machine core comprises a mirror image of the target machine core and a loading address of the resource configuration file of the first virtual machine, and the resource configuration file of the first virtual machine comprises the mirror image and the loading address of the resource description file.
S220: and configuring hardware resources of the target machine core according to the resource configuration file of the target machine core, and starting the mirror image of the target machine core on the hardware resources to create the target machine core.
The hardware resources of the target machine core comprise a physical CPU core, a memory interval and physical equipment, and the physical equipment at least comprises an interrupt controller and equipment corresponding to each virtual machine sharing equipment.
Wherein the virtual machine kernel runs this step.
S230: and configuring hardware resources of the first virtual machine according to the resource configuration file of the first virtual machine, and starting the mirror image of the first virtual machine by utilizing the resource description file of the first virtual machine to create the first virtual machine.
The hardware resources of the first virtual machine comprise independent hardware resources and virtual hardware resources, and the independent hardware resources of each virtual machine comprise independent CPU cores, independent memory intervals and physical devices of the virtual machine. The virtual hardware resources of each virtual machine correspond to the corresponding hardware resources of the target machine kernel. The image of the first virtual machine is started at an independent CPU core of the first virtual machine.
Wherein the resource description file of the first virtual machine includes its device tree or its APC I table. When the chip of the target machine is an ARM SOC chip, the resource description file of each virtual machine is a device tree thereof. When the chip of the target machine is an x86 chip, the resource description file of each virtual machine has an APC I table.
Wherein the virtual machine kernel runs this step.
S240: after the first virtual machine is operated, the resource configuration file, the resource description file and the mirror image of the second virtual machine are loaded in the target machine, and the second virtual machine and the operating system for operating the second virtual machine are created according to the methods of the steps S230 and S240.
The resource configuration file of the target machine kernel contains information of the configuration number (config_max_vm_cfginfo) of the virtual machines, and when the number of the virtual machines of the target machine is smaller than the maximum support number in the actual use process, the resource configuration file and the resource description file of the virtual machines of the offline host machine can be obtained. When the resource configuration files of all the virtual machines are synthesized into one target machine configuration file, the resource configuration files are directly loaded into the target machine configuration file, and finally, the whole target machine configuration file can be updated in a covering mode.
Step S210 of this embodiment is invoked to load a file of the second virtual machine, where the resource configuration file of the second virtual machine includes a mirror image thereof and a loading address of the resource description file. The first virtual machine is not stopped in the loading process.
The step S230 of this embodiment is called to implement the creation of the second virtual machine, because the hardware resource of the second virtual machine is created on the bare metal machine according to the resource configuration file of the second virtual machine, and the second virtual machine is created according to the resource description file of the second virtual machine, and the first virtual machine is not stopped during the process of creating the second virtual machine.
In summary, the second embodiment of the method for creating a virtual machine inherits the first embodiment of the method for creating a virtual machine, which has all advantages, and adds a method for creating another virtual machine when the target machine runs, so as to realize the elastic expansion without stopping.
Fig. 3A shows a flow of a method for generating a virtualized file according to a second embodiment of a method for creating a virtual machine, including steps S310 to S350.
S310: and abstracting the allocable physical equipment of the target machine from the resource description file of the target machine to obtain the resource information file of the target machine.
The resource description file of the target machine is a device tree or an APCI table thereof.
The content of the resource information file of the target machine is concise and only comprises the identification of the hardware resource of the target machine, namely the identification of the CPU core, the memory space and the physical equipment of the target machine; the memory space is the identification of the memory, and each identification is the identification of the corresponding hardware resource in the resource information file of the target machine.
S320: and distributing relevant hardware resources in the resource information files of the target machine to the target machine cores and the virtual machines according to the hardware resource requirements of the target machine cores and the virtual machines, and obtaining the resource information files of the target machine cores and the virtual machines.
The allocation of the step realizes the isolation of independent resources of each virtual machine partition, and the virtual resources of each virtual machine partition share corresponding hardware resources in the target machine core.
Allocating the physical CPU core of the target machine to a designated virtual machine exclusive use or a plurality of virtual machines exclusive use;
allocating the appointed memory blocks in the memory of the target machine to the target machine kernel and the appointed virtual machine, namely allocating the memory for the target machine kernel and the appointed virtual machine;
the physical devices are assigned to a specific virtual machine or a plurality of virtual machine uses, and the physical devices assigned to the plurality of virtual machine uses are also assigned to target machine kernel management. And the physical devices are distributed to a plurality of virtual machines, the virtual devices are distributed to each virtual machine, and the devices are distributed to the cores of the target machines.
The resource information file of the target machine is regarded as a resource summary table, and the resource information files of the target machine kernel and each virtual machine are regarded as a resource sub-table, and the step is to divide a summary table into sub-tables.
The resource information file of the target machine core comprises an identifier of a physical CPU core, an internal memory section and an identifier of a physical device, the content is concise, each identifier corresponds to a corresponding hardware resource in the resource description file of the target machine, the physical device of the target machine core at least comprises an interrupt controller and a physical device corresponding to a virtual device of the virtual machine, in some possible embodiments, the physical device of the target machine core can also comprise a control and a physical timer, and the control is created based on serial uart.
The resource information file of each virtual machine comprises an identifier of a physical CPU core, an independent memory interval, a physical device identifier and a virtual device identifier, wherein the virtual device identifier corresponds to a corresponding physical device identifier in a core of the target machine, so that the hardware resource identifier of each virtual machine corresponds to a corresponding hardware resource in a resource description file of the target machine. The physical CPU core in each virtual machine comprises an independent CPU core and a virtual CPU core, the memory interval comprises an independent memory interval, the physical equipment of each virtual machine is exclusive equipment, and each virtual equipment corresponds to one physical equipment in the target machine core. The virtual device includes a virtual interrupt controller, and in some possible implementations, the virtual device further includes a virtual timer and a VPL011, where the VPL011 corresponds to a respective serial port of the target machine core.
The simple resource information files of the target machine kernel and each virtual machine are convenient for generating the virtualization files related to hardware resources, such as resource configuration files and resource description files.
FIG. 3B shows an example of resource allocation of the present embodiment, taking virtual machine vm1 and virtual machine vm2 as examples
The target machine core is distributed with CPU0-4, memory interval, interrupt controller GIC, peripheral serial port UART0, CPU0-4, interrupt controller GIC and peripheral serial port UART0.
The virtual machine vm1 is allocated with a CPU0-1, an independent memory interval, a peripheral Net1, a peripheral PCI1, and a USB, a virtual device vGIC, a virtual device VUART, interrupt controllers GIC of the cores of the target machine and a peripheral serial port UART0 corresponding to the virtual device vGIC and the virtual device VUART.
The virtual machine vm2 is allocated with a CPU2, an independent memory interval, a peripheral Net2, a peripheral UART1, a peripheral CAN1, a virtual device vGIC, a virtual device VUART, and interrupt controllers GIC and peripheral serial ports UART0 corresponding to the virtual device vGIC and the virtual device VUART.
S330: corresponding configuration structures are constructed for each hardware resource in each resource information file of the target machine kernel and each virtual machine, and description information of corresponding resource hardware sources in the resource description files of the target machine is added for each configuration structure, so that the resource configuration files of the target machine kernel and each virtual machine are obtained.
The resource configuration file of the target machine core comprises a physical CPU core, a memory, physical equipment and an interrupt configuration structure body, wherein peripheral equipment in all the physical equipment is defined in one configuration structure body, and an interrupt controller, a control and a physical timer of the target machine core are respectively defined in the respective configuration structure bodies. The configuration structure of the physical CPU core comprises an identification of the physical CPU core and a generated logic CPU core, the configuration structure of the memory comprises a starting address and a size of the memory, the configuration structure of the physical equipment at least comprises a physical address and a space size of each physical equipment on a target machine, and the configuration structure of the interrupt comprises an interrupt number of the physical equipment of the target machine core.
The resource configuration file of each virtual machine comprises a physical CPU core, a memory, a physical device, a virtual device and an interrupt configuration structure body, wherein the peripheral in the physical device of each virtual machine is defined in one configuration structure body, and the virtual interrupt controller, the VPL011 and the virtual timer of the virtual machine are respectively defined in the respective configuration structure bodies. The configuration structure of the physical CPU core of each virtual machine comprises an identification of the physical CPU core and a generated logic CPU core, the configuration structure of the memory of each virtual machine comprises a starting address and a size of the memory, the configuration structure of the physical equipment of each virtual machine at least comprises a physical address and a space size of each physical equipment on a target machine, and the interrupt configuration structure of each virtual machine comprises an interrupt number of the physical equipment of the virtual machine and an interrupt number of the virtual equipment.
S340: and copying a resource description file of a target machine for each virtual machine, and setting hardware resources which are not included in the resource information file of the virtual machine in the copied resource description file to be in an invalid state to obtain the resource description file of the virtual machine.
The content of the resource description file of the virtual machine obtained by copying and selecting is accurate.
The resource description file of each virtual machine is used for starting an operating system on the virtual machine, and is also a device tree or an APC I table of the virtual machine, and the content of the resource description file is directly from the resource description file of the target machine.
S350: the method comprises the steps of adding a mirror image of a target machine core and loading addresses of resource configuration files of virtual machines in a resource configuration file of the target machine core, and adding the mirror image of the virtual machine and the loading addresses of resource description files in the resource configuration file of each virtual machine.
By adding the loading address, the loading address of each file required by starting the target machine kernel and starting and running the virtual machine can be found according to the resource configuration file of the target machine kernel.
In summary, the method for generating a virtualization file in the second embodiment of the method for creating a virtual machine is used for generating a virtual file of a hardware resource on a target machine based on type1 virtualization on an offline host machine, so as to create the virtual machine on the target machine and run an embedded operating system, partition isolation of the hardware resource of the target machine is realized by distributing resources on the offline host machine through a concise resource information file, resource virtualization configuration is realized by combining the resource information file and a resource description file, the complexity of generating the resource configuration file of the virtual machine and the resource description file started by the virtual machine is simplified, and requirements on a configurator are reduced.
The following describes a specific implementation manner of a method for generating a virtualized file in a virtual machine according to a second embodiment of a method for creating a virtual machine with reference to fig. 4A to fig. 4F, where a specific method for generating a hardware resource virtualized file on a target machine based on an ARM chip virtualized by type1 on an offline host machine, where a resource description file is a device tree file.
Fig. 4A shows a flow of a specific implementation manner of a virtualized file generation method of a creation method embodiment two of a virtual machine, including steps S410 to S450.
S410: and abstracting the device tree file of the target machine to obtain a resource information file hwi nfo.json of the target machine.
Wherein fig. 4B shows the procedure of this step, taking as input the device tree file of the target machine (·dts); and acquiring equipment node information of the target machine to form a dts.json file, and extracting equipment nodes for hardware resource allocation to form a resource information file hwi nfo.json of the target machine. The format is as follows:
/>
the cpu_id_list comprises a physical CPU core of the target machine, the mem_blk_list comprises a memory section of the target machine, and the dev_list comprises a device node identifier in a device tree of the target machine.
S420: and distributing relevant hardware resources in a resource information file hwinfo.json of the target machine to the target machine kernel and each virtual machine according to the hardware requirements of the target machine and the virtual machine to obtain resource information files hwinfo_hyper.json, hwinfo_vm1.json and hwinfo_vm2.json of the target machine kernel, the virtual machine vm1 and the virtual machine vm2.
Fig. 4C shows a schematic diagram of the resource allocation process in this step, where the hardware requirements of the target machine and the virtual machine are in devlist. Json, and the hardware resource allocation tool of the target machine uses hwinfo. Json as a hardware resource pool to create a hardware resource partition of the target machine kernel hyper, the virtual machine vm1, the virtual machine vm2, and …; and distributing the hardware nodes to the target machine kernel hyper, the virtual machine vm1 and the virtual machines vm2 and … to form corresponding resource information files hwinfo_hyper. Json, hwinfo_vm1.Json and hwinfo_vm2.Json and ….
The hardware resource allocation rule comprises the following steps:
(1) Resource allocation requirements of the target kernel: all physical CPU core information of the target machine, independent memory information, interrupt controller and debug serial port [ optional ];
(2) Virtual machine resource allocation requirements: physical cpu and number (all vm memory and less than total physical memory), independent memory size (all vm memory and less than total physical memory), virtual device (vGIC, vtimer, vpl011 etc.), peripheral (serial port, network card, can, pci, …).
When the hardware allocation tool allocates the virtual device of the virtual machine, a virtual interrupt controller vGIC, a virtual timer vtimer, a virtual port vpl011 and the like are allocated to the virtual machine, and are provided by the target machine kernel on the target machine. The virtual device allocation rules include:
(1) The vGIC version is consistent with the physical GIC version, and the vGIC address space is also consistent with the physical GIC address space;
(2) vpl011, vpl, 57011 is DEBUG terminal function (CONFIG_DEBUG_CONSOLE) configured by the hypervisor system;
(3) The vtimer information is consistent with the physical timer information (including the interrupt number).
The format of the resource information file of the virtual machine is as follows:
the cpu_id_list comprises a physical CPU core of the virtual machine, the mem_blk_list comprises a memory section of the virtual machine, the dev_list comprises an identifier of a physical device of the virtual machine, and the vdev_list corresponds to a GIC, timer, UART physical device of the target machine core.
S430: and constructing a corresponding configuration structure body according to each hardware resource in the resource description files of the target machine kernel, the virtual machine vm1 and the virtual machine vm2, and adding the corresponding resource description message as configuration information to obtain resource configuration files hyper.cfgdata, vm1.cfgdata and vm2.cfgdata of the target machine kernel, the virtual machine vm1 and the virtual machine vm2.
The configuration structure of each resource is as follows.
/>
Fig. 4D shows a process of obtaining a resource configuration file, where information such as a cpu id, an address space, and an interrupt of a corresponding node in the device tree is obtained through node identifiers in resource description files of the target machine kernel, the virtual machine vm1, and the virtual machine vm2, and the obtained information is added to a corresponding structure body according to the node identifiers.
The generation rule of the resource configuration file comprises the following steps:
generating struct cpu_info by physical cpu core information;
independent memory information is generated into struct mem_info;
the physical device information generates structdev info,
virtual device information generation struct vdev_info;
devices (including virtual devices and physical devices) use the interrupt information to generate struct hirq_info information.
S440: and obtaining the device tree files vm1.Dts and vm2.Dts of the virtual machine vm1 and the virtual machine vm2 according to the resource information files of the virtual machine vm1 and the virtual machine vm2 and the device tree files of the target machine.
Wherein FIG. 4E illustrates a process of obtaining a device tree file for a virtual machine, the virtual device tree generation comprising one of:
mode 1: and searching the description information of the corresponding equipment nodes in the equipment tree of the target machine according to the equipment node information in the hardware information file of the virtual machine, and writing the description information into the equipment tree file of the virtual machine.
Mode 2: and acquiring the equipment tree file of the target machine, enabling all peripheral nodes to be disabled, searching corresponding equipment nodes in the copied equipment tree of the target machine according to the equipment node identification in the hardware information file of the virtual machine, and changing the node state by a bit 'okay' to generate the equipment tree file of the virtual machine.
Wherein the device tree generation rule includes:
(1) The virtual device IPA address space of the virtual machine device tree is consistent with the physical address space of the target machine kernel using the same type of device.
(2) The vGICs of the virtual machine device tree are consistent with the target machine kernel using the physical GIC address space
(3) The virtual machine device tree's virtual art is consistent with the target machine kernel's use of the physical art address space
(4) The vtimer of the virtual machine device tree is consistent with the timer configuration information used by the target machine kernel).
S450: adding the mirror image of the target machine kernel and the loading address of the resource configuration file of each virtual machine in the resource configuration file of the target machine kernel, and adding the mirror image of each virtual machine and the loading address of the resource description file in the resource configuration file of each virtual machine.
FIG. 4F illustrates the load address pointing of each file in the resource configuration file hyper.cfgdata and virtual machine vmx.cfgdata of the target machine kernel, the virtual machine vmx.cfgdata also including the load addresses of other additional files, such as randisk, ttos, and other files.
In summary, the method for generating a virtualization file in the second embodiment of the method for creating a virtual machine is used for generating a virtual file of a hardware resource on a target machine based on type1 virtualization on an offline host machine, so as to create the virtual machine on the target machine and run an embedded operating system, partition isolation of the hardware resource of the target machine is realized by distributing resources on the offline host machine through a concise resource information file, resource virtualization configuration is realized by combining the resource information file and a resource description file, the complexity of generating the resource configuration file of the virtual machine and the resource description file started by the virtual machine is simplified, and requirements on a configurator are reduced.
An embodiment of a virtual machine creation apparatus according to the present invention will be described below based on fig. 5.
An embodiment of a virtual machine creation device, an embodiment of a virtual machine creation method, and an embodiment of the method have all the advantages.
Fig. 5 shows a structure of a first embodiment of a creation apparatus of a virtual machine, including: a file loading module 510, a virtual machine resource configuration module 520, and a virtual machine creation module 530.
The file loading module 510 is configured to load the resource configuration file, the resource description file, and the image of the first virtual machine in the target machine. For its working principle and advantages, please refer to step S110 of a virtual machine creation method embodiment one.
The virtual machine resource configuration module 520 is configured to configure hardware resources of the first virtual machine according to the resource configuration file of the first virtual machine. For its working principle and advantages, please refer to step S120 of a virtual machine creation method embodiment one.
The virtual machine creation module 530 is configured to create a first virtual machine by starting an image of the first virtual machine on a hardware resource of the first virtual machine using a resource description file of the first virtual machine. For its working principle and advantages, please refer to step S130 of a first embodiment of a method for creating a virtual machine.
A second embodiment of a virtual machine creation apparatus according to the present invention is described below based on fig. 6.
The second embodiment of the virtual machine creating device runs the second embodiment of the virtual machine creating method, and has all the advantages.
Fig. 6 shows a structure of a second embodiment of a creating apparatus of a virtual machine, including: a file loading module 610, a kernel starting module 620, a virtual machine creating module 630, and a virtual machine expanding module 640.
The file loading module 610 is configured to load, in the target machine, a resource configuration file and an image of the kernel of the target machine, and a resource configuration file and an image of the first virtual machine, and a resource description file. For the working principle and advantages, please refer to step S210 of the second embodiment of the method for creating a virtual machine.
The kernel initiation module 620 is configured to configure hardware resources of the target kernel according to the resource configuration file of the target kernel, and initiate a mirror image of the target kernel thereon to create the target kernel. For the working principle and advantages, please refer to step S220 of the second embodiment of the method for creating a virtual machine.
The virtual machine creation module 630 is configured to configure hardware resources of the first virtual machine according to the resource configuration file of the first virtual machine, and start an image of the first virtual machine according to the resource description file of the first virtual machine to create the first virtual machine. For the working principle and advantages, please refer to step S230 of the second embodiment of the method for creating a virtual machine.
The virtual machine capacity expansion module 640 is configured to load a resource configuration file, a resource description file and a mirror image of the second virtual machine in the target machine after the first virtual machine is operated, and sequentially operate the mirror image of the second virtual machine according to the resource configuration file and operate an operating system of the second virtual machine according to the resource description file. For the working principle and advantages, please refer to step S240 of the second embodiment of the method for creating a virtual machine.
An embodiment of a virtualized file generation device for a virtual machine according to the present invention is described below based on fig. 7.
The virtual file generation method of the second virtual machine creation method embodiment has all advantages.
Fig. 7 shows a structure of an embodiment of a virtualized file generation device of a virtual machine, including: a resource abstraction module 710, a resource allocation module 720, a configuration generation module 730, a description generation module 740, and an address addition module 750.
The resource abstraction module 710 is configured to abstract the assignable physical device of the target machine from the resource description file of the target machine, and obtain the resource information file of the target machine. For its principle and advantage, please refer to step S310 of a method for generating a virtualized file in the second embodiment of a method for creating a virtual machine.
The resource allocation module 720 is configured to allocate related hardware resources in the resource information file of the target machine to the target machine core and each virtual machine according to the hardware resource requirements of the target machine core and each virtual machine, so as to obtain the resource information file of the target machine core and each virtual machine. For its principle and advantage, please refer to step S320 of a method for generating a virtualized file in the second embodiment of a method for creating a virtual machine.
The configuration generating module 730 is configured to construct a corresponding configuration structure for each hardware resource in each resource information file of the target machine kernel and each virtual machine, and add a description message of the corresponding resource hardware source in the resource description file of the target machine for each configuration structure to obtain the resource configuration files of the target machine kernel and each virtual machine. For its principle and advantage, please refer to step S330 of the virtualized file generation method of the second embodiment of the creation method of the virtual machine.
The description generating module 740 is configured to copy, for each virtual machine, a resource description file of a target machine, set a hardware resource that is not included in the resource information file of the virtual machine in the copied resource description file to an invalid state, and obtain the resource description file of the virtual machine. For its principle and advantage, please refer to step S340 of the virtualized file generation method of the second embodiment of the creation method of the virtual machine.
The address adding module 750 is configured to add, to a resource configuration file of the target machine kernel, a mirror image of the target machine kernel and a loading address of a resource configuration file of each virtual machine, and add, to a resource configuration file of each virtual machine, a mirror image of the virtual machine and a loading address of a resource description file. For its principle and advantage, please refer to step S350 of a method for generating a virtualized file in the second embodiment of a method for creating a virtual machine.
An embodiment of the present invention also provides a computing device, described in detail below with respect to fig. 8.
The computing device 800 includes a processor 810, a memory 820, a communication interface 830, a bus 840.
It should be appreciated that the communication interface 830 in the computing device 800 shown in this figure may be used to communicate with other devices.
Wherein the processor 810 may be coupled to the memory 820. The memory 820 may be used to store the program code and data. Accordingly, the memory 820 may be a storage unit internal to the processor 810, an external storage unit independent of the processor 810, or a component including a storage unit internal to the processor 810 and an external storage unit independent of the processor 810.
Optionally, computing device 800 may also include a bus 840. The memory 820 and the communication interface 830 may be connected to the processor 810 through a bus 840. Bus 840 may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (EFStended Industry Standard Architecture, EISA) bus, among others. The bus 840 may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one line is shown in the figure, but not only one bus or one type of bus.
It should be appreciated that in embodiments of the present invention, the processor 810 may employ a central processing unit (central processing unit, CPU). The processor may also be other general purpose processors, digital signal processors (digital signal processor, DSP), application specific integrated circuits (application specific integrated circuit, ASIC), off-the-shelf programmable gate arrays (field programmable gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. Or the processor 810 may employ one or more integrated circuits for executing associated routines to implement the techniques provided by embodiments of the present invention.
The memory 820 may include read only memory and random access memory and provides instructions and data to the processor 810. A portion of the processor 810 may also include non-volatile random access memory. For example, the processor 810 may also store information of the device type.
When the computing device 800 is running, the processor 810 executes computer-executable instructions in the memory 820 to perform the operational steps of the various method embodiments.
It should be understood that the computing device 800 according to the embodiments of the present invention may correspond to a respective subject performing the methods according to the embodiments of the present invention, and that the above and other operations and/or functions of the respective modules in the computing device 800 are respectively for implementing the respective flows of the methods according to the embodiments of the present method, and are not repeated herein for brevity.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, and are not repeated herein.
In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the method embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the decoding method according to the embodiments of the present invention. The storage medium includes various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk.
The embodiments of the present invention also provide a computer-readable storage medium having stored thereon a computer program for performing the operational steps of the method embodiments when executed by a processor.
The computer storage media of embodiments of the invention may take the form of any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium include 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
Note that the above is only a preferred embodiment of the present invention and the technical principle applied. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, while the invention has been described in connection with the above embodiments, the invention is not limited to the above embodiments, but may include many other equivalent embodiments without departing from the spirit of the invention, which fall within the scope of the invention.

Claims (13)

1. A method for creating a virtual machine, comprising:
configuring hardware resources of the first virtual machine according to the resource configuration file of the first virtual machine, wherein the resource configuration file of each virtual machine is created on an offline host machine and comprises configuration information of the hardware resources of the virtual machine in the resource description file of the target machine;
the method comprises the steps of starting an image of a first virtual machine on hardware resources of the first virtual machine by using a resource description file of the first virtual machine to create the first virtual machine, wherein the resource description file of each virtual machine is created on an offline host.
2. The method of claim 1, wherein the hardware resources of each virtual machine comprise independent hardware resources of the virtual machine, the independent hardware resources comprising independent CPU cores, independent memory intervals, physical devices of the virtual machine.
3. The method of claim 2, wherein the hardware resources of each virtual machine further comprise virtual hardware resources of the virtual machine, the virtual hardware resources corresponding to corresponding hardware resources in the target machine kernel;
before configuring the hardware resources of the first virtual machine, further comprising: and configuring hardware resources of the target machine core according to the resource configuration file of the target machine core, starting the mirror image of the target machine core on the hardware resources, wherein the resource configuration file of the target machine core is created on the offline host and comprises configuration information of the hardware resources of the target machine core in the resource description file of the target machine.
4. The method of claim 3, wherein the resource configuration file of the target machine core further comprises a mirror image of the target machine core and a loading address of the resource configuration file of each virtual machine;
the resource configuration file for each virtual machine also includes the image of the virtual machine and the loading address of the resource description file.
5. The method of claim 1, wherein when the first virtual machine has created and the second virtual machine has been created, further comprising:
loading a resource configuration file, a resource description file and a mirror image of the second virtual machine;
and configuring the hardware resources of the second virtual machine according to the resource configuration file of the second virtual machine, and starting the mirror image of the second virtual machine on the independent hardware resources of the second virtual machine by utilizing the resource description file of the second virtual machine.
6. A method according to claim 3, further comprising:
and on the offline host, distributing the hardware resources of the target machine to the target machine and each virtual machine according to the resource description file of the target machine, and creating the resource configuration file of the target machine, the resource configuration file of each virtual machine and the resource description file.
7. The method of claim 6, wherein the allocating hardware resources of the target machine to the target machine and each virtual machine according to the resource description file of the target machine comprises:
abstracting the allocable physical resources of the target machine from the resource description file of the target machine;
and distributing the distributable hardware resources to the target machine core and each virtual machine according to the hardware resource requirements of the target machine core and each virtual machine to obtain resource information files of the target machine core and each virtual machine, wherein the resource information files of the virtual machine comprise the independent hardware resources and the identifiers of the resource description files of the virtual hardware resources in the target machine, and the resource information files of the target machine core comprise the identifiers of the resource description files of the hardware resources in the target machine.
8. The method of claim 7, wherein creating the resource profile for the target machine kernel and each virtual machine comprises:
constructing corresponding configuration structures for each hardware resource in each resource information file of the target machine kernel and each virtual machine, and obtaining resource configuration files of the target machine kernel and each virtual machine when the configuration structures of each hardware resource comprise corresponding description messages in the resource description files of the target machine;
and adding an interrupt configuration structure body in each resource configuration file, wherein the interrupt configuration structure body of the target machine kernel comprises an interrupt number of a hardware resource of the target machine kernel, and the interrupt configuration structure body of each virtual machine comprises an independent hardware resource of the virtual machine and an interrupt number of the virtual hardware resource.
9. The method of claim 7, wherein creating a resource description file for each virtual machine comprises:
and copying a resource description file of a target machine for each virtual machine, and setting unassigned hardware resources of the virtual machine in the copied resource description file to be in an invalid state according to the resource information file of the virtual machine to obtain the resource description file of the virtual machine.
10. The method of claim 1, wherein each resource description file comprises a device tree or an APC I table.
11. A virtual machine creation apparatus, comprising:
the virtual machine resource configuration module is used for configuring the hardware resources of the first virtual machine according to the resource configuration files of the first virtual machine, wherein the resource configuration file of each virtual machine is created on the offline host machine and comprises the configuration information of the hardware resources of the virtual machine in the resource description file of the target machine;
the virtual machine creation module is used for starting the mirror image of the first virtual machine by utilizing the resource description file of the first virtual machine on the hardware resource of the first virtual machine so as to create the first virtual machine, and the resource description file of each virtual machine is created on the offline host.
12. A computing device, comprising:
a bus;
a communication interface connected to the bus;
at least one processor coupled to the bus;
and at least one memory coupled to the bus and storing program instructions that, when executed by the at least one processor, cause the at least one processor to perform the method of any of claims 1 to 10.
13. A computer readable storage medium, characterized in that it has stored thereon program instructions, which when executed by a computer, cause the computer to perform the method of any of claims 1 to 10.
CN202311758384.9A 2023-12-19 2023-12-19 Virtual machine creation method, device, equipment and storage medium Pending CN117742890A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311758384.9A CN117742890A (en) 2023-12-19 2023-12-19 Virtual machine creation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311758384.9A CN117742890A (en) 2023-12-19 2023-12-19 Virtual machine creation method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117742890A true CN117742890A (en) 2024-03-22

Family

ID=90278877

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311758384.9A Pending CN117742890A (en) 2023-12-19 2023-12-19 Virtual machine creation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117742890A (en)

Similar Documents

Publication Publication Date Title
RU2639693C1 (en) Method for resource processing, operating system and device
EP2847669B1 (en) Hybrid operating system
US8578369B2 (en) Managing memory in multiple virtual machines
US10025503B2 (en) Autonomous dynamic optimization of platform resources
TWI512479B (en) Assigning processors to memory mapped configuration
CN110704155A (en) Container network construction method and device, physical host and data transmission method
US9009703B2 (en) Sharing reconfigurable computing devices between workloads
CN106537336B (en) Cloud firmware
JP2016541072A5 (en)
KR101401523B1 (en) A coarse-grained sharing gpu scheduling method and apparatus among virtual machines
US20150095607A1 (en) Verification of dynamic logical partitioning
US10719333B2 (en) BIOS startup method and apparatus
US10838861B1 (en) Distribution of memory address resources to bus devices in a multi-processor computing system
TW201319827A (en) Method for executing multiple operating systems and electronic apparatus
CN116249962A (en) Pool management for in-vehicle device application launch
KR101765723B1 (en) apparatus and method for interaction between a coarse-grained GPU resource scheduler and a GPU aware scheduler
CN116028164B (en) Equipment virtualization method and device
US20140304495A1 (en) System and method for expediting virtual i/o server (vios) boot time in a virtual computing environment
CN117742890A (en) Virtual machine creation method, device, equipment and storage medium
US11372792B1 (en) Automatic bus resource adjustment in a multiple root bridge computing system
US20190278714A1 (en) System and method for memory access latency values in a virtual machine
CN103106084A (en) Method for executing multiple operating systems and electronic device
JP6035993B2 (en) Information processing apparatus, apparatus management method, and apparatus management program
US8799616B2 (en) Method and system for preferred CPU binding on virtual partitions
CN117742962A (en) Virtual machine resource management method, device, equipment and storage medium

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