Virtual machine starting method and device and product

By automatically identifying the boot device and generating the virtual machine's boot item file, the problem of boot item abnormality during virtual machine startup is solved, fast recovery and efficient startup are achieved, and stability and compatibility are improved.

CN119938222APending Publication Date: 2025-05-06HENAN KUNLUN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202412000092.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

When starting a virtual machine, it often encounters the problem of boot item exceptions, which leads to failure to start normally. Existing solutions such as manual repair or reinstalling the operating system are complex and time-consuming, unable to meet the needs of fast recovery, and poor compatibility.

Method used

By automatically identifying the boot device, obtaining operating system information and loading path information, generating the virtual machine's boot item file, and saving it to the virtual machine, so that the virtual machine can load the operating system based on the file.

Benefits of technology

It realizes rapid recovery of virtual machines, improves startup efficiency and stability, reduces downtime caused by boot item abnormalities, and has good compatibility and ease of use.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119938222A_ABST
    Figure CN119938222A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a virtual machine starting method and device and a product. After the virtual machine is started, the starting device determines the guide equipment connected to the virtual machine; operating system information and loading path information are obtained according to the guiding equipment; the loading path information comprises obtaining a file path of a boot loader or obtaining a file path of an EFI file; generating a boot item file according to the operating system information and the loading path information; and storing the boot item file in the virtual machine, so that the virtual machine loads the operating system based on the boot item file. Therefore, the bootstrap item can be quickly generated by automatically identifying the bootstrap device and quickly acquiring the operating system information and the loading path information based on the bootstrap device. When the starting mode is applied to a recovery scene with the abnormal guide item, the recovery efficiency of the virtual machine can be improved, the starting efficiency and stability of the virtual machine are further improved, and the downtime caused by the abnormal guide item is shortened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of server technology, and in particular to a method, device and product for starting a virtual machine. Background Art

[0002] When starting a virtual machine, you often encounter abnormal boot items, such as USB boot item errors, operating system boot file loss or errors, which cause the virtual machine to fail to start normally. The boot item defines the operating system or boot program used when the virtual machine starts.

[0003] Currently, manual repair or reinstallation of the operating system is often used to restore the boot items of the virtual machine. However, whether it is manual recovery or reinstallation, the repair process is difficult and time-consuming, and cannot meet the needs of rapid recovery of virtual machines. Moreover, the above repair methods are often only applicable to specific types or versions of operating systems, have poor compatibility, and are not suitable for users with non-technical backgrounds. Summary of the invention

[0004] The embodiments of the present application provide a method, device and product for starting a virtual machine, which are used to quickly restore boot items, improve the startup efficiency and stability of the virtual machine, and have good compatibility and ease of use.

[0005] In a first aspect, an embodiment of the present application provides a method for starting a virtual machine, which is applied to a starting device of a computing device.

[0006] After the virtual machine is powered on, the startup device determines the boot device connected to the virtual machine; based on the boot device, the operating system information and the loading path information are obtained; the loading path information includes obtaining the file path of the boot loader, or obtaining the file path of the EFI file; based on the operating system information and the loading path information, a boot entry file of the virtual machine is generated; the boot entry file is saved in the virtual machine so that the virtual machine loads the operating system based on the boot entry file.

[0007] The embodiment of the present application can quickly generate a boot item by automatically identifying the boot device and quickly obtaining the operating system information and loading path information based on the boot device. When this startup method is applied to the boot item abnormality recovery scenario, the recovery efficiency of the virtual machine can be improved, thereby improving the startup efficiency and stability of the virtual machine and reducing the downtime caused by the boot item abnormality. In addition, the above scheme can be deployed on OVMF, and only the software needs to be modified on the physical machine, that is, it can be compatible with the boot item recovery of multiple virtual machine operating systems, and has high compatibility. And it does not require the user to manually install or configure, and is easy to use.

[0008] The operating system information includes at least one of the type and version information of the operating system and the name of the operating system.

[0009] In a specific implementation, the boot device can generate a boot item file based on the boot item configuration template according to the operating system information and the loading path information. The boot item configuration template includes a system information adding position and a path information adding position, the system information adding position is used to add the operating system information, and the path information adding position is used to add the loading path information. Therefore, the boot device generates a boot item file through the boot item configuration module, which can improve the accuracy and consistency of the configuration and realize batch deployment.

[0010] In another specific implementation, the boot item configuration template also includes a boot order position and a boot priority position; the boot order position is used to add the boot order of the boot item, the boot priority position is used to add the boot priority of the boot item, the boot priority is used to determine the execution order, and the boot order is used to determine the startup order of multiple operating systems. The startup device is used to add the operating system name to the operating system name position in the boot item configuration template, add the file path to the file path position in the boot item configuration template, add the boot order to the boot order position in the boot configuration template, and add the boot priority to the boot priority position in the boot item configuration template; based on the added boot item configuration template, generate a boot item file. By adding the boot order and boot priority in the boot item file, the startup reliability can be improved, for example, ensuring that the operating system specified by the user is started first.

[0011] Furthermore, the boot item configuration template also includes a boot information location, which is used to add a boot configuration file, and the startup device is also used to obtain the boot configuration file; the boot configuration file includes information associated with the corresponding EFI file configured for each operating system; the operating system name is added to the operating system name position in the boot item configuration template, the file path is added to the file path position in the boot item configuration template, and the boot configuration file is added to the configuration file position in the boot item configuration template; based on the added boot item configuration template, a boot item file is generated.

[0012] In another specific implementation, the boot device first detects whether the boot item is abnormal. If the boot item is abnormal, the boot device connected to the virtual machine is determined and subsequent operations are performed. The boot device can simplify the operation process and improve the boot efficiency by checking whether the boot item is abnormal and performing the operation of generating a new boot item file only when the boot item is abnormal.

