Virtual machine operation method and device and computer equipment

By detecting the label of virtual machine instances in Kubernetes and determining the host pass-through mode, traditional Kubernetes has solved the problem of limited support for virtual machine management and scheduling for traditional Kubernetes, and the efficient operation of virtual machines on the host is achieved, reducing resource overhead.

CN120066677APending Publication Date: 2025-05-30CHINA TELECOM CORP LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510116011.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-23
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

The traditional Kubernetes framework has limited support for the management and scheduling of virtual machines, resulting in low-efficiency and high resource overhead in scenarios where high performance or direct access to hardware resources are required.

Method used

By detecting the label of the virtual machine instance, determine that its operating mode is host pass-through mode, and check whether the virtual machine's network configuration meets the preset conditions. If it matches, run the virtual machine on the marked host and access the physical resources directly bypass the container layer.

Benefits of technology

It realizes the direct operation of virtual machines on the host, which reduces the resource overhead of virtual machines running, improves performance, and meets the direct control needs of hardware resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120066677A_ABST
    Figure CN120066677A_ABST
Patent Text Reader

Abstract

The invention discloses a virtual machine operation method and device and computer equipment. The method comprises the steps that a label of a virtual machine instance is detected, and the label is used for indicating an operation mode of a virtual machine; under the condition that the label indicates that the operation mode of the virtual machine is the host machine direct connection mode, detecting whether the network configuration of the virtual machine corresponding to the virtual machine instance meets a preset condition or not; a marked host machine is determined, and the marked host machine can directly run the virtual machine; and under the condition that the network configuration of the virtual machine corresponding to the virtual machine instance meets a preset condition, running the virtual machine on the marked host machine.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and more particularly, to a virtual machine operation method, apparatus, and computer device. Background Art

[0002] With the rapid development of cloud computing and containerization technologies, Kubernetes (an open-source container orchestration and management platform), as a leader in the field of container orchestration, has occupied a core position in the application deployment and management in data centers and cloud environments. Through its powerful scheduling, management, and automation capabilities, Kubernetes has greatly simplified the deployment and operation and maintenance of container applications. However, the traditional Kubernetes framework mainly targets container applications, and its support for the management and scheduling of virtual machines (VMs) is relatively limited. However, in some scenarios, such as high-performance computing, graphics processing, real-time applications, or workloads with specific requirements for physical resources, using traditional container technologies may not meet the requirements. Therefore, integrating virtual machines into the Kubernetes ecosystem has become an important research direction and practical field in recent years. KubeVirt (a virtual machine operation and management project) was born precisely to solve this problem. KubeVirt provides a mechanism for running virtual machines in a Kubernetes cluster. It maps virtual machines to Kubernetes resources, enabling users to use the scheduling and management capabilities of Kubernetes to operate virtual machines just like operating containers. However, the default mode of KubeVirt is container-based, that is, virtual machines run in the virt-launcher Pod of KubeVirt, which introduces additional virtualization and containerization layers. Although it provides flexibility, it also brings performance loss and resource overhead, especially in scenarios where direct access to hardware resources or strict performance requirements are needed. In addition, when the container layer of Kubernetes performs resource scheduling and management, it may increase additional complexity and failure points, especially for applications that have direct control requirements for hardware resources, such as GPU acceleration, access to specific hardware devices, or high-real-time applications. The original KubeVirt mode cannot meet these requirements or has performance bottlenecks. Summary of the Invention

[0003] Embodiments of this application provide a virtual machine operation method, apparatus, and computer device to at least solve the technical problem of excessive resource overhead in running virtual machines in related technologies.

[0004] According to one aspect of the embodiments of the present application, a method for running a virtual machine is provided, including: detecting a label of a virtual machine instance, where the label is used to indicate the running mode of the virtual machine; when the label indicates that the running mode of the virtual machine is the host direct pass-through mode, detecting whether the network configuration of the virtual machine corresponding to the virtual machine instance meets a preset condition; determining a labeled host, where the labeled host can directly run the virtual machine; and when the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset condition, running the virtual machine on the labeled host.

