Virtual machine management methods and systems based on QGA and KubeVirt
By integrating QEMU's QGA tool with KubeVirt, extending the API interface, and using gRPC remote procedure calls, the problems of inflexible command execution and complex interaction in KubeVirt virtual machine management are solved, achieving efficient and convenient virtual machine management and improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TONGFANG YOUYUN (BEIJING) TECH CO LTD
- Filing Date
- 2025-01-16
- Publication Date
- 2026-06-30
AI Technical Summary
The existing KubeVirt virtual machine management solution lacks a flexible command execution mechanism, cannot directly interact with the operating system inside the virtual machine, and is complex to manage and has a cumbersome operation process, especially prone to errors when managing multiple virtual machines.
By integrating QEMU's QGA tool with KubeVirt, the API interface is extended, and gRPC remote procedure calls and QGA commands are used to achieve efficient communication and command control between the host machine and the virtual machine, providing fine-grained operations such as virtual machine password management.
It enables flexible and convenient command control from the host machine to the virtual machine, simplifies the virtual machine management process, improves operational flexibility and compatibility, reduces the need for customized scripts for different operating systems, and enhances the user experience.
Smart Images

Figure CN120010993B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of virtual machine management technology, and more specifically, to a virtual machine management method and system based on QGA and KubeVirt. Background Technology
[0002] Kubernetes is a widely used open-source container orchestration platform that automates the management and deployment of containerized applications. It is widely used in cloud computing environments, helping development and operations teams improve efficiency and simplify application management and operation by providing efficient resource management, automated scheduling, and container orchestration.
[0003] Currently, the control of virtual machine lifecycles in Kubernetes clusters primarily relies on the functionality of KubeVirt. KubeVirt is an open-source project that extends Kubernetes, allowing virtual machines (VMs) to run within Kubernetes clusters. With KubeVirt, users can manage VMs like containers and deploy and schedule VM applications on the Kubernetes platform. The KubeVirt project introduced the concept of virtual machines to containerized environments, supporting management, scheduling, and monitoring at the VM level. KubeVirt provides a more flexible and efficient management mechanism for VMs.
[0004] KubeVirt provides the ability to manage the lifecycle of virtual machines (VMs) by defining resources, including controlling the creation, destruction, and management of VMs through the Kubernetes API. However, these management operations are largely limited to VM state management and lack fine-grained, real-time interaction capabilities between the host machine and the VM's internal system. Currently, KubeVirt manages the VM lifecycle through the kubectl command or virtctl tool in Kubernetes. While these methods can perform basic operations such as creation, stopping, and restarting, they still have some significant shortcomings in the following aspects:
[0005] 1. Current virtual machine management operations are mostly batch and global, such as stopping or restarting virtual machines, but lack direct support for operations inside virtual machines (such as executing applications inside virtual machines) and lack a 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 operation and control inside the virtual machine.
[0007] 3. In some complex environments, the management of Kubernetes and virtual machines is highly dependent and the operations are frequent. In order to control virtual machines more finely, a more granular management interface is usually required, which increases the management complexity.
[0008] 4. Existing virtual machine management operations require administrators to manually log in to the virtual machine via SSH and execute management commands (such as resetting passwords and modifying configurations). The operation process is complex, 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 execution control, virtual machine internal interaction, and lifecycle management. Summary of the Invention
[0010] Therefore, the purpose of this invention is to propose a virtual machine management method and system based on QGA and KubeVirt. Leveraging QEMU's QGA tool, it achieves a more flexible, efficient, and convenient virtual machine operation and control mechanism; through the virt-handler extension service, it executes QGA commands to realize KubeVirt virtual machine lifecycle management; through the integration of QGA and KubeVirt, it realizes command control from the host machine to the virtual machine, meeting the needs for fine-grained virtual machine management and enhancing the flexibility of virtual machine lifecycle control; it provides a new command execution mechanism where the client initiates a request, KubeVirt receives and processes the request to obtain QGA commands, and sends commands to the operating system within the virtual machine through QGA to control the virtual machine's state changes, realizing instruction transfer from the host machine to the virtual machine without relying on complex API calls. Users do not need to enter the virtual machine to operate, simplifying the interaction process between the virtual machine and the virtual machine; through the combination of KubeVirt and QGA, standardized QGA commands are used to complete virtual machine management tasks, simplifying the virtual machine management operation process; users can access the Kubernetes API... Requests are sent automatically by the KubeVirt extension, eliminating the need to directly call complex underlying APIs. This makes it compatible with various virtual machine operating systems, improving compatibility and eliminating the need to write custom scripts for different operating systems, thus enhancing the user experience.
[0011] QEMU (Quick Emulator) is an open-source virtualization software capable of emulating various hardware architectures and devices, supporting virtualization technologies such as KVM (Kernel-based Virtual Machine). QGA (QEMU Guest Agent) is a tool provided by QEMU that allows bidirectional communication between the host machine and the operating system within the virtual machine, thereby enabling management of the virtual machine's lifecycle. QGA is typically used for task management within the virtual machine, including system status monitoring, log collection, and command execution. Through QGA, the host machine can send commands to the virtual machine to control its lifecycle, such as starting, stopping, pausing, and resuming the virtual machine.
[0012] This invention provides a virtual machine management method based on QGA and KubeVirt, comprising the following steps:
[0013] S1. Define the extensible API interface for KubeVirt;
[0014] This invention provides native support for virtual machine password management by extending the KubeVirt API interface, thus 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 have the virt-launcher component execute virtual machine state management commands.
[0016] S3. Write processing functions for the defined API interfaces in the virt-handler component of KubeVirt to execute the actual QGA commands 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 for defining the extensible API interface of KubeVirt in step S1 includes the following steps:
[0019] S11. Define API interface routes to create new API sub-paths for server virtual machine instances. Through the API sub-paths, the API interfaces are bound to client HTTP requests (such as PUT / POST requests), allowing clients to request control over the virtual machine's state management (e.g., changing the virtual machine's password).
[0020] The existing KubeVirt API does not directly provide functionality for virtual machine password management, especially when remote operation via QGA is required. A preferred embodiment of this invention adds the functionality to reset virtual machine passwords, enabling clients to invoke this function via a RESTful API. Specifically, a new API interface is first defined in virt-api, and the API interface is routed to the corresponding processing function. In virt-api, API routes can be defined using subws.Route, and a new PUT interface can be added to handle virtual machine requests.
[0021] S12. Define the request parameters of the HTTP request. 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 the specific virtual machine for operation.
[0022] S13. Add relevant documentation for the API interface, including a description of the API interface's function (e.g., "Reset virtual machine password"), success and failure HTTP status codes, and corresponding messages.
[0023] Furthermore, step S2 includes the following steps:
[0024] S21. Check if the server virtual machine is running. If the virtual machine is running, proceed with state management operations (e.g., reset the password); if the virtual machine is not running, return an error.
[0025] Specifically, state management operations are only allowed for virtual machines in the running state. By verifying the state of the virtual machine instance, state management operations (such as password reset) are only performed 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 inside the virtual machine, and the state management (such as password reset) command is executed through this 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] Using QGA and gRPC technologies enables efficient communication between the host machine and the virtual machine, avoiding the problem of unsmooth cross-component communication and interaction that exists in existing technologies.
[0029] S24. The virt-handler component calls the execution command interface in the virt-launcher component to send a command to perform virtual machine state management (e.g., reset password);
[0030] S25. After the virt-launcher component executes the state management (e.g., reset password) command, it returns the execution result, and the virt-handler component returns the execution result back to the client.
[0031] Furthermore, the actual QGA commands for executing virtual machine state management in step S3 include the following steps:
[0032] S31. Before processing the HTTP request for virtual machine state management (e.g., password reset), locate the server virtual machine through the 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 user-supplied request parameters (e.g., password parameters) from the HTTP request body, and perform state management operations on the virtual machine (e.g., password reset operation); the request body is in JSON or YAML format, and the request parameters (e.g., password parameters) are parsed according to the request type.
[0034] S33. After the request parameters (such as username and password) are successfully parsed, construct a QGA command to perform virtual machine state management operations (such as password reset operations). The QGA command will be used to perform state management operations (such as password reset operations) inside the virtual machine.
[0035] S34. After the QGA command is built, use the API interface to route and connect to the client, and execute virtual machine state management commands through QGA;
[0036] This step resolves the command execution issue across virtual machines and the host machine.
[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 operation feedback and event logging mechanisms, 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 for parsing request parameters according to the request type in step S32 includes the following steps:
[0040] S321. Determine the request body format and confirm the request type by checking 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 indicates that the request body is in YAML format;
[0043] If no Content-Type is specified, an error message will be returned indicating that the request format is not supported;
[0044] S322. Decode the request body. Based on the format determined by Content-Type, use the corresponding decoding library to parse the request body into a data structure (e.g., a dictionary).
[0045] The decoded request body is a data structure (such as a Python dictionary);
[0046] S323. Verify whether the extracted parameters (e.g., password) after decoding meet the requirements (e.g., 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 use by subsequent components (e.g., the component that generates QGA commands).
[0047] In a practical application of virtual machine password reset, this invention ensures the security of password transmission by transmitting the password via Base64 encoding, including the following steps:
[0048] (1) On the client side, the plaintext password entered by the user at the front end is encoded into a string using Base64;
[0049] (2) The client sends the Base64-encoded password to the server in the request body via HTTPS encryption.
[0050] (3) After receiving the Base64 encoded password, the server decodes and verifies the Base64 encoded password;
[0051] (4) Match the decoded original password 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] This invention also provides a virtual machine management system based on QGA and KubeVirt, which 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 for KubeVirt;
[0054] gRPC call module: used to establish gRPC remote procedure calls between the virt-handler component and the virt-launcher component of KubeVirt, with the virt-launcher component executing virtual machine state management commands;
[0055] The QGA command execution module is used to write processing functions for the defined API interfaces in the virt-handler component of KubeVirt, which are used to execute the actual QGA commands for virtual machine state management.
[0056] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the steps of the virtual machine management method based on QGA and KubeVirt as described above.
[0057] The present invention also provides a computer device, the computer device including a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements the steps of the virtual machine management method based on QGA and KubeVirt as described above.
[0058] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0059] This invention provides a virtual machine management method and system based on QGA and KubeVirt. Leveraging QEMU's QGA tool, it achieves a more flexible, efficient, and convenient virtual machine operation and control mechanism. Through the virt-handler extension service, it executes QGA commands to implement KubeVirt virtual machine lifecycle management. By integrating QGA with KubeVirt, it enables command control from the host machine to the virtual machine, meeting the needs for fine-grained virtual machine management and enhancing the flexibility of virtual machine lifecycle control. It provides a new command execution mechanism: the client initiates a request, KubeVirt receives and processes the request to obtain QGA commands, and then sends commands to the operating system within the virtual machine via QGA to control virtual machine state changes, such as restarting, pausing, and configuration modification. This achieves command transfer from the host machine to the virtual machine without relying on complex API calls, simplifying the interaction process between the virtual machine and its environment without requiring users to enter the virtual machine. Through the combination of KubeVirt and QGA, standardized QGA commands are used to complete virtual machine management tasks, such as restarting, mounting disks, and changing passwords, simplifying the virtual machine management operation process. Users can access the Kubernetes API... Requests are sent automatically by the KubeVirt extension, eliminating the need to directly call complex underlying APIs. This makes it compatible with various virtual machine operating systems, enhancing user experience by eliminating the need to write custom scripts for different operating systems. Attached Figure Description
[0060] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention.
[0061] In the attached diagram:
[0062] Figure 1 This is an interactive diagram of the extended RESTful API interface according to an embodiment of the present invention;
[0063] Figure 2 The flowchart shows the virtual machine management method based on QGA and KubeVirt of this invention.
[0064] Figure 3 A flowchart illustrating the method for defining the extensible API interface of KubeVirt in this invention;
[0065] Figure 4 This is a flowchart of step S2 of the virtual machine management method based on QGA and KubeVirt of the present invention;
[0066] Figure 5A flowchart illustrating the actual QGA commands used in executing virtual machine state management according to this invention;
[0067] Figure 6 This is a flowchart of the method for parsing request parameters according to the request type according to the present invention;
[0068] Figure 7 This is a schematic diagram of the configuration of a computer device according to an embodiment of the present invention. Detailed Implementation
[0069] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and products consistent with some aspects of this disclosure as detailed in the appended claims.
[0070] The terminology used in this disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The singular forms “a,” “the,” and “the” as used in this disclosure and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.
[0071] It should be understood that although the terms first, second, third, etc., may be used in this disclosure to describe various information, such information should not be limited to these terms. These terms are used only to distinguish information of the same type from one another. For example, without departing from the scope of this disclosure, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0072] The embodiments of the present invention will be described in further detail below.
[0073] This invention provides a virtual machine management method based on QGA and KubeVirt. See [link to relevant documentation]. Figure 2 As shown, it includes the following steps:
[0074] S1. Define the extensible API interface for KubeVirt;
[0075] For methods on defining the extensible API interface of KubeVirt, see [link to documentation]. Figure 3 As shown, it includes the following steps:
[0076] S11. Define API interface routes to create new API sub-paths for server virtual machine instances. Through the API sub-paths, the API interfaces are bound to client HTTP requests (such as PUT / POST requests), allowing clients to request control over the virtual machine's state management (such as changing the virtual machine's password).
[0077] This embodiment adds the functionality to reset the virtual machine password. Clients can call this virtual machine password reset function via a RESTful API (e.g., ...). Figure 1 As shown, first define a new API interface in virt-api and route the API interface to the corresponding handler function. In virt-api, API routes can be defined using subws.Route, and new PUT interfaces can be added to handle virtual machine requests.
[0078] S12. Define the request parameters of the HTTP request. 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 the specific virtual machine for operation.
[0079] S13. Add relevant documentation for the API interface, including a description of the API interface's function (such as "Reset virtual machine password"), success and failure HTTP status codes, and corresponding messages.
[0080] This embodiment extends the KubeVirt API interface to provide native support for virtual machine password management, 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 have the virt-launcher component execute virtual machine state management commands.
[0082] Step S2 includes the following steps (see...) Figure 4 (as shown)
[0083] S21. Check if the server virtual machine is running. If the virtual machine is running, proceed with state management operations (such as resetting the password); if the virtual machine is not started, return an error.
[0084] Specifically, state management operations are only allowed for virtual machines in the running state. By verifying the state of the virtual machine instance, state management operations (such as password reset) are only performed 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 inside the virtual machine, and the state management (such as password reset) command is executed through this 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] Using QGA and gRPC technologies enables efficient communication between the host machine and the virtual machine, avoiding the problem of unsmooth cross-component communication and interaction that exists in existing technologies.
[0088] S24. The virt-handler component calls the execution command interface in the virt-launcher component to send a command to perform virtual machine state management (such as resetting the password);
[0089] S25. After the virt-launcher component executes the state management (such as resetting the password) command, it returns the execution result, and the virt-handler component returns the execution result back to the client.
[0090] S3. Write processing functions for the defined API interfaces in the virt-handler component of KubeVirt to execute the actual QGA commands for virtual machine state management.
[0091] The actual QGA commands for performing virtual machine state management include the following steps (see...). Figure 5 (as shown)
[0092] S31. Before processing HTTP requests for virtual machine state management (such as password reset), locate the server virtual machine through the 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 user-supplied request parameters (such as password parameters) from the HTTP request body, and perform state management operations on the virtual machine (such as password reset operations); the request body is in JSON or YAML format, and the request parameters (such as password parameters) are parsed according to the request type.
[0094] The method for parsing request parameters based on the request type includes the following steps (see...). Figure 6 (as shown)
[0095] S321. Determine the request body format and confirm the request type by checking 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 indicates that the request body is in YAML format;
[0098] If no Content-Type is specified, an error message will be returned indicating that the request format is not supported;
[0099] S322. Decode the request body. Based on the format determined by Content-Type, use the corresponding decoding library to parse the request body into a data structure (e.g., a dictionary).
[0100] The decoded request body is a data structure (such as a Python dictionary);
[0101] S323. Verify whether the extracted parameters (e.g., password) after decoding meet the requirements (e.g., 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 use by subsequent components (e.g., the component that generates QGA commands).
[0102] This embodiment includes a virtual machine password reset operation. To ensure the security of password transmission, the password is transmitted using Base64 encoding. The specific steps are as follows:
[0103] (1) On the client side, the plaintext password entered by the user at the front end is encoded into a string using Base64;
[0104] (2) The client sends the Base64-encoded password to the server in the request body via HTTPS encryption.
[0105] (3) After receiving the Base64 encoded password, the server decodes and verifies the Base64 encoded password;
[0106] (4) Match the decoded original password 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 username and password) are successfully parsed, construct a QGA command to perform virtual machine state management operations (such as password reset operations). The QGA command will be used to perform state management operations (such as password reset operations) inside the virtual machine.
[0108] S34. After the QGA command is built, use the API interface to route and connect to the client, and execute virtual machine state management commands 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] This invention also provides a virtual machine management system based on QGA and KubeVirt, which 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 for KubeVirt;
[0112] gRPC call module: used to establish gRPC remote procedure calls between the virt-handler component and the virt-launcher component of KubeVirt, with the virt-launcher component executing virtual machine state management commands;
[0113] The QGA command execution module is used to write processing functions for the defined API interfaces in the virt-handler component of KubeVirt, which are used to execute the actual QGA commands for virtual machine state management.
[0114] This invention also provides a computer device. Figure 7 This is a schematic diagram of the structure of a computer device provided in 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 provided in the above embodiments; 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 Taking the example of a connection between China and Israel via a bus.
[0115] The memory 22, as a read / write storage medium for a computing device, can be used to store software programs and computer-executable programs, such as the program instructions corresponding to the virtual machine management method based on QGA and KubeVirt described in this embodiment of the invention. The memory 22 may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function; the data storage area may store data created based on the use of the device. Furthermore, the memory 22 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 22 may further include memory remotely located relative to the processor 21, and these remote memories can be connected to the device via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0116] The input system 23 can be used to receive input digital or character information, and generate key signal inputs related to user settings and function control of the device; the output system 24 may include display devices such as a display screen.
[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, thereby realizing the virtual machine management method based on QGA and KubeVirt described above.
[0118] The computer equipment provided above can be used to execute the virtual machine management method based on QGA and KubeVirt provided in the above embodiments, and has corresponding functions and beneficial effects.
[0119] This invention also provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to execute the virtual machine management method based on QGA and KubeVirt as provided in the above embodiments. The storage medium can be any type of memory device or storage device, including: mounting media such as CD-ROM, floppy disk, or tape systems; 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 (e.g., hard disk or optical storage); registers or other similar types of memory elements; the storage medium may also include other types of memory or combinations thereof; furthermore, the storage medium may reside in a first computer system in which the program is executed, or it may reside in a different second computer system connected to the first computer system via a network (such as the Internet); the second computer system can provide program instructions to the first computer for execution. The storage medium includes two or more storage media that can reside in different locations (e.g., in different computer systems connected via a network). The storage medium can store program instructions (e.g., specifically implemented as a computer program) executable by one or more processors.
[0120] Of course, the computer-executable instructions provided in the embodiments of the present invention are not limited to the virtual machine management method based on QGA and KubeVirt as described in the above embodiments, but 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] The technical solution of the present invention has been described in conjunction with preferred embodiments. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions resulting from these changes or substitutions will all fall within the scope of protection of the present invention.
[0122] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A virtual machine management method based on QGA and KubeVirt, characterized in that, Includes the following steps: S1. Define the extensible API interface for KubeVirt; S2. Establish a gRPC remote procedure call between the virt-handler component and the virt-launcher component of KubeVirt, and have the virt-launcher component execute virtual machine state management commands. S3. Write processing functions for the defined API interfaces in the virt-handler component of KubeVirt to execute the actual QGA commands for virtual machine state management; The method for defining the extensible API interface of KubeVirt in step S1 includes the following steps: S11. Define API interface routes and create new API sub-paths for server virtual machine instances. Through the API sub-paths, the API interfaces are bound to the client's HTTP requests, allowing the client to request control over the virtual machine's state management. S12. Define the request parameters of the HTTP request. 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 the 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.
2. The virtual machine management method based on QGA and KubeVirt according to claim 1, characterized in that, Step S2 includes the following steps: S21. Check if the server virtual machine is running. If the virtual machine is running, proceed with 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 generated for the virtual machine; the path of the URI points to the virt-launcher component inside the virtual machine, and the state management command is executed through this 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 to perform virtual machine state management; S25. After the virt-launcher component executes the state management command, it returns the execution result, and the virt-handler component returns the execution result back to the client.
3. The virtual machine management method based on QGA and KubeVirt according to claim 1, characterized in that, The actual QGA commands for executing virtual machine state management in step S3 include 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. Extract the user-input request parameters from the HTTP request body and perform state management operations on the virtual machine; the request body format is JSON or YAML, and the request parameters are parsed according to the request type. S33. After the request parameters are successfully parsed, construct a QGA command to perform virtual machine state management operations. The QGA command will be used to perform state management operations inside the virtual machine. S34. After the QGA command is built, use the API interface to route and connect to the client, and execute virtual machine state management commands 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.
4. The virtual machine management method based on QGA and KubeVirt according to claim 3, characterized in that, The method for parsing request parameters according to the request type in step S32 includes the following steps: S321. Determine the request body format and confirm the request type by checking 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, it means that the request body is in YAML format; If no Content-Type is specified, an error message will be returned indicating that the request format is not supported; S322. Decode the request body. Based on the format determined by Content-Type, use the corresponding decoding library to parse the request body into a data structure. 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.
5. A virtual machine management system based on QGA and KubeVirt, characterized in that, Performing the virtual machine management method based on QGA and KubeVirt as described in any one of claims 1-4, comprising: API extension module: Used to define the extensible API interface for KubeVirt; gRPC call module: used to establish gRPC remote procedure calls between the virt-handler component and the virt-launcher component of KubeVirt, with the virt-launcher component executing virtual machine state management commands; The QGA command execution module is used to write processing functions for the defined API interfaces in the virt-handler component of KubeVirt, which are used to execute the actual QGA commands for virtual machine state management.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps of the virtual machine management method based on QGA and KubeVirt as described in any one of claims 1-4.
7. A computer device, the 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, it implements the steps of the virtual machine management method based on QGA and KubeVirt as described in any one of claims 1-4.