Virtual machine configuration method, device and storage medium
The virtual machine monitor image and virtual machine domain image are loaded through the boot program, and the processor core is started in parallel, which solves the problem of slow virtual machine startup, realizes parallel startup of multiple virtual machines, shortens the operating system startup time, and improves the system security and reliability.
Patent Information
- Application Number
- CN202111624261.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2041-12-28
AI Technical Summary
The problem of slow startup of multiple virtual machines during the virtual machine configuration process has not been effectively resolved.
The virtual machine monitor image and multiple virtual machine domain images are loaded through the boot program, and resources are allocated to them. Multiple virtual machine domain images are started in parallel according to the resources of each virtual machine domain image, and the processing core corresponding to the processor is started in parallel using a preset startup method.
The parallel startup of multiple virtual machines is achieved, which significantly shortens the operating system startup time, simplifies the complexity of functional safety authentication, avoids the impact of single point failure, and improves the security and reliability of the system.
Smart Images

Figure CN114385313B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology applications, and in particular to a virtual machine configuration method, device, and storage medium. Background Art
[0002] In related technologies, a virtual machine (VM) refers to a complete computer system that is simulated by software and has complete hardware system functions, running in a completely isolated environment. Any work that can be completed in a physical computer can also be achieved in a VM.
[0003] The application of virtual machines enables multiple virtual machine devices to run on the same computer device, greatly expanding the application scope of computers and making the computer's functions more diversely adaptable to various scenarios.
[0004] However, due to the configuration characteristics of virtual machines in related technologies, there is no solution to the problem of slow startup of multiple virtual machines. Summary of the Invention
[0005] To overcome the problems existing in the related art, the present application provides a virtual machine configuration method, device and storage medium.
[0006] According to the first aspect of an embodiment of the present application, a virtual machine configuration method is provided, including: loading a virtual machine monitor image and multiple virtual machine domain images through a boot program; starting the virtual machine monitor image and allocating resources to the multiple virtual machine domain images; and starting the multiple virtual machine domain images in parallel based on the resources of each virtual machine domain image.
[0007] Optionally, loading the virtual machine monitor image and multiple virtual machine domain images through the boot program includes: loading the virtual machine monitor image and multiple virtual machine domain images to the system's storage medium through the boot program; and verifying the signatures of the virtual machine monitor image and multiple virtual machine domain images.
[0008] Optionally, the virtual machine monitor image includes: a resource configuration file.
[0009] Furthermore, optionally, starting the virtual machine monitor image and allocating resources to multiple virtual machine domain images includes: starting the virtual machine monitor image, obtaining resources corresponding to the virtual machine monitor image and multiple virtual machine domain images from a resource configuration file, wherein the resources include: at least one of the memory space of the virtual machine monitor, virtual input and output backend services, memory resources corresponding to the virtual machine domain image, and input and output resources.
[0010] Optionally, the method further includes: configuring the virtual input / output backend service in the virtual machine monitor image, wherein the address space of the virtual input / output backend service is a separate address space.
[0011] Optionally, starting multiple virtual machine domain images in parallel based on resources of each virtual machine domain image includes: starting processing cores corresponding to processors in parallel based on resources of each virtual machine domain image and a preset startup mode initiated by a processor in each virtual machine domain image.
[0012] Further, optionally, starting the processing core corresponding to the processor includes: when the processing core is in a waiting state, sending an interrupt wake-up to the processing core in the virtual machine domain image according to a preset order through the virtual machine monitor image, and starting the virtual machine domain image in parallel.
[0013] According to the second aspect of an embodiment of the present application, a virtual machine configuration device is provided, including: a loading module for loading a virtual machine monitor image and multiple virtual machine domain images through a boot program; an allocation module for starting the virtual machine monitor image and allocating resources to multiple virtual machine domain images; and a startup module for starting multiple virtual machine domain images in parallel based on the resources of each virtual machine domain image.
[0014] According to a third aspect of an embodiment of the present application, a virtual machine configuration device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured as the above method.
[0015] According to the fourth aspect of the embodiment of the present application, a non-temporary computer-readable storage medium is provided. When the instructions in the non-temporary computer-readable storage medium are executed by the processor of the mobile terminal, the mobile terminal is enabled to execute a virtual machine configuration method, which includes the above-mentioned method.
[0016] The technical solution provided by the embodiments of the present application may include the following beneficial effects: loading a virtual machine monitor image and multiple virtual machine domain images through a boot program; starting the virtual machine monitor image and allocating resources to multiple virtual machine domain images; starting multiple virtual machine domain images in parallel based on the resources of each virtual machine domain image. The technical solution provided by the embodiments of the present application realizes the parallel startup of multiple virtual machines, greatly shortening the startup time of the operating system.
[0017] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0019] Figure 1 The figure is a flowchart showing a method for configuring a virtual machine according to an exemplary embodiment.
[0020] Figure 2 The figure is a schematic diagram showing another virtual machine configuration method according to an exemplary embodiment.
[0021] Figure 3 The figure is a schematic diagram showing a device for configuring a virtual machine according to an exemplary embodiment. DETAILED DESCRIPTION
[0022] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0023] Example 1
[0024] According to a first aspect of an embodiment of the present application, a virtual machine configuration method is provided. Figure 1 FIG. 1 is a flow chart showing a method for configuring a virtual machine according to an exemplary embodiment. Figure 1 As shown, the virtual machine configuration method is used in a terminal and includes the following steps.
[0025] In step S102, a virtual machine monitor image and multiple virtual machine domain images are loaded through a boot program;
[0026] In the above step S102 of the present application, the boot program may include: uboot or BIOS, wherein uboot is a boot loader mainly used for embedded systems and can support a variety of different computer system structures; BIOS is Basic Input Output System, basic input and output system;
[0027] The virtual machine monitor image in the embodiment of the present application can be recorded as a Hypervisor image; multiple virtual machine domain images can be recorded as VM Domain images.
[0028] The reason why the virtual machine configuration method provided in the embodiment of the present application can realize the rapid startup of multiple virtual machines in parallel is that by loading the virtual machine monitor Hypervisor image and multiple virtual machine domain VM Domain images into uboot or BIOS during virtual machine configuration, the hypervisor runs as the virtual input and output end virtIO backend without relying on any operating system (OS) inside the domain. When the OS inside the domain is started, it can communicate with the virtIO backend.
[0029] Specifically, loading the virtual machine monitor image and multiple virtual machine domain images through the boot program in step S102 includes: loading the virtual machine monitor image and multiple virtual machine domain images to the storage medium of the system through the boot program; and verifying the signatures of the virtual machine monitor image and multiple virtual machine domain images.
[0030] The storage medium in the embodiment of the present application may be a memory. Figure 2 is a schematic diagram showing another virtual machine configuration method according to an exemplary embodiment. Figure 2 As shown in the figure, the main CPU loads the hypervisor image and multiple virtual machine domain images into the memory through uboot or BIOS and verifies the signature. After the signature verification is passed, it enters the hypervisor image.
[0031] In the embodiment of the present application, the virtual machine monitor image includes: a resource configuration file. That is, Figure 2 As shown, a resource configuration file is set in the Hypervisor image.
[0032] In step S104, the virtual machine monitor image is started, and resources are allocated to the multiple virtual machine domain images;
[0033] In the above step S104 of the present application, based on the resource configuration file in the virtual machine monitor image in step S102, the Hypervisor image is started, the global resources of the Hypervisor are initialized, and resources are allocated to multiple virtual machine domain VM Domain images.
[0034] Furthermore, optionally, starting the virtual machine monitor image in step S104 and allocating resources to multiple virtual machine domain images includes: starting the virtual machine monitor image, obtaining resources corresponding to the virtual machine monitor image and multiple virtual machine domain images from a resource configuration file, wherein the resources include: at least one of the memory space of the virtual machine monitor, virtual input and output backend services, memory resources corresponding to the virtual machine domain image, and input and output resources.
[0035] Specifically, such as Figure 2 As shown, the main CPU initializes the global resources of the Hypervisor, such as the memory space of the Hypervisor itself, the virtIO back-end service (i.e., the virtual input and output back-end service in the embodiment of the present application); and the CPU of this Domain (i.e., the memory resources corresponding to the virtual machine domain image in the embodiment of the present application), memory (i.e., the memory space of the virtual machine monitor in the embodiment of the present application), IO (i.e., the input and output resources in the embodiment of the present application) and other resources. These resources are obtained through the configuration file.
[0036] Optionally, the virtual machine configuration method provided in the embodiment of the present application further includes: configuring the virtual input / output backend service in the virtual machine monitor image, wherein the address space of the virtual input / output backend service is a separate address space.
[0037] Among them, the virtual input and output backend service is recorded as virtIO backend service, such as Figure 2 As shown in the figure, since the virtIO backend service is configured in the Hypervisor image, the address space of the virtIO backend service is a separate address space, and the virtIO backend service does not rely on any domain and runs on the Hypervisor. The address space of virtIO is isolated from the other functional address spaces of the Hypervisor.
[0038] In step S106 , multiple virtual machine domain images are started in parallel based on the resources of each virtual machine domain image.
[0039] In the above step S106 of the present application, based on the resources of each virtual machine domain (VM Domain) mirror in step S104, the main CPU in each VM Domain initializes the VM Domain resources, such as Stage2 page table, interrupt and IO resources, and finally each VM Domain is started in parallel.
[0040] Specifically, starting multiple virtual machine domain images in parallel based on the resources of each virtual machine domain image in step S106 includes: starting processing cores corresponding to the processors in parallel based on the resources of each virtual machine domain image and the preset startup mode initiated by the processors in each virtual machine domain image.
[0041] Furthermore, starting the processing cores corresponding to the processors in parallel includes: when the processing cores are in a waiting state, sending an interrupt wakeup to the processing cores in the virtual machine domain image according to a preset order through the virtual machine monitor image, and starting the virtual machine domain image in parallel.
[0042] Among them, the preset startup mode in the embodiment of the present application can be a Symmetrical Multi-Processing (SMP) startup mode.
[0043] In the embodiment of the present application, in step S106, multiple virtual machine domain images are started in parallel based on the resources of each virtual machine domain image. The implementation is as follows:
[0044] The main CPU pulls up all the slave cores (i.e., the processing cores in the embodiment of the present application) in sequence (i.e., the preset order in the embodiment of the present application). After the slave core is started, the main CPU core of each domain initializes the resources of the domain, such as the Stage2 page table, interrupts and IO resources. Different from the existing technology, in the embodiment of the present application, since there is no role of Domain0, even if Domain0 hangs up, it will not affect other domains. Therefore, the virtual machine configuration method provided in the embodiment of the present application does not rely on the main CPU0 of the first Domain0.
[0045] All other slave cores enter a low-power state (wait for interrupt, WFI). After the master CPU0 of each domain is initialized, it jumps to the entry address of its respective domain. Other slave CPUs enter the WFI idle state.
[0046] like Figure 2 As shown in the figure, after each domain's master CPU enters its respective Domain0 (the entry address is defined in the resource configuration file), it sequentially launches slave cores through the SMP boot method. The process of launching slave cores involves each domain's master CPU core trapping it to the hypervisor, sending an interrupt to the slave core within the domain to wake it up, and each slave core initializes and enters its own domain. The trap command allows users to specify Linux signals that the shell script should monitor and intercept. The format of the trap command is: trap commands signals.
[0047] In the virtual machine configuration method provided in the embodiment of the present application, during the startup process, for shared devices, the hypervisor runs as the virtIO backend, does not rely on any OS within the domain, and can communicate with the virtIO backend after the OS within the domain is started.
[0048] In summary, the virtual machine configuration method provided in the embodiment of the present application realizes the parallel startup of multiple VMs, greatly shortens the OS startup time, and the startup time of the VM Domain is in milliseconds, which meets the Safety and Security requirements, simplifies the complexity of functional safety certification, avoids the impact of single point failure, and effectively isolates the impact range of erroneous failures.
[0049] The technical solution provided by the embodiment of the present application loads a virtual machine monitor image and multiple virtual machine domain images through a boot program; starts the virtual machine monitor image and allocates resources to multiple virtual machine domain images; and starts multiple virtual machine domain images in parallel based on the resources of each virtual machine domain image. The technical solution provided by the embodiment of the present application realizes the parallel startup of multiple virtual machines, greatly shortening the operating system startup time.
[0050] Example 2
[0051] According to a second aspect of an embodiment of the present application, a virtual machine configuration device is provided. Figure 3 FIG. 1 is a schematic diagram showing a virtual machine configuration device according to an exemplary embodiment. Figure 3 The device includes: a loading module 32, an allocation module 34 and a startup module 36.
[0052] The loading module 32 is configured to load the virtual machine monitor image and multiple virtual machine domain images through a boot program;
[0053] The allocation module 34 is configured to start the virtual machine monitor image and allocate resources to the multiple virtual machine domain images;
[0054] The startup module 36 is configured to start multiple virtual machine domain images in parallel based on the resources of each virtual machine domain image.
[0055] Optionally, the loading module 32 includes: a loading unit configured to load the virtual machine monitor image and multiple virtual machine domain images into the system's storage medium through a boot program; and a signature verification unit configured to verify the virtual machine monitor image and multiple virtual machine domain images.
[0056] Optionally, the virtual machine monitor image includes: a resource configuration file.
[0057] Further, optionally, the allocation module 34 includes: an allocation unit, configured to start the virtual machine monitor image, obtain resources corresponding to the virtual machine monitor image and multiple virtual machine domain images from a resource configuration file, wherein the resources include: the memory space of the virtual machine monitor, the virtual input and output backend service, the memory resources corresponding to the virtual machine domain image, and at least one of the input and output resources.
[0058] Optionally, the virtual machine configuration device provided in the embodiment of the present application further includes: a configuration module configured to configure the virtual input and output backend service in the virtual machine monitor image, wherein the address space of the virtual input and output backend service is a separate address space.
[0059] Optionally, the startup module 36 includes: a startup unit configured to start processing cores corresponding to the processors in parallel according to resources of each virtual machine domain image and a preset startup mode initiated by the processor in each virtual machine domain image.
[0060] Further, optionally, the startup unit includes: a startup subunit, which is used to send an interrupt wake-up to the processing core in the virtual machine domain image according to a preset order through the virtual machine monitor image when the processing core is in a waiting state, and start the virtual machine domain image in parallel.
[0061] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0062] Example 3
[0063] According to a third aspect of an embodiment of the present application, a virtual machine configuration device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured as the method in the above-mentioned embodiment 1.
[0064] Example 4
[0065] According to the fourth aspect of the embodiments of the present application, a non-temporary computer-readable storage medium is provided. When the instructions in the non-temporary computer-readable storage medium are executed by the processor of the mobile terminal, the mobile terminal is enabled to execute a virtual machine configuration method, which includes the method in the above-mentioned embodiment 1.
[0066] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0067] It should be understood that the present application is not limited to the exact structures described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A virtual machine configuration method, characterized in that: include: Loading a hypervisor image and multiple virtual machine domain images through the boot loader; Starting the virtual machine monitor image and allocating resources to the multiple virtual machine domain images; Starting the multiple virtual machine domain images in parallel based on the resources of each virtual machine domain image; The method further comprises: configuring a virtual input and output virtIO backend service in the virtual machine monitor image, wherein the address space of the virtIO backend service is a separate address space; The step of starting the plurality of virtual machine domain images in parallel based on the resources of each virtual machine domain image comprises: starting the processing cores corresponding to the processors in parallel in a preset startup mode initiated by the processors in each virtual machine domain image based on the resources of the virtual machine domain image; The parallel startup of the processing core corresponding to the processor includes: when the processing core is in a waiting state, sending an interrupt wake-up to the processing core in the virtual machine domain image according to a preset order through the virtual machine monitor image, and parallel startup of the virtual machine domain image.
2. The method according to claim 1, characterized in that The loading of the virtual machine monitor image and the multiple virtual machine domain images by the boot program includes: Loading the virtual machine monitor image and the multiple virtual machine domain images to a storage medium of the system through a boot program; The virtual machine monitor image and the multiple virtual machine domain images are signature-verified.
3. The method according to claim 1 or 2, characterized in that The virtual machine monitor image includes: a resource configuration file.
4. The method according to claim 3, characterized in that The starting the virtual machine monitor image and allocating resources to the multiple virtual machine domain images includes: Start the virtual machine monitor image, and obtain resources corresponding to the virtual machine monitor image and the multiple virtual machine domain images from the resource configuration file, wherein the resources include: at least one of: memory space of the virtual machine monitor, the virtIO backend service, memory resources corresponding to the virtual machine domain image, and input and output resources.
5. A virtual machine configuration device, characterized in that: include: A loading module, used to load a virtual machine monitor image and multiple virtual machine domain images through a boot program; an allocation module, configured to start the virtual machine monitor image and allocate resources to the multiple virtual machine domain images; A startup module, configured to start the multiple virtual machine domain images in parallel based on the resources of each virtual machine domain image; The virtual machine configuration device further includes: a configuration module configured to configure a virtual input and output virtIO backend service in the virtual machine monitor image, wherein the address space of the virtIO backend service is a separate address space; The startup module includes: a startup unit, configured to start processing cores corresponding to the processors in parallel according to resources of the respective virtual machine domain images and preset startup modes initiated by the processors in the respective virtual machine domain images; The startup unit includes: a startup subunit, which is used to send an interrupt wakeup to the processing core in the virtual machine domain image according to a preset order through the virtual machine monitor image when the processing core is in a waiting state, and start the virtual machine domain image in parallel.
6. A virtual machine configuration device, characterized in that: include: processor; memory for storing processor-executable instructions; The processor is configured as: the method according to any one of claims 1 to 4.
7. A non-transitory computer-readable storage medium, wherein when instructions in the non-transitory computer-readable storage medium are executed by a processor of a mobile terminal, the mobile terminal is enabled to perform a virtual machine configuration method, the method comprising: The method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Electronic apparatus, virtual machine providing apparatus, and method of using virtual machine service
CN101826028A
System and method for usage-based application licensing in a hypervisor virtual execution environment
CN102511034A