[0005] Optionally, determining the labeled host includes: obtaining the versions of virtualization components installed in multiple hosts, and determining the host with the same virtualization component version as that in the container group as the initial host; obtaining the network configuration of the initial host, and when the initial host is configured with a detectable network, determining the initial host as the target host; and determining the labeled host based on the target host.

[0006] Optionally, determining the labeled host based on the target host includes: mounting the daemon socket libvirtd socket of the target host through the virtual machine processor daemon set virt-handler daemonset in the target host; detecting whether the libvirtd socket supports starting the virtual machine, and when the libvirtd socket supports starting the virtual machine, determining that the target host is the labeled host.

[0007] Optionally, when the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset condition, running the virtual machine on the labeled host includes: starting the container group by using a virtual machine startup component image; and scheduling the container group to the labeled host to start the virtual machine.

[0008] Optionally, scheduling the container group to the labeled host to start the virtual machine includes: sending the virtual machine instance to the virtual machine processor by using the container group, where the virtual machine instance includes: the configuration information of the virtual machine, the storage resources accessible to the virtual machine, and the network configuration required by the virtual machine; obtaining the configuration information of the labeled host from the virtual machine processor by using the container group, where the configuration information of the labeled host at least includes: the persistent volume claim PVC information of the labeled host and the network information of the labeled host; and completing the startup of the virtual machine by using the container group according to the configuration information of the virtual machine and the configuration information of the labeled host.

[0009] Optionally, the container group is used to obtain the configuration information of the tagged host from the virtual machine processor, including: using the virtual machine processor to obtain the persistent volume claim (PVC) information of the tagged host from the container storage interface (CSI) plugin, where the PVC information includes: the actual mounted directory of the PVC on the tagged host or the storage path of the PVC block; when the network type of the virtual machine is SR-IOV network, obtaining the PCI address information of the tagged host; when the network type of the virtual machine is bridge network, obtaining the actual bridge name of the tagged host.

[0010] Optionally, the container group is used to complete the startup of the virtual machine according to the configuration information of the virtual machine and the configuration information of the tagged host, including: generating a virtual machine configuration definition file according to the configuration information of the virtual machine and the configuration information of the tagged host; starting the virtualization component according to the virtual machine configuration definition file to start the virtual machine.

[0011] Optionally, the method further includes: obtaining the running state of the virtual machine through an observer container in the container group; when the running state of the virtual machine indicates that the virtual machine escapes from the preset management scope, converting the observer container into a proxy mode to shut down the tagged host.

[0012] According to another aspect of the embodiments of the present application, there is also provided a virtual machine running device, including: a first detection module, configured to detect the label of the virtual machine instance, where the label is used to indicate the running mode of the virtual machine; a second detection module, configured to detect whether the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset conditions when the label indicates that the running mode of the virtual machine is the host direct pass-through mode; a determination module, configured to determine the tagged host, where the tagged host can directly run the virtual machine; a running module, configured to run the virtual machine on the tagged host when the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset conditions.

[0013] According to yet another aspect of the embodiments of the present application, there is also provided a computer device, including: a memory and a processor, where the memory is used to store program instructions; the processor is connected to the memory and is configured to execute the above virtual machine running method.

[0014] According to still another aspect of the embodiments of the present application, there is also provided a non-volatile storage medium, which includes a stored computer program, where the device where the non-volatile storage medium is located executes the above virtual machine running method by running the computer program.

[0015] According to another aspect of the embodiments of the present application, there is also provided a computer program product, including computer instructions, which implement the above-mentioned virtual machine running method when executed by a processor.