[0013] In another specific implementation, the partition of the boot device is mounted; the partition of the boot device includes an EFI partition; the characteristic files of the operating system are extracted from each mounted partition, and the operating system information is recorded; the EFI file is extracted from the EFI partition, and the file path of the extracted EFI file is recorded.

[0014] Furthermore, the boot device further determines an invalid boot item file in the boot item file; deletes the invalid boot item file from the boot item file to obtain the boot item file to be saved; and saves the boot item file to be saved into a UEFI variable storage file dedicated to the virtual machine. This ensures that the boot item file after storage occupies a small memory space and helps to increase the probability of the virtual machine starting correctly.

[0015] In a second aspect, an embodiment of the present application provides a device for starting a virtual machine, the device comprising:

[0016] A determination unit, used to determine a boot device connected to the virtual machine after the virtual machine is powered on;

[0017] An acquisition unit, used to acquire operating system information and loading path information according to a boot device; the loading path information includes acquiring a file path of an extensible firmware interface EFI file, or acquiring a file path of a boot loader;

[0018] A generating unit, used for generating a boot entry file of a virtual machine according to the operating system information and the loading path information;

[0019] The saving unit is used to save the boot entry file to the virtual machine so that the virtual machine loads the operating system based on the boot entry file.

[0020] In a specific implementation, the generation unit is specifically used to: generate a boot item file based on a boot item configuration template according to operating system information and loading path information; the boot item configuration template includes a system information adding position and a path information adding position, the system information adding position is used to add operating system information, and the path information adding position is used to add loading path information.

[0021] In a specific implementation, if the boot item configuration template also includes a boot order position and a boot priority position; the boot order position is used to add the boot order of the boot item, the boot priority position is used to add the boot priority of the boot item, the boot priority is used to determine the execution order, and the boot order is used to determine the startup order of multiple operating systems; the generation unit is specifically used to: add the operating system name to the operating system name position in the boot item configuration template, add the file path to the file path position in the boot item configuration template, add the boot order to the boot order position in the boot configuration template, and add the boot priority to the boot priority position in the boot item configuration template; based on the added boot item configuration template, generate a boot item file.

[0022] In another specific implementation, if the boot item configuration template also includes a boot information location, the boot information location is used to add a boot configuration file, and the generation unit is also used to: obtain the boot configuration file; the boot configuration file includes information associated with the corresponding EFI file configured for each operating system; add the operating system name to the operating system name position in the boot item configuration template, add the file path to the file path position in the boot item configuration template, and add the boot configuration file to the configuration file position in the boot item configuration template; based on the added boot item configuration template, generate a boot item file.

[0023] In another implementation, the startup device further includes a detection unit, which is used to detect whether the boot item is abnormal; the determination unit is specifically used to determine the boot device connected to the virtual machine if the boot item is detected to be abnormal.

[0024] In another implementation, the acquisition unit is specifically used to: mount the partition of the boot device; the partition of the boot device includes an EFI partition; extract the characteristic files of the operating system from each mounted partition and record the operating system information; extract the EFI file from the EFI partition and record the file path of the extracted EFI file.

[0025] In another implementation, the boot device further includes a deleting unit, which is used to: determine an invalid boot item file in the boot item file; delete the invalid boot item file from the boot item file to obtain the boot item file to be saved;

[0026] The saving unit is specifically used to save the boot item file to be saved into a UEFI variable storage file dedicated to the virtual machine.

[0027] In the embodiment of the present application, the operating system information includes at least one of the type and version information of the operating system and the name of the operating system.

[0028] In a third aspect, an embodiment of the present application provides a computing device, including:

[0029] Memory, used to store programs;

[0030] The processor is used to execute the program stored in the memory. When the program stored in the memory is executed, the processor is used to execute any method as described in the first aspect.

[0031] In a fourth aspect, the present application provides a computer storage medium for storing a computer program, which, when executed, is used to implement the method provided in any one of the embodiments of the first aspect of the present application.

[0032] In a fifth aspect, the present application provides a computer program product comprising instructions, which, when executed on at least one computing device, enables the at least one computing device to implement the method provided in any one of the embodiments of the first aspect of the present application.

[0033] The corresponding computing device, terminal device, computer-readable storage medium, or computer program product of any of the virtual machine startup methods provided above are used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 A schematic diagram of an application scenario of the method for starting a virtual machine provided in an embodiment of the present application;

[0035] Figure 2 A flowchart of a method for starting a virtual machine provided in an embodiment of the present application;

[0036] Figure 3A A flowchart of a method for starting a virtual machine provided in an embodiment of the present application;

[0037] Figure 3B A schematic diagram of a startup process of another virtual machine provided in an embodiment of the present application;

[0038] Figure 4 A schematic diagram of the startup process of a UEFI boot operating system provided in an embodiment of the present application;

[0039] Figure 5 A schematic diagram of a virtual machine startup process provided in an embodiment of the present application;

[0040] Figure 6 A schematic diagram of the structure of a virtual device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0041] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0042] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.

[0043] The terms "first" and "second" in the description and claims of the embodiments of the present application are used to distinguish different objects rather than to describe a specific order of objects. For example, a first target object and a second target object are used to distinguish different target objects rather than to describe a specific order of target objects.

[0044] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0045] In the description of the embodiments of the present application, unless otherwise specified, the meaning of "multiple" refers to two or more than two. For example, multiple processing units refer to two or more processing units; multiple systems refer to two or more systems.

[0046] The following describes a method for starting a virtual machine provided in an embodiment of the present application in conjunction with the accompanying drawings.

