Virtual machine management method and system based on QGA and KubeVirt
By combining QEMU's QGA tool and KubeVirt, extending KubeVirt's API interface and using gRPC remote procedure calls, the limitations of existing virtual machine management solutions in command control, internal interaction and life cycle management are solved, and flexible and efficient virtual machine management is achieved.
Patent Information
- Application Number
- CN202510071869.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-16
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2045-01-16
AI Technical Summary
The existing virtual machine management solutions have many limitations in execution command control, internal virtual machine interaction, life cycle management, etc., and lack flexible command execution mechanisms and direct internal virtual machine operation support.
By combining QEMU's QGA tools and KubeVirt, KubeVirt's API interface is extended, and command control from the host to the virtual machine is implemented using gRPC remote procedure calls and QGA commands, providing a new command execution mechanism, and simplifying the management operation process of the virtual machine.
It realizes a more flexible, efficient and convenient virtual machine operation control mechanism, meets the refined management needs of virtual machines, enhances the flexibility of virtual machine life cycle control, simplifies the interaction process inside and outside the virtual machine, and improves user experience and compatibility.
Smart Images

Figure CN120010993A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of virtual machine management, and in particular to a virtual machine management method and system based on QGA and KubeVirt. Background Art
[0002] Kubernetes is a widely used open source container orchestration platform that can automatically manage and deploy containerized applications. Kubernetes is widely used in cloud computing environments, helping development and operation teams improve work efficiency and simplify application management and operations by providing efficient resource management, automated scheduling, container orchestration and other functions.
[0003] Currently, the control of the life cycle of virtual machines in Kubernetes clusters mainly relies on the relevant functions of KubeVirt. KubeVirt is an open source project that extends Kubernetes. KubeVirt allows running virtual machines (VMs) in Kubernetes clusters. With KubeVirt, users can manage virtual machines like containers and deploy and schedule virtual machine applications on the Kubernetes platform. The KubeVirt project introduces the concept of virtual machines to containerized environments and supports management, scheduling, and monitoring in units of virtual machines. KubeVirt provides a more flexible and efficient management mechanism for virtual machines.
[0004] KubeVirt provides the ability to manage the lifecycle of virtual machines (VMs) by defining resources, including controlling the creation, destruction, and management of virtual machines through the Kubernetes API. However, the basic control of these management operations is mostly limited to the state management of the virtual machine, and lacks the sophisticated real-time interaction capabilities based on the internal systems of the host and the virtual machine. Currently, KubeVirt manages the lifecycle of virtual machines through the kubectl command or virtctl tool in Kubernetes. Although these methods can achieve basic operations such as creation, stopping, and restarting, there are still some obvious shortcomings in the following aspects:
[0005] 1. Most of the current virtual machine management operations are batch and global, such as stopping or restarting a virtual machine, but there is a lack of direct support for internal operations of the virtual machine (such as executing applications inside the virtual machine) and a lack of flexible command execution mechanism.
[0006] 2. Since virtual machines are isolated systems, Kubernetes' native scheduling and management functions cannot directly interact with the operating system inside the virtual machine, which limits the management and monitoring inside the virtual machine and increases the complexity of internal operation control of the virtual machine.
[0007] 3. In some complex environments, the management dependency between Kubernetes and virtual machines is large and operations are frequent. To control virtual machines in a more fine-grained manner, a more sophisticated management interface is usually required, which increases management complexity.
[0008] 4. The existing virtual machine management operation requires the administrator to manually log in to the virtual machine through SSH and execute management commands (such as resetting passwords and modifying configurations). The operation process is complicated, especially when managing multiple virtual machines. This method is cumbersome and prone to errors.
[0009] In summary, existing virtual machine management solutions still have many limitations in terms of command control execution, internal interaction of virtual machines, and lifecycle management. Summary of the invention
[0010] In view of this, the purpose of the present invention is to propose a virtual machine management method and system based on QGA and KubeVirt, and to realize a more flexible, efficient and convenient virtual machine operation control mechanism with the help of QGA tool of QEMU; to execute QGA commands through virt-handler extension service to realize KubrVirt virtual machine life cycle management; to realize command control from host machine to virtual machine through QGA and KubeVirt integration, to meet the demand for refined management of virtual machines and enhance the flexibility of virtual machine life cycle control; to provide a new command execution mechanism, in which the client initiates the request, KubeVirt receives the request and processes it to obtain QGA command, and sends commands to the operating system in the virtual machine through QGA to control the state change of the virtual machine, so as to realize the instruction transmission from host machine to virtual machine, without relying on complex API calls, and users do not need to enter the virtual machine for operation, thus simplifying the interaction process inside and outside the virtual machine; through the combination of KubeVirt and QGA, standardized QGA instructions are used to complete the management tasks inside the virtual machine, thus simplifying the management operation process of the virtual machine; users can use Kubernetes API to Sending requests is automatically processed by the KubeVirt extension program without directly calling the underlying complex API. It can be applied to a variety of virtual machine operating systems to improve compatibility. There is no need to write customized scripts for different operating systems, which improves the user experience.
[0011] QEMU (Quick Emulator) is an open source virtualization software that can simulate a variety of hardware architectures and devices and supports virtualization technologies such as KVM (Kernel-based Virtual Machine). QGA (QEMU Guest Agent) is a tool provided by QEMU. QGA allows the host machine to communicate with the operating system in the virtual machine in a two-way manner, thereby managing the life cycle of the virtual machine. QGA is usually used to handle task management within the virtual machine, including system status monitoring, log collection, command execution, etc. Through QGA, the host machine can send instructions to the virtual machine to control the life cycle of the virtual machine, such as starting, stopping, pausing, and resuming the virtual machine.
[0012] The present invention provides a virtual machine management method based on QGA and KubeVirt, comprising the following steps:
[0013] S1. Define KubeVirt's extensible API interface.
[0014] The present invention provides native support for virtual machine password management by extending the API interface of KubeVirt, solving the problem that the existing API does not support state management operations (such as password reset operations).
[0015] S2. Establish a gRPC remote procedure call between the virt-handler component and the virt-launcher component of KubeVirt, and the virt-launcher component executes the virtual machine status management command;
[0016] S3. Writing a processing function for the defined API interface in the virt-handler component of KubeVirt to execute the actual QGA command for virtual machine state management.
[0017] Specifically, QGA commands are sent through the virt-handler extension to achieve state management (lifecycle control) of virtual machines managed by KubeVirt.
[0018] Furthermore, the method of defining the extensible API interface of KubeVirt in step S1 includes the following steps:
[0019] S11. Define an API interface route, create a new API sub-path for the server virtual machine instance, and through the API sub-path, the API interface is bound to the client's HTTP request (such as PUT / POST request), allowing the client to request to control the state management of the virtual machine (such as changing the password of the virtual machine);
[0020] The existing KubeVirt API does not directly provide functions for virtual machine password management, especially when remote operation is required through QGA. The preferred embodiment of the present invention adds the function of resetting the password of the virtual machine, so that the client can call the virtual machine password reset function through the RESTful API. Specifically, first define a new API interface in virt-api and route the API interface to the corresponding processing function. In virt-api, you can define API routes through subws.Route and add a new PUT interface to process virtual machine requests.
[0021] S12. Define request parameters of the HTTP request, where the request parameters include the namespace where the virtual machine is located and the name of the virtual machine, so that the API interface can locate a specific virtual machine for operation;
[0022] S13. Add relevant documentation for the API interface, including a functional description of the API interface (eg, "reset virtual machine password"), success and failure HTTP status codes, and corresponding messages.
[0023] Furthermore, the step S2 includes the following steps:
[0024] S21. Check whether the server virtual machine is running. If the virtual machine is running, enter the state management operation (such as resetting the password); if the virtual machine is not started, return an error;
[0025] Specifically, state management operations are allowed only for virtual machines in the Running state; by verifying the state of the virtual machine instance, it is ensured that state management operations (such as password reset) are performed only when the virtual machine is in the "Running" state, thereby avoiding operation errors or failures.
[0026] S22. By querying the connection information in the virt-handler component of KubeVirt, a URI pointing to a state management operation (such as a password reset operation) is created for the virtual machine; the path of the URI points to the virt-launcher component in the virtual machine, and the state management (such as password reset) command is executed through the path;
[0027] S23. Establish gRPC communication between the virt-handler component and the virt-launcher component of KubeVirt, so that the virt-handler component and the virt-launcher component can exchange information with high efficiency and low latency.
[0028] QGA and gRPC technologies are used to achieve efficient communication between the host and virtual machines, avoiding the problem of unsmooth cross-component communication interaction in existing technologies.
[0029] S24, the virt-handler component calls the execution command interface in the virt-launcher component to send a command for executing virtual machine status management (eg, resetting a password);
[0030] S25. After executing the state management (eg, resetting the password) command, the virt-launcher component returns an execution result, and the virt-handler component transmits the returned execution result back to the client.
[0031] Furthermore, the actual QGA command for executing the virtual machine state management in step S3 includes the following steps:
[0032] S31, before processing an HTTP request for virtual machine state management (e.g., password reset), locate the server virtual machine through request parameters in the HTTP request, obtain the server virtual machine instance object (VMI) and the client required to connect to the virtual machine execution environment;
[0033] S32. Extract the request parameters (such as password parameters) passed in by the user from the request body of the HTTP request, and perform a state management operation (such as a password reset operation) on the virtual machine; the format of the request body is JSON or YAML, and the request parameters (such as password parameters) are parsed according to the request type;
[0034] S33. After the request parameters (such as user name and password) are successfully parsed, a QGA command for executing a virtual machine state management operation (such as a password reset operation) is constructed, and the QGA command will be used to execute the state management operation (such as a password reset operation) inside the virtual machine;
[0035] S34, after the QGA command is constructed, the API interface routing is used to connect to the client, and the virtual machine state management command is executed through QGA;
[0036] This step solves the problem of command execution across virtual machines and host machines.
[0037] S35. After the virtual machine state management operation is completed, the operation event is recorded for subsequent auditing, and an HTTP response is returned to the client to notify the result of the state management operation.
[0038] Through the operation feedback and event recording mechanism, the execution process of state management operations (such as password reset operations) can be tracked and audited, providing greater operational transparency and reliability.
[0039] Furthermore, the method of parsing request parameters according to the request type in step S32 includes the following steps:
[0040] S321. Determine the format of the request body and confirm the request type by using the Content-Type field in the HTTP request header:
[0041] If the Content-Type field is Content-Type: application / json, it means that the request body is in JSON format;
[0042] If the Content-Type field is Content-Type: application / x-yaml or other specified value, it means that the request body is in YAML format;
[0043] If Content-Type is not specified, an error message is returned, indicating that the request format is not supported;
[0044] S322, decoding the request body, and using the corresponding decoding library to parse the request body into a data structure (such as a dictionary) according to the format determined by Content-Type;
[0045] The decoded request body is a data structure (such as a Python dictionary);
[0046] S323. Verify whether the parameters (such as password) extracted after decoding meet the requirements (such as length limit, character set requirements); if the verification does not meet the requirements, return an error; if the verification meets the requirements, return the decoded parameters for subsequent components (such as components that generate QGA commands) to use.
[0047] In a virtual machine password reset operation in an actual application of the present invention, in order to ensure the security of password transmission, the password is transmitted through Base64 encoding, including the following steps:
[0048] (1) On the client side, encode the plain text password entered by the user into a string using Base64;
[0049] (2) The client sends the Base64-encoded password in the request body to the server via HTTPS encrypted transmission.
[0050] (3) After receiving the Base64-encoded password, the server decodes and verifies the Base64-encoded password;
[0051] (4) The decoded original password is matched with the password stored in the database. If the match is successful, it means that the new password has passed the security check, and the password reset operation is performed; if the match is successful, it means that the new password has failed the security check, and the password reset operation is not performed.
[0052] The present invention also provides a virtual machine management system based on QGA and KubeVirt, and executes the virtual machine management method based on QGA and KubeVirt as described above, including:
[0053] API extension module: used to define the extensible API interface of KubeVirt;
[0054] gRPC call module: used to establish gRPC remote procedure calls between the virt-handler component and the virt-launcher component of KubeVirt, and the virt-launcher component executes virtual machine status management commands;
[0055] QGA command execution module: used to write a processing function for the defined API interface in the virt-handler component of KubeVirt, and to execute the actual QGA command for virtual machine state management.
[0056] The present invention also provides a computer-readable storage medium having a computer program stored thereon, and when the program is executed by a processor, the steps of the virtual machine management method based on QGA and KubeVirt as described above are implemented.
[0057] The present invention also provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of the virtual machine management method based on QGA and KubeVirt as described above are implemented.
[0058] Compared with the prior art, the present invention has the following beneficial effects:
[0059] The virtual machine management method and system based on QGA and KubeVirt provided by the present invention use the QGA tool of QEMU to realize a more flexible, efficient and convenient virtual machine operation control mechanism; through the virt-handler extension service, QGA commands are executed to realize KubrVirt virtual machine life cycle management; through the integration of QGA and KubeVirt, command control from the host machine to the virtual machine is realized, the refined management requirements of the virtual machine are met, and the flexibility of virtual machine life cycle control is enhanced; a new command execution mechanism is provided, the client initiates a request, KubeVirt receives the request and processes it to obtain the QGA command, and sends a command to the operating system in the virtual machine through QGA to control the state change of the virtual machine, such as restart, pause, configuration modification, etc., to realize the instruction transmission from the host machine to the virtual machine without relying on complex API calls, and the user does not need to enter the virtual machine to operate, which simplifies the interaction process inside and outside the virtual machine; through the combination of KubeVirt and QGA, standardized QGA instructions are used to complete the management tasks inside the virtual machine, such as restart, mount disk, modify password, etc., which simplifies the management operation process of the virtual machine; users can use the Kubernetes API The request is sent and automatically processed by the KubeVirt extension program. There is no need to directly call the underlying complex API. It can be applied to a variety of virtual machine operating systems, has stronger compatibility, and does not require customized scripts for different operating systems, thus improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the following detailed description of the preferred embodiment.The drawings are only for the purpose of illustrating the preferred embodiments and are not to be construed as limiting the invention.
[0061] In the attached picture:
[0062] Figure 1 is an interactive schematic diagram of an extended RESTful API interface according to an embodiment of the present invention;
[0063] Figure 2 It is a flow chart of the virtual machine management method based on QGA and KubeVirt of the present invention;
[0064] Figure 3 A flow chart of a method for defining an extensible API interface of KubeVirt for the present invention;
[0065] Figure 4 It is a flow chart of step S2 of the virtual machine management method based on QGA and KubeVirt of the present invention;
[0066] Figure 5A flowchart of the actual QGA command for executing virtual machine state management in the present invention;
[0067] Figure 6 A flow chart of a method for parsing request parameters according to request type according to the present invention;
[0068] Figure 7 The figure is a schematic diagram of the structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0069] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and products consistent with some aspects of the present disclosure as detailed in the appended claims.
[0070] The terms used in this disclosure are for the purpose of describing specific embodiments only and are not intended to limit the disclosure. The singular forms of "a", "said" and "the" used in this disclosure and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0071] It should be understood that although the terms first, second, third, etc. may be used in the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0072] The embodiments of the present invention are described in further detail below.
[0073] The embodiment of the present invention provides a virtual machine management method based on QGA and KubeVirt, see Figure 2 As shown, the following steps are included:
[0074] S1. Define KubeVirt's extensible API interface.
[0075] For methods to define KubeVirt's extensible API interface, see Figure 3 As shown, the following steps are included:
[0076] S11. Define an API interface route, create a new API sub-path for the server virtual machine instance, and through the API sub-path, the API interface is bound to the client's HTTP request (such as PUT / POST request), allowing the client to request to control the state management of the virtual machine (such as changing the password of the virtual machine);
[0077] This embodiment adds a function of resetting the password of the virtual machine. The client can call the virtual machine password reset function through the RESTful API (such as Figure 1 As shown in the figure, first define a new API interface in virt-api and route the API interface to the corresponding processing function. In virt-api, you can define API routes through subws.Route and add a new PUT interface to process virtual machine requests.
[0078] S12. Define request parameters of the HTTP request, where the request parameters include the namespace where the virtual machine is located and the name of the virtual machine, so that the API interface can locate a specific virtual machine for operation;
[0079] S13. Add relevant documentation for the API interface, including a functional description of the API interface (such as "reset virtual machine password"), HTTP status codes for success and failure, and corresponding messages.
[0080] This embodiment provides native support for virtual machine password management by extending the API interface of KubeVirt, solving the problem that the existing API does not support state management operations (such as password reset operations).
[0081] S2. Establish a gRPC remote procedure call between the virt-handler component and the virt-launcher component of KubeVirt, and the virt-launcher component executes the virtual machine status management command;
[0082] The S2 step includes the following steps (see Figure 4 shown):
[0083] S21. Check whether the server virtual machine is running. If the virtual machine is running, enter the state management operation (such as resetting the password); if the virtual machine is not started, return an error;
[0084] Specifically, state management operations are allowed only for virtual machines in the Running state; by verifying the state of the virtual machine instance, it is ensured that state management operations (such as password reset) are performed only when the virtual machine is in the "Running" state, thereby avoiding operation errors or failures.
[0085] S22. By querying the connection information in the virt-handler component of KubeVirt, a URI pointing to a state management operation (such as a password reset operation) is created for the virtual machine; the path of the URI points to the virt-launcher component in the virtual machine, and the state management (such as password reset) command is executed through the path;
[0086] S23. Establish gRPC communication between the virt-handler component and the virt-launcher component of KubeVirt, so that the virt-handler component and the virt-launcher component can exchange information with high efficiency and low latency.
[0087] QGA and gRPC technologies are used to achieve efficient communication between the host and virtual machines, avoiding the problem of unsmooth cross-component communication interaction in existing technologies.
[0088] S24, the virt-handler component calls the execution command interface in the virt-launcher component to send a command for executing virtual machine status management (such as resetting the password);
[0089] S25. After executing the state management (such as resetting the password) command, the virt-launcher component returns the execution result, and the virt-handler component transmits the returned execution result back to the client.
[0090] S3. Writing a processing function for the defined API interface in the virt-handler component of KubeVirt to execute the actual QGA command for virtual machine state management.
[0091] The actual QGA commands that perform virtual machine state management include the following steps (see Figure 5 shown):
[0092] S31, before processing an HTTP request for virtual machine state management (such as password reset), locate the server virtual machine through request parameters in the HTTP request, obtain the server virtual machine instance object (VMI) and the client required to connect to the virtual machine execution environment;
[0093] S32. Extract the request parameters (such as password parameters) passed in by the user from the request body of the HTTP request, and perform state management operations (such as password reset operations) on the virtual machine; the format of the request body is JSON or YAML, and the request parameters (such as password parameters) are parsed according to the request type;
[0094] The method for parsing request parameters according to the request type includes the following steps (see Figure 6 shown):
[0095] S321. Determine the format of the request body and confirm the request type by using the Content-Type field in the HTTP request header:
[0096] If the Content-Type field is Content-Type: application / json, it means that the request body is in JSON format;
[0097] If the Content-Type field is Content-Type: application / x-yaml or other specified value, it means that the request body is in YAML format;
[0098] If Content-Type is not specified, an error message is returned, indicating that the request format is not supported;
[0099] S322, decoding the request body, and using the corresponding decoding library to parse the request body into a data structure (such as a dictionary) according to the format determined by Content-Type;
[0100] The decoded request body is a data structure (such as a Python dictionary);
[0101] S323. Verify whether the parameters (such as password) extracted after decoding meet the requirements (such as length limit, character set requirements); if the verification does not meet the requirements, return an error; if the verification meets the requirements, return the decoded parameters for subsequent components (such as components that generate QGA commands) to use.
[0102] This embodiment includes a virtual machine password reset operation. To ensure the security of password transmission, the password is transmitted through Base64 encoding. The specific steps are as follows:
[0103] (1) On the client side, encode the plain text password entered by the user into a string using Base64;
[0104] (2) The client sends the Base64-encoded password in the request body to the server via HTTPS encrypted transmission.
[0105] (3) After receiving the Base64-encoded password, the server decodes and verifies the Base64-encoded password;
[0106] (4) The decoded original password is matched with the password stored in the database. If the match is successful, it means that the new password has passed the security check, and the password reset operation is performed; if the match is successful, it means that the new password has failed the security check, and the password reset operation is not performed.
[0107] S33. After the request parameters (such as user name and password) are successfully parsed, a QGA command for executing a virtual machine state management operation (such as a password reset operation) is constructed, and the QGA command will be used to execute the state management operation (such as a password reset operation) inside the virtual machine;
[0108] S34, after the QGA command is constructed, the API interface routing is used to connect to the client, and the virtual machine state management command is executed through QGA;
[0109] S35. After the virtual machine state management operation is completed, the operation event is recorded for subsequent auditing, and an HTTP response is returned to the client to notify the result of the state management operation.
[0110] The embodiment of the present invention further provides a virtual machine management system based on QGA and KubeVirt, and executes the virtual machine management method based on QGA and KubeVirt as described above, including:
[0111] API extension module: used to define the extensible API interface of KubeVirt;
[0112] gRPC call module: used to establish gRPC remote procedure calls between the virt-handler component and the virt-launcher component of KubeVirt, and the virt-launcher component executes virtual machine status management commands;
[0113] QGA command execution module: used to write a processing function for the defined API interface in the virt-handler component of KubeVirt, and to execute the actual QGA command for virtual machine state management.
[0114] An embodiment of the present invention further provides a computer device, Figure 7 is a schematic diagram of the structure of a computer device provided by an embodiment of the present invention; see the accompanying drawings Figure 7As shown, the computer device includes: an input system 23, an output system 24, a memory 22 and a processor 21; the memory 22 is used to store one or more programs; when the one or more programs are executed by the one or more processors 21, the one or more processors 21 implement the virtual machine management method based on QGA and KubeVirt as provided in the above embodiment; wherein the input system 23, the output system 24, the memory 22 and the processor 21 can be connected via a bus or other means, Figure 7 The example of connecting through bus is taken in the following.
[0115] The memory 22 is a readable and writable storage medium of a computing device, which can be used to store software programs and computer executable programs, such as program instructions corresponding to the virtual machine management method based on QGA and KubeVirt described in the embodiment of the present invention; the memory 22 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and at least one application required for a function; the data storage area can store data created according to the use of the device, etc.; in addition, the memory 22 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device; in some instances, the memory 22 can further include a memory remotely arranged relative to the processor 21, and these remote memories can be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0116] The input system 23 may be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the device; the output system 24 may include display devices such as display screens.
[0117] The processor 21 executes various functional applications and data processing of the device by running software programs, instructions and modules stored in the memory 22, that is, implements the above-mentioned virtual machine management method based on QGA and KubeVirt.
[0118] The computer device provided above can be used to execute the virtual machine management method based on QGA and KubeVirt provided in the above embodiment, and has corresponding functions and beneficial effects.
[0119] The embodiment of the present invention also provides a storage medium containing computer executable instructions, which are used to execute the virtual machine management method based on QGA and KubeVirt as provided in the above embodiment when executed by a computer processor. The storage medium is any of various types of memory devices or storage devices, and the storage medium includes: installation media, such as CD-ROM, floppy disk or tape system; computer system memory or random access memory, such as DRAM, DDRRAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (such as hard disk or optical storage); registers or other similar types of memory elements, etc.; the storage medium may also include other types of memory or combinations thereof; in addition, the storage medium may be located in the first computer system in which the program is executed, or may be located in a different second computer system, the second computer system is connected to the first computer system via a network (such as the Internet); the second computer system may provide program instructions to the first computer for execution. The storage medium includes two or more storage media that can reside in different locations (for example, in different computer systems connected via a network). The storage medium can store program instructions (for example, specifically implemented as a computer program) that can be executed by one or more processors.
[0120] Of course, the storage medium containing computer executable instructions provided in an embodiment of the present invention is not limited to the virtual machine management method based on QGA and KubeVirt as described in the above embodiment, and can also execute related operations in the virtual machine management method based on QGA and KubeVirt provided in any embodiment of the present invention.
[0121] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments, but it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
[0122] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A virtual machine management method based on QGA and KubeVirt, characterized in that: The following steps are involved: S1. Define KubeVirt's extensible API interface. S2. Establish a gRPC remote procedure call between the virt-handler component and the virt-launcher component of KubeVirt, and the virt-launcher component executes the virtual machine status management command; S3. Writing a processing function for the defined API interface in the virt-handler component of KubeVirt to execute the actual QGA command for virtual machine state management.
2. The virtual machine management method based on QGA and KubeVirt according to claim 1, characterized in that: The method of defining the KubeVirt extensible API interface in step S1 includes the following steps: S11, define an API interface route, create a new API sub-path for the server virtual machine instance, through which the API interface is bound to the client's HTTP request, allowing the client to request control of the state management of the virtual machine; S12. Define request parameters of the HTTP request, where the request parameters include the namespace where the virtual machine is located and the name of the virtual machine, so that the API interface can locate a specific virtual machine for operation; S13. Add relevant documentation for the API interface, including a functional description of the API interface, HTTP status codes for success and failure, and corresponding messages.
3. The virtual machine management method based on QGA and KubeVirt according to claim 1, characterized in that: The S2 step includes the following steps: S21. Check whether the server virtual machine is running. If the virtual machine is running, enter the state management operation; if the virtual machine is not started, return an error; S22. By querying the connection information in the virt-handler component of KubeVirt, a URI pointing to the state management operation is created for the virtual machine; the path of the URI points to the virt-launcher component in the virtual machine, and the state management command is executed through the path; S23. Establish gRPC communication between the virt-handler component and the virt-launcher component of KubeVirt, so that the virt-handler component and the virt-launcher component can exchange information with high efficiency and low latency. S24, the virt-handler component calls the execution command interface in the virt-launcher component to send a command for executing virtual machine state management; S25. After executing the state management command, the virt-launcher component returns an execution result, and the virt-handler component transmits the returned execution result back to the client.
4. The virtual machine management method based on QGA and KubeVirt according to claim 1, characterized in that: The actual QGA command for executing the virtual machine state management in step S3 includes the following steps: S31, before processing the HTTP request for virtual machine state management, locate the server virtual machine through the request parameters in the HTTP request, obtain the server virtual machine instance object and the client required to connect to the virtual machine execution environment; S32, extracting the request parameters passed by the user from the request body of the HTTP request, and performing state management operations on the virtual machine; the format of the request body is JSON or YAML, and the request parameters are parsed according to the request type; S33. After the request parameters are successfully parsed, a QGA command for executing a virtual machine state management operation is constructed, and the QGA command will be used to execute the state management operation inside the virtual machine; S34, after the QGA command is constructed, the API interface routing is used to connect to the client, and the virtual machine state management command is executed through QGA; S35. After the virtual machine state management operation is completed, the operation event is recorded for subsequent auditing, and an HTTP response is returned to the client to notify the result of the state management operation.
5. The virtual machine management method based on QGA and KubeVirt according to claim 4, characterized in that: The method for parsing request parameters according to the request type in step S32 comprises the following steps: S321. Determine the format of the request body and confirm the request type through the Content-Type field in the HTTP request header: If the Content-Type field is Content-Type: application / json, it means that the request body is in JSON format; If the Content-Type field is Content-Type: application / x-yaml or other specified value, it means that the request body is in YAML format; If Content-Type is not specified, an error message is returned, indicating that the request format is not supported; S322, decoding the request body, and using the corresponding decoding library to parse the request body into a data structure according to the format determined by Content-Type; S323. Verify whether the parameters extracted after decoding meet the requirements; if the verification does not meet the requirements, return an error; if the verification meets the requirements, return the decoded parameters for use by subsequent components.
6. A virtual machine management system based on QGA and KubeVirt, characterized by: Executing the virtual machine management method based on QGA and KubeVirt according to any one of claims 1 to 5, comprising: API extension module: used to define the extensible API interface of KubeVirt; gRPC call module: used to establish gRPC remote procedure calls between the virt-handler component and the virt-launcher component of KubeVirt, and the virt-launcher component executes virtual machine status management commands; QGA command execution module: used to write a processing function for the defined API interface in the virt-handler component of KubeVirt, and to execute the actual QGA command for virtual machine state management.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by the processor, the steps of the virtual machine management method based on QGA and KubeVirt are implemented as described in any one of claims 1-5.
8. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the virtual machine management method based on QGA and KubeVirt are implemented as described in any one of claims 1-5.
Citation Information
Patent Citations
Method for realizing management of virtual machine by cloud native application
CN112000439A
Method and device for simplifying workload of virtual machine under k8s cluster, processor and storage medium thereof
CN117032892A
Virtual machine management and scheduling method based on autonomous architecture server
CN117519906A
Method and device for creating virtual machine with vDPA equipment, equipment and storage medium
CN117742891A
Control method for virtual computer, and virtual computer system
US20130346584A1