[0016] In the embodiments of the present application, by detecting the tags of virtual machine instances, where the tags are used to indicate the running mode of the virtual machine; when the tags indicate that the running mode of the virtual machine is the host direct pass-through mode, detecting whether the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset conditions; determining the marked host, where the marked host can directly run the virtual machine; when the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset conditions, running the virtual machine on the marked host, thereby achieving the purpose of directly running the virtual machine on the marked host, thus realizing the technical effect of reducing the resource overhead of running the virtual machine, and further solving the technical problem of too high resource overhead of running the virtual machine in the related art. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments and descriptions thereof of the present application are used to explain the present application and do not constitute an improper limitation of the present application. In the drawings:

[0018] Figure 1 is a hardware structure block diagram of a computer terminal for implementing the virtual machine running method according to the embodiments of the present application;

[0019] Figure 2 is a flowchart of a virtual machine running method according to the embodiments of the present application;

[0020] Figure 3 is a structural diagram of a virtual machine running device according to the embodiments of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0021] In order to enable those skilled in the art to better understand the solution of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0022] It should be noted that the terms "first", "second", etc. in the description, claims and the above-mentioned drawings of this application are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of this application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0023] The information collected in the embodiments of this application is information and data authorized by the user or fully authorized by all parties. And for the processing of relevant data such as collection, storage, use, processing, transmission, provision, disclosure and application, etc., all comply with the relevant laws, regulations and standards of the relevant regions, take necessary confidentiality measures, do not violate public order and good customs, and provide corresponding operation entrances for users to choose to authorize or reject the automated decision-making results; if the user chooses to reject, then enter the expert decision-making process.

[0024] To solve the problems existing in the related art, the embodiments of this application provide a virtual machine running method, which can run on Figure 1 the computer terminal shown below. The following is an explanatory description of this computer terminal.

[0025] The embodiments of the virtual machine running method provided by the embodiments of this application can be executed on a mobile terminal, a computer terminal or a similar computing device. Figure 1 The following shows a hardware structure block diagram of a computer terminal for implementing the virtual machine running method. As Figure 1 shown, the computer terminal 10 may include one or more processors (the processors may include, but are not limited to, processing devices such as a microprocessor MCU or a programmable logic device FPGA, shown as 102a, 102b,..., 102n in the figure), a memory 104 for storing data, and a transmission module 106 for communication functions connected by wired and / or wireless networks. In addition, it may further include: a display, a keyboard, a cursor control device, an input / output interface (I / O interface), a universal serial bus (USB) port (which can be included as one of the ports of the I / O interface), a network interface, and a BUS bus. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only schematic and does not limit the structure of the above-mentioned electronic device. For example, the computer terminal 10 may further include more or fewer components than Figure 1 shown in the figure, or have a structure different from Figure 1The different configurations shown.

[0026] It should be noted that one or more of the above processors and / or other data processing circuits can generally be referred to as "data processing circuits" herein. The data processing circuit can be embodied in software, hardware, firmware, or any combination thereof, in whole or in part. In addition, the data processing circuit can be a single independent processing module, or be incorporated in whole or in part into any one of the other elements in the computer terminal 10. As involved in the embodiments of the present application, the data processing circuit is a kind of processor control (such as the selection of a variable resistance terminal path connected to an interface).

[0027] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the virtual machine running method in the embodiments of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implements the above virtual machine running method. The memory 104 can include high-speed random access memory, and can also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory 104 can further include a memory remotely disposed relative to the processor, and these remote memories can be connected to the computer terminal 10 through a network. Examples of the above network include but are not limited to the Internet, intranet, local area network, mobile communication network, and combinations thereof.

[0028] The transmission module 106 is used to receive or send data via a network. Specific examples of the above network can include the wireless network provided by the communication provider of the computer terminal 10. In one instance, the transmission module 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station and thus communicate with the Internet. In one instance, the transmission module 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0029] The display can be, for example, a touch-screen liquid crystal display (LCD), which enables the user to interact with the user interface of the computer terminal 10.

[0030] It should be noted here that in some alternative embodiments, the above Figure 1 shown computer terminal can include hardware elements (including circuits), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware elements and software elements. It should be pointed out that Figure 1This is just an example of a specific concrete instance and is intended to illustrate the types of components that can exist in the above computer terminal.