[0047] First combine Figure 1 , introduces a schematic diagram of an application scenario of the virtual machine startup method provided in an embodiment of the present application.

[0048] Figure 1 The computing device 100 shown includes a host machine and at least one virtual machine running on the host machine. Figure 2 For example, four virtual machines are virtual machine 1, virtual machine 2, virtual machine 3, and virtual machine 4.

[0049] The computing device 100 includes a hardware layer, a host operating system layer, a virtualization layer, a firmware layer and a virtual machine layer.

[0050] The hardware layer includes hardware devices of the computing device 100. The hardware devices include but are not limited to processors, memory, silver disks, Universal Serial Bus (USB) devices, and network cards.

[0051] The host operating system layer includes the operating system running on the computing device 100 .

[0052] The virtualization layer uses virtualization technology to simulate a virtual hardware environment for use by the virtual machine when the host operating system is running. As an example, the virtualization technology can be a Quick Emulator (QEMU) and / or a kernel-based virtual machine (KVM). In an embodiment of the present application, the method for starting a virtual machine can run on QEUM, on KVM, or on a module of another virtualization layer.

[0053] The firmware layer is responsible for starting the virtual machine. As an example, the firmware layer runs the open source virtual machine firmware (OpenVirtual Machine Firmware, OVFM) to start the virtual machine. Exemplarily, the virtual machine startup method can be run on OVFM, thereby taking advantage of the virtual machine startup process and better managing the startup.