[0031] Under the above operating environment, an embodiment of the present application provides an embodiment of a virtual machine running method. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And, although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.

[0032] Figure 2 is a flowchart of a virtual machine running method according to an embodiment of the present application, as Figure 2 shown, the method includes the following steps:

[0033] Step S202, detecting the label of the virtual machine instance, where the label is used to indicate the running mode of the virtual machine;

[0034] In step S202, the label kubevirt.io / vmRunMode of the virtual machine instance is set to the host mode, indicating that the running mode of the virtual machine is the host direct pass-through mode. In the host direct pass-through mode, it means that the virtual machine can directly run in the host and directly access and utilize the physical resources of the host.

[0035] Step S204, when the label indicates that the running mode of the virtual machine is the host direct pass-through mode, detecting whether the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset conditions;

[0036] In step S204, the network configuration of the virtual machine at least includes: when a detectable network is configured, such as an SR-IOV (Single Root I / O Virtualization) network or a bridge network, it is determined that the network configuration of the virtual machine meets the preset conditions.

[0037] Step S206, determining the labeled host, where the labeled host can directly run the virtual machine;

[0038] In step S206, the host is added with the label kubevirt.io / host-schedulable = true, indicating that the host is labeled and can directly run the virtual machine. It can be understood that the host can directly run the virtual machine means that the host can bypass the container layer to run the virtual machine, and the virtual machine can directly access and utilize the physical resources of the host.

[0039] Step S208: When the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset conditions, run the virtual machine on the marked host.

[0040] Through the above steps S202 to S208, by detecting the label of the virtual machine instance, where the label is used to indicate the running mode of the virtual machine; when the label indicates that the running mode of the virtual machine is the host direct mode, detecting whether the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset conditions; determining the marked host, where the marked host can directly run the virtual machine; when the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset conditions, running the virtual machine on the marked host, thereby achieving the purpose of directly running the virtual machine on the marked host, thus realizing the technical effect of reducing the resource overhead of running the virtual machine, and further solving the technical problem of too high resource overhead of running the virtual machine in the related art. The following is a detailed description.

[0041] In some embodiments of the present application, the specific process of determining the marked host is as follows: Obtain the versions of the virtualization components installed in multiple hosts, and determine the host with the same version of the virtualization component as that in the container group as the initial host; obtain the network configuration of the initial host, and when the initial host is configured with a detectable network, determine the initial host as the target host; determine the marked host based on the target host.

[0042] Specifically, ensure that the versions of the virtualization components installed on the marked host, such as libvirtd (a daemon process) and qemu (an open-source machine emulator and virtual machine monitor), are the same as those of the virtualization components installed inside the container group, such as virt-launcher Pod (a virtual machine launcher container group), which is to ensure cross-component compatibility and avoid potential problems caused by version differences. The host must be configured with a detectable network, such as an SR-IOV network or a predefined bridge network.

[0043] In some embodiments of the present application, the specific steps of determining the marked host based on the target host are as follows: Mount the daemon socket libvirtd socket of the target host through the virtual machine processor daemon set virt-handler daemonset in the target host; detect whether the libvirtd socket supports starting the virtual machine, and when the libvirtd socket supports starting the virtual machine, determine that the target host is the marked host.

[0044] Specifically, when the virt-handler daemonset of the virtual machine processor in the target host starts, it mounts the libvirtd socket and detects the libvirtd socket. When it detects that the libvirtd socket supports starting a virtual machine, the virt-handler (virtual machine processor) adds the label kubevirt.io / host-schedulable=true to the current target host, indicating that the target host has the ability to directly start a virtual machine.

[0045] In some embodiments of the present application, when the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset conditions, running the virtual machine on the marked host includes: starting a container group using a virtual machine startup component image; scheduling the container group to the marked host to start the virtual machine.

[0046] Specifically, a virtual machine startup component image, such as the virt-launcher-host (virtual machine launcher in host mode) image, can be used to start a container group and schedule the container group to the marked host.

[0047] In some embodiments of the present application, the specific steps of scheduling the container group to the marked host to start the virtual machine are as follows: sending the virtual machine instance to the virtual machine processor using the container group, where the virtual machine instance includes: the configuration information of the virtual machine, the storage resources accessible by the virtual machine, and the network configuration required by the virtual machine; obtaining the configuration information of the marked host from the virtual machine processor using the container group, where the configuration information of the marked host at least includes: the persistent volume claim PVC information of the marked host and the network information of the marked host; using the container group to complete the startup of the virtual machine according to the configuration information of the virtual machine and the configuration information of the marked host.

[0048] Specifically, after the container group is scheduled to the marked host, the container group is also used to synchronize the information of the virtual machine instance with the virt-handler (virtual machine processor), for example, synchronizing the PVC information and network information.

[0049] It should also be noted that the specific steps for the container group to obtain the configuration information of the marked host from the virtual machine processor are as follows: The virtual machine processor obtains the Persistent Volume Claim (PVC) information of the marked host from the Container Storage Interface (CSI) plug-in. The PVC information includes: the actual mount directory of the PVC on the marked host or the storage path of the PVC block. When the network type of the virtual machine is SR-IOV network, obtain the PCI address information of the marked host. When the network type of the virtual machine is bridge network, obtain the actual bridge name of the marked host.

[0050] It can be understood that the network information includes: the PCI address information of the marked host or the actual bridge name of the marked host.

[0051] Specifically, when virt-handler processes a virtual machine instance, it will detect the type of the Persistent Volume Claim (PVC) associated with the virtual machine instance; obtain the CSI mount directory or PVC block path: According to the type of the PVC, virt-handler will obtain the mount directory from the Container Storage Interface (CSI) plug-in, or directly obtain the block device path of the PVC, ensuring that the virtual machine can correctly access the storage resources in the marked host, and the mapping of the storage resources is consistent with the actual situation on the host.

[0052] The process of obtaining the PCI address for SR-IOV network is as follows: For the SR-IOV network type, virt-handler will obtain the PCI address information of the marked host so that the virtual machine can directly access the physical network device of the marked host, improving network performance.

[0053] Obtaining the actual bridge name for bridge network: For the bridge-based network type, virt-handler will obtain the actual bridge name to ensure the accuracy of the virtual machine network configuration, enabling it to start and run correctly in the network environment of the marked host.

[0054] In some embodiments of the present application, the container group completes the startup of the virtual machine according to the configuration information of the virtual machine and the configuration information of the marked host, including: generating a virtual machine configuration definition file according to the configuration information of the virtual machine and the configuration information of the marked host; starting the virtualization component according to the virtual machine configuration definition file to start the virtual machine.

[0055] It should be noted that the virt-launcher-host Pod is developed based on the virt-launcher code. After being scheduled to the labeled host, it mounts the libvirtd socket of the labeled host. It is responsible for synchronizing virtual machine instance information with the virt-handler. After obtaining the information of the labeled host from the virt-handler, according to the configuration information of the virtual machine and the configuration information of the labeled host, it uses the libvirt (free virtualization library) API of the Go language to generate and define the libvirt XML (virtual machine configuration definition file) configuration file, and operates the libvirtd to start the virtualization components, such as qemu-kvm, to start the virtual machine. This part ensures that the startup and management processes of the VM are tightly integrated with the host resources and are consistent with the original virtual machine startup process. In addition to the above customized startup and management processes, for other operations of the virtual machine, such as startup, stop, migration, monitoring, etc., the original virt-launcher Pod processing flow code will continue to be reused and implemented using the libvirt API of the Go language to ensure compatibility and consistency with the existing ecosystem.

[0056] The embodiment of the present application also provides a method for monitoring the running state of a virtual machine as follows: obtaining the running state of the virtual machine through the observer container in the container group; in the case where the running state of the virtual machine indicates that the virtual machine escapes from the preset management range, converting the observer container into a proxy mode to shut down the labeled host.