[0054] The virtual machine layer includes several virtual machines ( Figure 1 There are 4 virtual machines displayed, namely virtual machine 1 to virtual machine 4. These virtual machines run in the virtualization layer. Each virtual machine has its own operating system and application and shares the hardware resources of the host machine.

[0055] In an embodiment of the present application, the computing device 100 includes a startup device, and the startup method of the virtual machine provided in the embodiment of the present application is executed by the startup device. In one example, the startup device can be located on the OVFM firmware. Among them, the startup device can be an independent software system, such as an independent recovery tool or suite. Or the device can be integrated with other software as a functional module, plug-in, extension, component or applet, for example, the software system can be VMware, VirtualBox, Hyper-V. The software system can integrate QEUM, or KVM, or it can be integrated on OVMF. Figure 1 It shows that the boot device is deployed at the firmware layer.

[0056] Attached Figure 2 A flowchart of a method for starting a virtual machine provided in an embodiment of the present application, the method is applied to Figure 1 On the starting device shown, the method includes the following contents:

[0057] S10. After the virtual machine is powered on, determine the boot device connected to the virtual machine.

[0058] A boot device refers to a storage medium or network resource that contains the information required to start the operating system. Boot devices include but are not limited to: disks, hard disks, optical drives, USB drives, and network boot devices. The information includes: boot operating system files, boot loaders, and boot configuration files. It should be noted that the boot loader in the Unified Extensible Firmware Interface (UEFI) environment, also known as the EFI file, is located in the Extensible Firmware Interface (EFI) system partition.

[0059] In an embodiment of the present application, when the virtual machine is powered on, the startup device determines the boot device connected to the virtual machine. For example, the startup device may call an application program interface (API) in a virtual machine management tool, or may use a command line tool or script to identify the boot device connected to the virtual machine. A virtual machine management tool refers to a tool on a computing device that manages virtual machines, such as libvirt, VMware, etc.

[0060] It should be noted that the boot connected to the virtual machine may exist in the form of a boot device list, or may be stored in other forms, which is not specifically limited in the embodiments of the present application.

[0061] S20. Obtain operating system information and loading path information according to the boot device.

[0062] In the embodiment of the present application, the operating system information includes but is not limited to information such as the operating system name, operating system version number, and operating system type, which is used to determine the specific operating system used by the boot device.

[0063] The boot device can mount the partition of the boot device. In this way, the files in the boot device can be recognized by the boot device through mounting. The partition of the boot device refers to a logical area created on the boot device for storing files and data required when the operating system is started. For example, the partition of the boot device includes a first partition for storing boot loader files and a second partition for storing the operating system.

[0064] Mounting refers to connecting the partition of the boot device to a directory of the virtual machine so that the boot device can access the partition files in the boot device. For example, the boot device can mount the first partition to directory 1, and can also mount the second partition to the directory. In Linux, mounting is a very important operation. Mounting can be used to mark the location of partitions in the boot device so that they can be used by the boot device. After mounting, the partitions of these boot devices belong to the file tree structure in the virtual machine and become a subdirectory under the root directory.

[0065] The boot device can call a file system operation tool or other tools to obtain the operating system file from the file tree structure. For example, the operating system file is a Windows feature file, or a Linux feature file, etc. The boot device records the type and version information of the operating system. For example, for a Linux feature file named / etc / os-release, it usually contains information such as the operating system name, version number and type. The boot device can directly identify and record the operating system name, version number and type from / etc / os-release. For another example, for a Windows system, a specific key value in the registry (a special Windows feature file) can be read to obtain the operating system name, version number and type, etc.

[0066] Load path information refers to the path information for obtaining the information required to generate a boot item file, such as obtaining the path information of a boot loader or an EFI file. In an embodiment of the present application, the load path information can be the file path of the boot loader or the file path of the EFI file. For example, if the load path information is a file path named / EFI / Boot / bootx64.efi, the boot device can obtain the bootx64.efi file from the Boot folder under the EFI folder.

[0067] In one example, if the boot device is in a UEFI environment, the boot device can obtain the EFI file from the EFI folder partition of the mounted boot device. For example, the EFI files are grubaa64.efi, shim.efi, osbootmgfw.efi, and Shell.efi. The boot device records the file path where the EFI file is found. For example, the file path of the EFI file is / EFI / Boot / bootx64.efi, that is, the bootx64.efi file can be obtained from the Boot folder of the folder whose folder is EFI. These file paths are used to generate boot items to ensure that the virtual machine starts correctly.

[0068] S30: Generate a boot entry file of the virtual machine according to the loading path information and the operating system information.

[0069] In the embodiment of the present application, the boot device generates a boot item file based on the boot item configuration template according to the loading path information and the operating system information, wherein the boot item file refers to a file including the loading information and the operating system information, and is used to guide the loading of the operating system.

[0070] The boot item configuration template includes a system information adding position and a path information adding position. The system information adding position is used to add operating system information, and the path information adding position is used to add loading path information.

[0071] For example, if the loading path information is the file path, and the operating system information is the operating system name, the boot item configuration template includes the following items: the file path location (i.e., the path information addition location), which is used to add the file path, and the operating system name location (i.e., the system information addition location), which is used to add the operating system name. The boot item configuration template after adding is the information boot location. For example, if the file path of the EFI file is / EFI / Boot / bootx64.efi, and the operating system information is: Windows10, then the boot items include: / EFI / Boot / bootx64.efi, Windows 10.

[0072] In addition, in an embodiment of the present application, the boot item file of the virtual machine may also include information such as the boot order and boot priority, reference configuration files and / or environment variables.

[0073] In a possible implementation, since there may be multiple virtual machines deployed in the server, for example, including four virtual machines (for example, virtual machine 1, virtual machine 2, virtual machine 3, and virtual machine 4), each virtual machine corresponds to an operating system. Therefore, in order to ensure the normal startup of each virtual machine, the startup device can also set a boot order and a boot priority for each boot item.

[0074] The boot order refers to the boot order of the virtual machines to which the boot item belongs during the boot process. For example, the boot item belongs to virtual machine 1, which is the primary server, and the boot order is to start first. The boot item belongs to virtual machine 2, which is a database server and depends on the server provided by virtual machine 1, so the boot order is to start after virtual machine 1. The boot item belongs to virtual machine 3, which is an application server and depends on the database server provided by virtual machine 2, so the boot order is to start after virtual machine 2. The boot item belongs to virtual machine 4, which is a backup server, so the boot order is to start last.

[0075] The boot priority refers to the priority of the boot item in the same virtual machine. Among them, the boot items with high priority are called first, and the boot items with low priority are called later. For example, the operating system running on virtual machine 1 is Windows, and the boot items are hard disk boot item, USB drive boot item and network boot item. The boot item priorities are set from high to low: hard disk boot item, USB drive boot item and network boot item. The virtual machine startup order is boot from hard disk, boot from USB drive (for system recovery), and boot from network.

[0076] In the embodiment of the present application, the boot device can obtain the boot order and boot priority of each boot item, and add the boot order and boot priority of the boot item to the boot order position and boot priority position of the boot item configuration template. Wherein, the boot item file also includes the boot order and boot priority.

[0077] The boot configuration file is a set of settings that specifies how to start the operating system, such as the Grub configuration file. The boot configuration file contains a series of instructions or parameters that tell the virtual machine what to do when it starts, such as which EFI file to choose to start. In addition, the boot configuration file can also set startup parameters, such as the startup timeout, the default startup operating system, and the startup mode, and pass the startup parameters to the EFI file when starting the operating system.

[0078] In an embodiment of the present application, the boot device can obtain a boot configuration file based on a preset command line, a third tool, or a custom script. For example, in a Linux system, the Grub configuration file is located in a file path named / boot / grub / grub.cfg. The boot device can obtain the Grub configuration file from / boot / grub / grub.cfg based on a custom script. The boot device adds the obtained boot configuration file to the boot information position of the boot item configuration template.

[0079] S40, saving the generated boot item to the virtual machine.

[0080] In an example, the boot device may save the generated boot item into a variable storage file dedicated to the virtual machine, for example, save the boot item into a UEFI variable storage file dedicated to the virtual machine.

[0081] Afterwards, the virtual machine obtains the boot item file from the variable storage file, uses the boot item file to load the operating system of the virtual machine, and starts the virtual machine.

[0082] Furthermore, to avoid data loss, the variable storage file is backed up.

[0083] That is, the embodiment of the present application can quickly generate boot items by automatically identifying the boot device and quickly obtaining the operating system information and loading path information based on the boot device, thereby improving the recovery efficiency of the virtual machine, thereby improving the startup efficiency and stability of the virtual machine and reducing the downtime caused by abnormal boot items. In addition, the above solution can be deployed on OVMF, and only the software needs to be modified on the physical machine, that is, it can be compatible with the boot item recovery of multiple virtual machine operating systems, with high compatibility. And it does not require manual installation or configuration by the user, and is easy to use.

[0084] Since the generated boot item files may include unavailable boot item files, adding the boot item files to the dedicated variable storage file will occupy file space and also reduce the probability of the virtual machine starting correctly. Figure 2 The method for starting the virtual machine has the problems of occupying file space and storing the content, and having a low probability of correct startup.

[0085] See also Figure 3A , which is a flow chart of a method for starting a virtual machine provided by an embodiment of the present application. In the method, step S20 can be refined into steps S301 to S304, wherein the loading path information is the file path of the available EFI file.

[0086] In this method, step S40 can be further refined into S306 to S308. The method includes the following contents:

[0087] S10. After the virtual machine is powered on, determine the boot device connected to the virtual machine.

[0088] S301, check the boot device list and obtain operating system information.

[0089] Among them, some boot devices of the virtual machine store operating system files, and other parts do not store operating system files. The boot item recovery device can check the boot devices, filter out the boot devices that store operating system files, and obtain operating system information from these boot devices.

[0090] First, the boot device mounts the EFI system partition of each boot device on the file system tree of the virtual machine. By mounting each boot device on the file system tree, the boot device can recognize the boot device partition.

[0091] Then the boot device calls a file system operation tool or other tool to search for a known operating system file on the boot device partition, and obtains operating system information from the known operating system file.

[0092] S302: Retrieve EFI files.

[0093] The startup device detects the EFI system partition of each boot device, searches for the EFI file from the EFI system partition, and obtains the file path of the searched EFI file.

[0094] For example, EFI files searched from the EFI system partition include grubaa64.efi, shim.efi, osbootmgfw.efi, etc.

[0095] S303: Verify the EFI file.

[0096] The EFI files searched in step S302 may include abnormal EFI files.

[0097] Abnormal EFI files refer to EFI files that affect the normal boot of UEFI. For example, missing EFI files, damaged EFI files, or EFI files with invalid signatures. Missing EFI files refer to boot loader files that are deleted or damaged, causing the system to be unable to find valid EFI files.

[0098] The boot device directly uses the abnormal EFI file to generate a new boot item, which may be an abnormal boot item, affecting subsequent use. To this end, the boot device first verifies the EFI file, determines the abnormal EFI file found in the EFI file, and then deletes the abnormal EFI file.

[0099] S304: Processing abnormal EFI files.

[0100] The startup device deletes abnormal EFI files and records and reports EFI anomalies.

[0101] Exemplarily, if the searched EFI files include grubaa64.efi, shim.efi, and osbootmgfw.efi, wherein grubaa64.efi is an abnormal EFI file, the boot device deletes grubaa64.efi, deletes the file path corresponding to the abnormal EFI file, and records and reports the EFI abnormality.

[0102] S305: Generate a boot entry file according to the operating system information and the file path of the available EFI file.

[0103] Compared with step S30, the embodiment of the present application refines the loading path information into the file path of the available EFI file. In the embodiment of the present application, the boot device generates the boot item file based on the operating system information and the file path of the available EFI file and the boot item configuration template.

[0104] The method of generating a boot entry file based on the file path of the available EFI file and the operating system information is the same as the method of generating a boot entry file based on the loading path information and the operating system information, and will not be repeated here.

[0105] S306: Verify the boot entry file.

[0106] If multiple virtual machines are deployed on the server, for example Figure 1 The virtual machines shown include virtual machine 1, virtual machine 2, virtual machine 3, and virtual machine 4. At this time, the startup device will obtain the operating system information corresponding to each virtual machine in the multiple virtual machines and the file path of the boot loader or available EFI file corresponding to each operating system. For example, the operating system information A1 corresponding to virtual machine 1 has a file path of B1; the operating system information A2 corresponding to virtual machine 2 has a file path of B2; the operating system information A3 corresponding to virtual machine 3 has a file path of B3; the operating system information A4 corresponding to virtual machine 4 has a file path of B4.

[0107] According to the operating system information and the file path of the available EFI files, multiple boot entry files are generated, such as boot entry file 1 (A1, B1), boot entry file 2 (A1, B2), boot entry file 3 (A2, B1), boot entry file 1 (A2, B3), boot entry file 1 (A3, B2),...

[0108] Some boot item files are correct and usable, but some boot item files are unusable. Abnormal boot item files (abnormal boot item files, wireless boot item files for short) need to be adjusted or corrected. Among them, abnormal boot item files refer to boot loader files that are missing, boot loader files that exist but have damaged or incomplete file contents, boot devices that are unavailable, or boot item files with incorrect configuration parameters.

[0109] Therefore, the startup device verifies the boot entry file and processes the abnormal boot entry file, such as recording the problem and adjusting or correcting it.

[0110] In one example, the boot device reads the boot item file list of the OVFM firmware. The boot item file list includes multiple boot item files. Then, the boot device verifies whether the EFI file pointed to by the boot item file exists in the specified path to avoid booting from invalid or existing files. For example, the boot item file points to bootx64.efi, and the file path in the boot item file is \EFI\Boot\bootx64.efi. If the corresponding EFI file is not found based on the path, it means that the EFI file pointed to by the boot item file does not exist in the specified path.

[0111] Next, the boot device verifies the integrity of the EFI file. For example, the hash value of the EFI file is calculated using a cryptographic hash algorithm and compared with a pre-stored hash value. Another example is to verify the digital signature of the EFI file to determine that its source is credible and has not been tampered with. The status of the boot device is checked to ensure that the settings are in normal working order.

[0112] S307: Clear abnormal boot item files and obtain boot item files to be saved.

[0113] The startup device deletes abnormal boot item files and obtains correct and available boot item files to be saved.

[0114] S308: Save the boot item file to be saved.

[0115] The boot device saves the correct and available boot item file in a UEFI variable storage file dedicated to the virtual machine, and backs up the UEFI variable storage file to prevent data loss.

[0116] Further, as attached Figure 3B The above is another schematic diagram of the startup process of a virtual machine provided in an embodiment of the present application. Before executing step S10, the startup device may also execute step S401. In the embodiment of the present application, the startup device saves a new boot item file. In addition, since there may be expired boot items or abnormal boot items in the file library of the saved boot item file, these boot items may affect the startup rate and startup correctness, so S402 may be executed after step S308. The method includes:

[0117] S401: After the virtual machine is powered on, identify whether the boot item file is abnormal, if so, execute S10. If not, optionally, execute S50.

[0118] The abnormal boot entry file includes invalid or damaged boot entry file, etc. If the boot device finds an abnormal boot entry file, it triggers execution S50 to execute the boot entry file recovery mechanism, thereby ensuring that OVFM will not try to start from the abnormal boot entry file, thereby improving the stability and security of the server.

[0119] In an embodiment of the present application, the startup device can check whether the file path of the boot item file exists, verify the integrity of the boot loader, and if the secure boot is enabled, can detect whether the digital signature of the boot item file is valid. If the digital signature of the boot item file is valid, or the file path of the boot item file exists, or the boot loader is complete, it is determined that the boot item file is correct. If the digital signature of the boot item file is invalid, or the file path of the boot item file does not exist, or the boot loader is incomplete, it is determined that the boot item file is abnormal.

[0120] S10. Determine a boot device connected to the virtual machine.

[0121] S20. Obtain operating system information and loading path information according to the boot device.

[0122] S30: Generate a boot entry file of the virtual machine according to the loading path information and the operating system information.

[0123] S40, saving the generated boot item to the virtual machine.

[0124] (Optional) S50, deleting expired boot entry files and / or deleting abnormal boot entry files.

[0125] An expired boot entry file refers to a boot entry file that has been uninstalled by the operating system, a boot entry file with an outdated EFI file version, or a boot entry file that points to a startup mode or device that is no longer used.

[0126] The boot item file may be out of date, such as an uninstalled operating system or an invalid boot device. In the embodiment of the present application, the boot device can clean up the old boot item files in the NVRAM, free up space and keep the boot configuration tidy, ensure that the boot menu contains only valid boot options, and avoid users from selecting invalid boot item files.

[0127] Therefore, the embodiment of the present application first checks whether there is a boot item abnormality before executing S10, and only executes step S10 and subsequent operations when the boot item is abnormal. In this way, the number of times the boot item file is generated can be reduced and the loading efficiency of the operating system can be improved.

[0128] In summary, the method for starting a virtual machine provided in the embodiment of the present application only needs to update the startup device software on the host machine, without modifying the image of the virtual machine operating system, and can be applied to the recovery of boot item files of various operating systems. This not only simplifies the operation process, but also improves the compatibility of the system. And by deleting abnormal EFI files, and clearing invalid or expired boot item files and boot item files that cannot be used correctly, the generated boot item files can greatly improve the success probability of the virtual machine starting correctly, and improve the efficiency of the virtual machine boot item file recovery.

[0129] It is understandable that the virtual machine startup process may be different for different computing devices. For example, the startup process of some virtual machines uses UEFI startup, and the startup process of some virtual machines is Basic Input / Output System (BIOS), etc. In order to enable those skilled in the art to better understand the virtual machine startup method provided in the embodiment of the present application, the UEFI startup process is taken as an example to introduce a virtual machine startup method provided in the embodiment of the present application.

[0130] See also Figure 4 , Figure 4 A schematic diagram of the startup process of a UEFI boot operating system is shown.

[0131] The UEFI boot process refers to the process from powering on a computing device, through platform initialization, operating system startup, to shutdown. It includes seven stages, namely, security verification, Extensible Firmware Interface (EFI) initialization, driver execution environment, boot device selection, temporary system loading, system operation, and system shutdown. The following is a detailed analysis.

[0132] First, the security verification stage.

[0133] The security verification phase is mainly used to process the startup signal, restart signal and abnormal signal of the computing device. It is also used to create a temporary storage area as a carrier for program operation. In addition, the security verification phase can also prepare for the early initialization phase of EFI. The specific accurate information is: the accurate current system status, the address and size of the boot firmware volume (BFV), the address and size of the temporary storage area, etc.

[0134] Second, the EFI early initialization stage.

[0135] The EFI initialization phase initializes the content based on the accurate information in the security verification phase, and implements the chipset initialization, motherboard initialization, and processor initialization based on the EFI driver scheduling. In this way, the execution environment is prepared for the driver execution environment phase, and the accurate results are sent to the driver execution environment phase.

[0136] Third, the driver execution environment stage.

[0137] The driver execution environment is used to implement a series of initialization services, such as BootServices, and install configuration tables. In addition, the driver execution environment is also used to distribute drivers, initialize some protocols, devices, buses, and install drivers for subsequent use.

[0138] Fourth, start the equipment selection phase.

[0139] The boot device selection phase is used to perform boot management, including: initializing the console device, loading the relevant driver for the device, the driver determines the loading mode, setting the BIOS, loading the bootable options according to the system settings, etc. In the embodiment of the present application, the boot device selection phase is also used to perform the following steps provided in the embodiment of the present application: Figure 2The method for starting a virtual machine shown in the figure generates a boot entry file of the virtual machine and stores the generated boot entry file in a dedicated variable storage file. Thus, when the virtual machine loads the operating system, the operating system corresponding to the boot entry file is booted based on the boot entry file in the variable storage file.

[0140] Fifth, the early stage of operating system loading.

[0141] The early stage of operating system loading is used for the first stage of operating system loading execution, and is used to prepare the execution environment for loading the operating system. In this stage, the user can interact with the UEFI environment based on a command line interface of UEFI in the UEFI application (also known as UEFL shell). For example, when there is a problem with the boot item, the user can manually select the boot item through the UEFI shell, load different boot loaders, etc. And the UEFI application can load the early operating system loader and the operating system loader based on the boot item file of the fourth stage. Among them, the early operating system loader is used to perform tasks before the operating system is loaded, such as firmware updates, diagnosis, etc. The operating system loader is used to load information such as the kernel of the operating system.

[0142] Sixth, system operation stage.

[0143] After the computing device enters the system operation stage, at this time, the application program of the operating system can load the final operating system environment so that the virtual machine completes the loading of the operating system.

[0144] (Optional) Seventh, system shutdown phase.

[0145] When there is an error in the operating system hardware or the operating system is shut down, the system shutdown phase is carried out, and the operating system firmware provides error handling and recovery mechanisms.

[0146] Among them, for the fourth stage, the startup process of the virtual machine can be implemented through the Extensible Firmware Interface Developer Kit 2 (EDK2). EDK2 is a software development kit for developing firmware compatible with UEFI. Figure 5 As shown in FIG. 1 , the startup process of a virtual machine specifically includes the following steps:

[0147] S510: Display a startup screen.

[0148] During the UEFI boot process, a visual startup screen will be displayed. The startup screen includes the operating system version and prompt information, etc. The prompt information can be a progress loading bar to prompt the user that the virtual machine is starting.

[0149] S520: Process specific command options.

[0150] EDK2 processes specific command options, which means parsing and processing the startup parameters or options passed by the user through the command line. The command line options can be used to specify the startup mode, boot device and / or kernel parameters, etc.

[0151] S530, connecting to a boot device.

[0152] EDK2 connects the virtual machine to all boot devices and ensures that the boot devices are initialized correctly and start accurately. For example, EDK2 iterates over all connected devices and calls a function named ConnectController to load the driver for each device to ensure that all boots are initialized correctly.

[0153] S540. Enumerate all available boot entry files.

[0154] EDK2 lists all available boot entry files, providing the user with the option to select a boot entry, or automatically selects a boot entry based on a preset boot order. These boot entry files are often boot loaders and boot devices stored in NVRAM.

[0155] S550: Identify whether the boot entry file is abnormal, if so, execute S560. If not, execute S570.

[0156] The abnormal boot entry file includes the boot entry file being invalid or damaged, etc. If EDK2 finds an abnormal boot entry file, it triggers execution of S560 to execute the boot entry file recovery mechanism, thereby ensuring that OVFM will not try to start from the abnormal boot entry file, thereby improving the stability and security of the server.

[0157] In the embodiment of the present application, EDK2 can check whether the file path of the boot item file exists, verify the integrity of the boot loader, and if secure boot is enabled, detect whether the digital signature of the boot item file is valid. If the digital signature of the boot item file is valid, or the file path of the boot item file exists, or the boot loader is complete, it is determined that the boot item file is correct. If the digital signature of the boot item file is invalid, or the file path of the boot item file does not exist, or the boot loader is incomplete, it is determined that the boot item file is abnormal.

[0158] S560. Generate and save a new boot entry file.

[0159] When an abnormal boot entry file is detected, EDK2 calls Figure 1 The boot device shown executes the recovery boot item file settings to ensure the normal startup of the system. For specific execution methods, see Figure 2 As shown in Figure 3, it will not be discussed here.

[0160] S570: Delete expired boot item files and / or delete abnormal boot item files.

[0161] An expired boot entry file refers to a boot entry file that has been uninstalled by the operating system, a boot entry file with an outdated EFI file version, or a boot entry file that points to a startup mode or device that is no longer used.

[0162] The boot item file may be out of date, such as an uninstalled operating system or an invalid boot device. In the embodiment of the present application, EDK2 can clean up old boot item files and abnormal boot item files in NVRAM, free up space and keep the boot configuration clean, ensure that the boot menu contains only valid boot options, and avoid users from selecting invalid boot item files.

[0163] (Optionally) S580. Set the boot order.

[0164] When the boot order is not included in the boot item file, EDK2 sets the boot order of the boot item file according to the user configuration or system policy, that is, which boot item file is selected first at startup to ensure that the most important operating system or boot device is tried to start first. When the boot order is included in the boot item file, the boot order in the boot item file can be displayed through the firmware interface. Optionally, the user can also manually adjust the boot order through the firmware interface or command line tool. The embodiments of the present application are not specifically limited.

[0165] S590, register the processing procedure.

[0166] Register handlers to enable the virtual machine to automatically perform actions when specific events occur.

[0167] Therefore, EDK2 can effectively manage the startup process of the virtual machine and ensure that the virtual machine enters the operating system smoothly.

[0168] Furthermore, an embodiment of the present application provides a device for starting a virtual machine. Figure 6 A schematic diagram of the structure of a virtual device provided in an embodiment of the present application. The device 600 includes:

[0169] The determining unit 601 is used to determine the boot device connected to the virtual machine after the virtual machine is powered on;

[0170] The acquisition unit 602 is used to acquire operating system information and loading path information according to the boot device; the loading path information includes acquiring the file path of the extensible firmware interface EFI file, or acquiring the file path of the boot loader;

[0171] A generating unit 603 is used to generate a boot entry file of the virtual machine according to the operating system information and the loading path information;

[0172] The saving unit 604 is used to save the boot item file to the virtual machine, so that the virtual machine loads the operating system based on the boot item corresponding to the boot item file.

[0173] In a specific implementation, the generation unit 603 is specifically used to: generate a boot item file based on the boot item configuration template according to the operating system information and the loading path information; the boot item configuration template includes a system information adding position and a path information adding position, the system information adding position is used to add the operating system information, and the path information adding position is used to add the loading path information.

[0174] In a specific implementation, if the boot item configuration template also includes a boot order position and a boot priority position; the boot order position is used to add the boot order of the boot item, the boot priority position is used to add the boot priority of the boot item, the boot priority is used to determine the execution order, and the boot order is used to determine the startup order of multiple operating systems; the generation unit 603 is specifically used to: add the operating system name to the operating system name position in the boot item configuration template, add the file path to the file path position in the boot item configuration template, add the boot order to the boot order position in the boot configuration template, and add the boot priority to the boot priority position in the boot item configuration template; based on the added boot item configuration template, generate a boot item file.

[0175] In another specific implementation, if the boot item configuration template also includes a boot information location, the boot information location is used to add a boot configuration file, and the generation unit 603 is also used to: obtain the boot configuration file; the boot configuration file includes information associated with the corresponding EFI file configured for each operating system; add the operating system name to the operating system name position in the boot item configuration template, add the file path to the file path position in the boot item configuration template, and add the boot configuration file to the configuration file position in the boot item configuration template; and generate a boot item file based on the added boot item configuration template.

[0176] In another implementation, the startup device further includes a detection unit, which is used to detect whether the boot item is abnormal; the determination unit is specifically used to determine the boot device connected to the virtual machine if the boot item is detected to be abnormal.

[0177] In another implementation, the acquisition unit 602 is specifically used to: mount the partition of the boot device; the partition of the boot device includes an EFI partition; extract the characteristic files of the operating system from each mounted partition and record the operating system information; extract the EFI file from the EFI partition and record the file path of the extracted EFI file.

[0178] In another implementation, the boot device further includes a deleting unit, which is used to: determine an invalid boot item file in the boot item file; delete the invalid boot item file from the boot item file to obtain the boot item file to be saved;

[0179] The saving unit 604 is specifically used to save the boot item file to be saved into a UEFI variable storage file dedicated to the virtual machine.

[0180] The embodiment of the present application also provides a computer program product including instructions. The computer program product may be a software or program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on a computing device, the computing device is caused to execute the startup method of the above-mentioned virtual machine. The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium may be any available medium that can be stored by a computing device or a data storage device such as a data center containing one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc. The computer-readable storage medium includes instructions that instruct the computing device to execute the startup method of the above-mentioned virtual machine.

[0181] The descriptions of the processes or structures corresponding to the above-mentioned figures have different emphases. For parts that are not described in detail in a certain process or structure, please refer to the relevant descriptions of other processes or structures.

[0182] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A method for starting a virtual machine, characterized in that: The method comprises: After the virtual machine is powered on, determining a boot device connected to the virtual machine; According to the boot device, obtain operating system information and loading path information; the loading path information includes obtaining the file path of the extensible firmware interface EFI file, or obtaining the file path of the boot loader; Generate a boot entry file of the virtual machine according to the operating system information and the loading path information; The boot entry file is saved in the virtual machine, so that the virtual machine loads an operating system based on the boot entry file.

2. The startup method according to claim 1, characterized in that: The step of generating a boot entry file of the virtual machine according to the operating system information and the loading path information includes: According to the operating system information and the loading path information, the boot item file is generated based on a boot item configuration template; the boot item configuration template includes a system information adding position and a path information adding position, the system information adding position is used to add the operating system information, and the path information adding position is used to add the loading path information.

3. The startup method according to claim 2, characterized in that: The boot item configuration template also includes a boot order position and a boot priority position; the boot order position is used to add the boot order of the boot item, the boot priority position is used to add the boot priority of the boot item, the boot priority is used to determine the execution order, and the boot order is used to determine the startup order of the multiple operating systems; The step of generating the boot item file according to the operating system information and the loading path information and based on a boot item configuration template includes: Add the operating system name to the operating system name position in the boot item configuration template, add the file path to the file path position in the boot item configuration template, add the boot order to the boot order position in the boot configuration template, and add the boot priority to the boot priority position in the boot item configuration template; based on the added boot item configuration template, generate the boot item file.

4. The startup method according to claim 3, characterized in that: The boot item configuration template also includes a boot information location, and the boot information location is used to add a boot configuration file. The method also includes: Obtaining a boot configuration file; the boot configuration file includes information associated with a corresponding EFI file configured for each operating system; According to the operating system information and the loading path information, based on the boot item configuration template, the boot item file is generated, including: Add the operating system name to the operating system name position in the boot item configuration template, add the file path to the file path position in the boot item configuration template, and add the boot configuration file to the configuration file position in the boot item configuration template; generate the boot item file based on the added boot item configuration template.

5. The startup method according to claim 1, characterized in that: Before determining the boot device connected to the virtual machine, the method further includes: Check whether the boot item is abnormal; The determining a boot device connected to the virtual machine includes: If the boot item is detected to be abnormal, the boot device connected to the virtual machine is determined.

6. The startup method according to claim 1, characterized in that: The obtaining of operating system information and loading path information according to the boot device includes: Mounting the partition of the boot device; the partition of the boot device includes an EFI partition; Extracting characteristic files of the operating system from each mounted partition and recording the operating system information; The EFI file is extracted from the EFI partition, and the file path of the extracted EFI file is recorded.

7. The startup method according to any one of claims 1 to 6, characterized in that: The method further comprises: Determine an invalid boot item file in the boot item file; Deleting the invalid boot item file from the boot item file to obtain the boot item file to be saved; The step of saving the boot item file to the virtual machine includes: The boot item file to be saved is saved in the virtual machine.

8. The startup method according to claim 1, characterized in that: The operating system information includes at least one of the type and version information of the operating system and the name of the operating system.

9. A virtual machine startup device, characterized in that: The device comprises: a determining unit, configured to determine a boot device connected to the virtual machine after the virtual machine is powered on; an acquisition unit, configured to acquire operating system information and loading path information according to the boot device; the loading path information includes acquiring a file path of an extensible firmware interface EFI file, or acquiring a file path of a boot loader; a generation unit, configured to generate a boot entry file of the virtual machine according to the operating system information and the loading path information; A saving unit is used to save the boot entry file to the virtual machine, so that the virtual machine loads the operating system based on the boot entry file.

10. A computing device, characterized in that: The computing device includes a memory and a processor; The memory is coupled to the processor; The memory is used to store computer programs; the processor executes the startup method according to any one of claims 1 to 8 based on the programs stored in the memory.