[0057] Specifically, in the virt-handler Pod, a Watcher (observer) container is introduced to monitor the state of the virtual machines running on the host in real time.

[0058] If the virtual machine escapes from the management range of the virt-launcher-host, the virt-launcher-host will be destroyed, but the virtual machine cannot be managed. The Watcher container will switch to the handler proxy mode and take actions as needed, such as forced shutdown, to maintain the stability and security of the system.

[0059] The virtual machine running method of the present application realizes that when the running mode of VMI is specified as the host mode, the virt-launcher-host Pod will be scheduled to the host with the label kubevirt.io / host-schedulable=true. The virt-launcher-host Pod starts and manages the virtual machine by directly operating on libvirtd and host resources, avoiding the overhead of the container layer and providing a higher-performance virtual machine running environment. Collaboration with virt-handler: The virt-launcher-host Pod collaborates with the virt-handler and its Watcher container to ensure that operations such as the startup, resource allocation, status monitoring, and management of the virtual machine can be executed accurately and efficiently.

[0060] Through the above steps, KubeVirt can effectively and securely start and manage virtual machines in the host environment while maintaining a tight integration with the advanced features and resource management mechanisms of the Kubernetes cluster.

[0061] It should be noted that the virtual machine startup and management on the marked host by the virtual machine running method provided by the present application: By introducing specific labels and images in the KubeVirt environment, the ability to start virtual machines on the preselected host is realized. It ensures compatibility with host resources, and also realizes the precise scheduling of virtual machines through a specific label mechanism, and can be compatible with the original mode. By adding the synchronization logic for host network and storage resources, it ensures that virtual machines can accurately access and utilize the network and storage resources on the host. By adding a Watcher container to the virt-handler Pod, the invention can monitor the status of virtual machines running on the host in real time, effectively preventing potential security risks. It avoids the resource overhead of Kubernetes scheduling and container runtime, and utilizes the original kubevirt ecosystem to maximize the performance of specific virtual machines and meet the requirements of specific applications, such as GPU acceleration, direct access to specific hardware devices, virtual machine real-time performance, etc. Running virtual machines on the host allows for more refined hardware configuration and adjustment. It reduces the overhead of starting libvirt-related processes brought by the original virt-launcher.

[0062] Figure 3 It is a virtual machine running device according to an embodiment of the present application. The device includes:

[0063] A first detection module 30, configured to detect the label of the virtual machine instance, where the label is used to indicate the running mode of the virtual machine;

[0064] The second detection module 32 is configured to detect whether the network configuration of the virtual machine corresponding to the virtual machine instance meets a preset condition when the label indicates that the running mode of the virtual machine is the host direct pass-through mode;

[0065] The determination module 34 is configured to determine the labeled host, where the labeled host can directly run the virtual machine;

[0066] The running module 36 is configured to run the virtual machine on the labeled host when the network configuration of the virtual machine corresponding to the virtual machine instance meets a preset condition.

[0067] Through the above virtual machine running device, by detecting the label of the virtual machine instance, where the label is used to indicate the running mode of the virtual machine; when the label indicates that the running mode of the virtual machine is the host direct pass-through mode, detecting whether the network configuration of the virtual machine corresponding to the virtual machine instance meets a preset condition; determining the labeled host, where the labeled host can directly run the virtual machine; when the network configuration of the virtual machine corresponding to the virtual machine instance meets a preset condition, running the virtual machine on the labeled host, so as to achieve the purpose of directly running the virtual machine on the labeled host, thereby realizing the technical effect of reducing the resource overhead of running the virtual machine, and further solving the technical problem of too high resource overhead of running the virtual machine in the related art.

[0068] The determination module 34 includes: a determination sub-module, configured to obtain the versions of the virtualization components installed in multiple hosts, and determine the host with the same version of the virtualization component as that in the container group as the initial host; obtain the network configuration of the initial host, and when the initial host is configured with a detectable network, determine the initial host as the target host; determine the labeled host based on the target host.

[0069] The determination sub-module includes: a determination unit, configured to determine the labeled host based on the target host, including: mounting the daemon socket libvirtd socket of the target host through the virtual machine processor daemon set virt-handler daemonset in the target host; detecting whether the libvirtd socket supports starting the virtual machine, and when the libvirtd socket supports starting the virtual machine, determining to run the target host as the labeled host.

[0070] The running module 36 includes: a running sub-module, which is used to run the virtual machine on the marked host when the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset conditions, including: starting a container group by using a virtual machine startup component image; scheduling the container group to the marked host to start the virtual machine.

[0071] The running sub-module includes: a startup unit, which is used to schedule the container group to the marked host to start the virtual machine, including: sending the virtual machine instance to the virtual machine processor by using the container group, where the virtual machine instance includes: the configuration information of the virtual machine, the storage resources accessible to the virtual machine, and the network configuration required by the virtual machine; obtaining the configuration information of the marked host from the virtual machine processor by using the container group, where the configuration information of the marked host at least includes: the persistent volume claim PVC information of the marked host and the network information of the marked host; completing the startup of the virtual machine by using the container group according to the configuration information of the virtual machine and the configuration information of the marked host.

[0072] The startup unit includes: a configuration sub-unit and a startup sub-unit. Among them, the configuration sub-unit is used to obtain the configuration information of the marked host from the virtual machine processor by using the container group, including: obtaining the persistent volume claim PVC information of the marked host from the storage interface plugin CSI by using the virtual machine processor, where the PVC information includes: the actual mounting directory of the PVC on the marked host or the storage path of the PVC block; obtaining the PCI address information of the marked host when the network type of the virtual machine is an SR-IOV network; obtaining the actual bridge name of the marked host when the network type of the virtual machine is a bridge network.

[0073] The startup sub-unit is used to complete the startup of the virtual machine by using the container group according to the configuration information of the virtual machine and the configuration information of the marked host, including: generating a virtual machine configuration definition file according to the configuration information of the virtual machine and the configuration information of the marked host; starting the virtualization component according to the virtual machine configuration definition file to start the virtual machine.

[0074] The virtual machine running device further includes: a monitoring sub-module, which is used to obtain the running state of the virtual machine through the observer container in the container group; when the running state of the virtual machine indicates that the virtual machine escapes from the preset management range, converting the observer container into a proxy mode to shut down the marked host.

[0075] It should be noted that Figure 3The virtual machine running device shown is used to execute Figure 2 the virtual machine running method shown. Therefore, the relevant explanations in the above virtual machine running method also apply to this virtual machine running device, and will not be elaborated here.

[0076] An embodiment of the present application also provides a computer device, including: a memory and a processor. Among them, the memory is used to store program instructions; the processor is connected to the memory and is used to execute the above virtual machine running method.

[0077] An embodiment of the present application also provides a non-volatile storage medium, which includes a stored computer program. Among them, the device where the non-volatile storage medium is located executes the above virtual machine running method by running the computer program.

[0078] An embodiment of the present application also provides a computer program product, including computer instructions, which implement the steps of the virtual machine running method in the present application when executed by a processor.

[0079] The serial numbers of the above embodiments of the present application are only for description and do not represent the advantages or disadvantages of the embodiments.

[0080] In the above embodiments of the present application, the descriptions of each embodiment have their own focuses. For the parts not elaborated in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0081] In several embodiments provided by the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only illustrative. For example, the division of the units can be a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of units or modules can be in an electrical or other form.

[0082] The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0083] In addition, in each embodiment of the present application, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.

[0084] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The foregoing storage medium includes: various media that can store program codes, such as USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs.

[0085] The above are only the preferred embodiments of this application. It should be noted that for those of ordinary skill in the art, without departing from the principle of this application, several improvements and refinements can still be made, and these improvements and refinements should also be regarded as the protection scope of this application.

Claims

1. A method for operating a virtual machine, characterized in that: include: Detecting a tag of a virtual machine instance, wherein the tag is used to indicate an operating mode of the virtual machine; When the tag indicates that the operation mode of the virtual machine is the host machine pass-through mode, detecting whether the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset conditions; Determining a marked host machine, wherein the marked host machine can directly run the virtual machine; When the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset conditions, the virtual machine is run on the marked host machine.

2. The method according to claim 1, characterized in that Identify the marked hosts, including: Obtaining versions of virtualization components installed in multiple host machines, and determining a host machine having the same virtualization component version as the virtualization component version in the container group as an initial host machine; Acquire the network configuration of the initial host machine, and if the initial host machine is configured with a detectable network, determine the initial host machine as a target host machine; The marked host is determined based on the target host.

3. The method according to claim 2, characterized in that Determining the marked host based on the target host includes: Mounting the daemon socket libvirtd socket of the target host machine through the virtual machine processor daemon set virt-handler daemonset in the target host machine; It is detected whether the libvirtd socket supports starting a virtual machine. If the libvirtd socket supports starting a virtual machine, it is determined that the target host machine is the marked host machine.

4. The method according to claim 1, characterized in that: When the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset condition, running the virtual machine on the marked host machine includes: Use the virtual machine startup component image to start the container group; The container group is scheduled to the marked host machine to start the virtual machine.

5. The method according to claim 4, characterized in that Scheduling the container group to the marked host machine to start the virtual machine includes: The container group is used to send the virtual machine instance to the virtual machine processor, where the virtual machine instance includes: configuration information of the virtual machine, storage resources accessible to the virtual machine, and network configuration required by the virtual machine; The container group is used to obtain configuration information of the marked host machine from the virtual machine processor, wherein the configuration information of the marked host machine at least includes: persistent volume declaration PVC information of the marked host machine and network information of the marked host machine; The container group is used to complete the startup of the virtual machine according to the configuration information of the virtual machine and the configuration information of the marked host machine.

6. The method according to claim 5, characterized in that The container group is used to obtain configuration information of the marked host machine from the virtual machine processor, including: The virtual machine processor is used to obtain the persistent volume declaration PVC information of the marked host from the storage interface plug-in CSI, wherein the PVC information includes: the actual mounting directory of the PVC on the marked host or the storage path of the PVC block; When the network type of the virtual machine is an SR-IOV network, obtaining PCI address information of the marked host machine; When the network type of the virtual machine is a bridge network, the actual bridge name of the marked host machine is obtained.

7. The method according to claim 5, characterized in that The container group is used to start the virtual machine according to the configuration information of the virtual machine and the configuration information of the marked host machine, including: Generate a virtual machine configuration definition file according to the configuration information of the virtual machine and the configuration information of the marked host machine; The virtualization component is started according to the virtual machine configuration definition file to start the virtual machine.

8. The method according to claim 7, characterized in that The method further comprises: Obtaining the running status of the virtual machine through the observer container in the container group; When the running state of the virtual machine indicates that the virtual machine has escaped from a preset management scope, the observer container is converted to a hosting mode to shut down the marked host machine.

9. A virtual machine operation device, characterized in that: include: A first detection module, configured to detect a label of a virtual machine instance, wherein the label is used to indicate an operation mode of the virtual machine; A second detection module is used to detect whether the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset conditions when the label indicates that the operation mode of the virtual machine is the host machine pass-through mode; A determination module, used to determine a marked host machine, wherein the marked host machine can directly run the virtual machine; The running module is used to run the virtual machine on the marked host machine when the network configuration of the virtual machine corresponding to the virtual machine instance meets the preset conditions.

10. A computer device, characterized in that: include: A memory and a processor, wherein the memory is used to store program instructions; The processor is connected to the memory, and is used to execute the virtual machine operation method described in any one of claims 1 to 8.

11. A computer program product comprising computer instructions, characterized in that: When the computer instructions are executed by a processor, the virtual machine operation method described in any one of claims 1 to 8 is implemented.