CN117591246B - Method and device for realizing WEB terminal of KVM (keyboard video mouse) virtual machine - Google Patents

Method and device for realizing WEB terminal of KVM (keyboard video mouse) virtual machine Download PDF

Info

Publication number
CN117591246B
CN117591246B CN202410071465.XA CN202410071465A CN117591246B CN 117591246 B CN117591246 B CN 117591246B CN 202410071465 A CN202410071465 A CN 202410071465A CN 117591246 B CN117591246 B CN 117591246B
Authority
CN
China
Prior art keywords
virtual machine
virtual
serial port
module
serial
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202410071465.XA
Other languages
Chinese (zh)
Other versions
CN117591246A (en
Inventor
杨帅
杨其
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Youyun Technology Co ltd
Original Assignee
Hangzhou Youyun Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Youyun Technology Co ltd filed Critical Hangzhou Youyun Technology Co ltd
Priority to CN202410071465.XA priority Critical patent/CN117591246B/en
Publication of CN117591246A publication Critical patent/CN117591246A/en
Application granted granted Critical
Publication of CN117591246B publication Critical patent/CN117591246B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5061Partitioning or combining of resources
    • G06F9/5077Logical partitioning of resources; Management or configuration of virtualized resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45562Creating, deleting, cloning virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45579I/O management, e.g. providing access to device drivers or storage
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45595Network integration; Enabling network access in virtual machine instances

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention provides a method and a device for realizing a WEB terminal of a KVM virtual machine, wherein the method comprises the following steps: creating at least one KVM virtual machine configured with virtual serial port equipment on a host machine, configuring a WEB terminal module on cloud platform management and control, and registering the KVM virtual machine on the WEB terminal module based on a three-party mapping relation through a socket port equipment and serial port gateway module configured on the host machine and a WEB server module configured on a cloud platform gateway; and creating a virtual terminal window through the WEB terminal module, and converting and transmitting data instructions through the WEB server module to complete command interaction between the WEB terminal module and the KVM virtual machine serial port equipment. The method and the device of the invention enable the operation and maintenance engineer to conveniently log in the virtual machine and manage the virtual machine like operating the physical host locally.

Description

Method and device for realizing WEB terminal of KVM (keyboard video mouse) virtual machine
Technical Field
The invention relates to the technical field of cloud computing, in particular to a method and a device for realizing a WEB terminal of a KVM (keyboard video mouse) virtual machine.
Background
With the development of cloud computing application, cloud computing has become the basis of informatization construction in various industry fields, a cloud platform system is increasingly complex and huge, and the daily security guarantee problem of cloud computing is extremely important. In order to ensure the safety and reliability of the cloud platform, an operation and maintenance engineer needs to carry out daily inspection on the computing nodes, and whether the nodes have risks or not is confirmed through log information or state information of the computing nodes. When a security risk exists in a computing node, an operation and maintenance engineer often needs to log on to the computing node at the first time to confirm the state of the system.
The KVM virtual machine is an open source virtual machine module, which is widely used in cloud computing platforms. In order to solve the problem of remote management of virtual machines, there are two main solutions in the industry:
The first is to develop a set of Agent equipment to be deployed in the KVM virtual machine, the Agent is used as a management access Agent, and the cloud computing platform manages the cloud computing nodes through the Agent client. The method can solve the problem of virtual machine management, but virtual machine operating system platforms are complex and various, and in order to be compatible with different operating systems, the platforms need to develop and maintain a plurality of Agent components, and the software maintenance complexity is high.
The second is to build a proprietary cloud computing VNC network, according to which operators manage and maintain KVM virtual machines through VNC clients. According to the method, on one hand, the cloud computing network is required to be customized and planned, the hardware deployment cost is high, and on the other hand, the cloud computing platform is strongly dependent on the VNC client, and the management client has poor flexibility.
Disclosure of Invention
Based on the background, in order to more efficiently, quickly and conveniently manage the KVM virtual machine, the invention provides a method and a device for realizing the WEB terminal of the KVM virtual machine, so that an operation and maintenance engineer can conveniently log in the virtual machine and manage the virtual machine like a physical host in a local operation.
In order to achieve the above purpose, the present invention adopts the following technical scheme:
the first aspect of the present invention provides a method for implementing a KVM virtual machine WEB terminal, including:
S1, creating at least one KVM virtual machine configured with virtual serial port equipment on a host machine, configuring a WEB terminal module on cloud platform management and control, and registering the KVM virtual machine on the WEB terminal module based on a three-party mapping relation through socket port equipment and serial port gateway modules configured on the host machine and a WEB server module configured on a cloud platform gateway;
s2, creating a virtual terminal window through a WEB terminal module, monitoring a system mouse message when the virtual terminal window is activated or locked, displaying input text information in the virtual terminal window based on the monitored mouse message, calling a corresponding API interface based on a preset mouse trigger message to form a control instruction, and sending the control instruction in combination with a virtual machine serial number as request data to the WEB server module;
S3, the WEB server module receives and analyzes the request data, acquires the serial number of the virtual machine and the content of the control instruction, converts the content of the control instruction into a serial port protocol instruction, and sends the serial port protocol instruction to virtual serial port equipment corresponding to the virtual machine based on the three-party mapping relation to finish execution of the serial port instruction;
S4, the WEB server module queries a serial port gateway module of a corresponding host based on a query request of the WEB terminal module, acquires serial port data returned by the virtual serial port device, converts the serial port data into text data which can be displayed by the WEB terminal, packages the serial number and the text data of the virtual machine into an HTTP protocol, and sends the HTTP protocol to the WEB terminal module;
and S5, the WEB terminal module receives the data returned by the WEB server module, updates the received data to the virtual terminal window, refreshes interface display, and completes command interaction between the WEB terminal module and the KVM virtual machine serial device.
Further, the step S1 specifically includes:
S11, creating a KVM virtual machine configured with virtual serial port equipment on a host, and creating socket equipment after the starting of the KVM virtual machine is completed, wherein the socket equipment is connected with the virtual serial port equipment;
S12, scanning and connecting the socket equipment through a serial port gateway module deployed on a host machine, and establishing and maintaining and updating a virtual serial port equipment mapping table, wherein the virtual serial port equipment mapping table records the mapping relation between the virtual serial port equipment and the socket equipment;
s13, the serial port gateway module scans the mapping table of the virtual serial port equipment at regular time, and sends the serial number of the virtual machine and the management IP address of the current host to the WEB server module of the cloud platform gateway;
S14, after receiving the serial number of the virtual machine and the management IP address of the host, the WEB server module establishes and maintains and updates a mapping table of the host machine of the virtual machine, wherein the mapping table of the host machine of the virtual machine records the corresponding relation between the KVM virtual machine and the host machine;
S15, the WEB server side module responds to the query request of the WEB terminal module configured on the cloud platform management and control, generates full-quantity virtual machine terminal information based on the virtual machine host mapping table and returns the full-quantity virtual machine terminal information to the WEB terminal module, and the WEB terminal module registers the KVM virtual machine based on the returned information.
Further, in step S2, displaying the input text information in the virtual terminal window based on the monitored mouse message, and calling the corresponding API interface based on the preset mouse trigger message to form a control instruction, and sending the control instruction in combination with the virtual machine serial number as request data to the WEB server module specifically includes:
When the fact that the keyboard input key is a text is detected, namely 0-9, a-Z or A-Z, the virtual terminal window displays text information into the window;
When a preset key mouse trigger message is detected, the WEB terminal module acquires text information input by a current window and calls a corresponding API interface to form a control instruction according to the preset key mouse trigger message, wherein the preset key mouse trigger message comprises a cursor up, a cursor down, a Tab key, a ctrl+C or an Enter key trigger message.
Further, calling a corresponding API interface according to a preset mouse trigger message to form a control instruction specifically includes:
The preset mouse trigger message is a com_up interface when a cursor is upward, the preset mouse trigger message is a com_down interface when the cursor is downward, the preset mouse trigger message is a Tab key, the com_tab interface is called, the preset mouse trigger message is a ctrl+c interface, and the preset mouse trigger message is an Enter key, the com_submit interface is called.
Further, the step S3 specifically includes:
S31, a WEB server module receives and analyzes the request data, acquires a virtual machine serial number and control instruction content, converts the control instruction content into a serial port protocol instruction, queries a virtual machine host mapping relation table to obtain a host management IP address of a virtual machine corresponding to the acquired virtual machine serial number, and sends the virtual machine serial number and the converted serial port protocol instruction to a serial port gateway module on a corresponding host;
S32, the serial port gateway module queries the virtual serial port device mapping table according to the received serial number of the virtual machine to find out the corresponding socket port device, and sends the received serial port protocol instruction to the virtual serial port device of the corresponding virtual machine through the socket port device, so that execution of the serial port instruction is completed.
Further, in step S31, converting the control instruction content into a serial port protocol instruction specifically includes:
Convert com_up command to " ", Convert com_down command to"/>", Convert com_tab command to"/>", Convert com_cancel command to"/>”;
When the com_submit interface is called, the cmd field in the request message is acquired, and the serial port message is encapsulated: cmd field message + ".”。
Further, the step S4 specifically includes:
S41, a virtual terminal window on the WEB terminal module is used for calling a com_status interface at fixed time to send a virtual machine serial number to inquire whether the virtual machine has contents to be output and displayed to the virtual terminal window;
s42, the WEB service end module analyzes the serial number of the virtual machine after receiving the call of the com_status interface, and inquires a serial port gateway module of a corresponding host;
S43, the serial port gateway module checks the states of the socket devices on all hosts in the virtual serial port device mapping table at regular time, and records the output state information of the corresponding virtual serial port device;
S44, when the serial gateway module receives the query request of the WEB server module, checking output state information of the virtual serial device recorded in the mapping table of the virtual serial device, and if the output state of the virtual serial device is data, reading the serial data and returning the serial data to the WEB server module; if no data exists, immediately replying and returning empty data;
S45, the WEB server side module checks the data returned by the serial port gateway module, if the data is returned, the returned serial port data is converted into text data which can be displayed by the WEB terminal, and the serial number of the virtual machine and the text data are packaged into an HTTP protocol and sent to the WEB terminal module.
The second aspect of the present invention further provides a device for implementing a KVM virtual machine WEB terminal, which is configured to implement the method for implementing a KVM virtual machine WEB terminal according to the first aspect, including:
The system comprises a host machine, at least one KVM virtual machine provided with virtual serial port equipment, socket equipment corresponding to the virtual serial port equipment and a serial port gateway module, wherein the serial port gateway module establishes and maintains and updates a virtual serial port equipment mapping table, and the virtual serial port equipment mapping table records the mapping relation between the virtual serial port equipment and the socket equipment;
The cloud platform gateway is provided with a WEB server side module, the WEB server side module acquires a virtual machine serial number and a management IP address of a current host machine based on the virtual serial device mapping table, establishes and maintains an updated virtual machine host machine mapping table, and the virtual machine host machine mapping table records the corresponding relation between the KVM virtual machine and the host machine;
and the cloud platform management and control is provided with a WEB terminal module, the WEB terminal module creates a virtual terminal window corresponding to the virtual machine, monitors a system mouse key message when the virtual terminal window is activated or locked, and transmits data and commands with the serial port gateway module through the WEB server module to complete command interaction of the WEB terminal module and the serial port equipment of the KVM virtual machine.
The beneficial technical effects of the invention are as follows:
1) According to the method and the device, the operation and maintenance management module of the KVM virtual machine is designed into an independent functional component, the cloud computing platform can be conveniently deployed to cloud computing management and control like the common WEB component management, and the method and the device have no system and platform dependence and are strong in software adaptability.
2) According to the method and the device, an operation and maintenance person can use the WEB terminal to manage the remote KVM virtual machine like operating the local physical server, command line interaction is carried out on the WEB webpage and the virtual machine, and an execution result is output to the WEB terminal webpage after the command interaction is finished, so that the operation and maintenance cost of the system and the learning time of the system are greatly reduced.
3) According to the method and the device, all API interfaces requested by the WEB terminal are designed to be stateless, the dependence of system software on network and interface delay is solved from the design source, and even if part of interfaces or command requests are overtime, the system can still correctly continue to operate, so that the system has strong system robustness.
4) According to the method and the device, agent software does not need to be customized and developed for a service operation system in the KVM virtual machine, management and service separation are achieved, on one hand, the complexity of the system is reduced, and on the other hand, the stability of the system is improved.
Drawings
FIG. 1 is a schematic diagram of an embodiment of a system for implementing a KVM virtual machine WEB terminal according to the present invention.
FIG. 2 is a schematic diagram of a WEB terminal registration process in an embodiment of a method for implementing a KVM virtual machine WEB terminal according to the present invention.
FIG. 3 is a schematic diagram of a WEB terminal user interaction flow in an embodiment of a method for implementing a KVM virtual machine WEB terminal of the present invention.
FIG. 4 is a schematic diagram of a WEB terminal command execution flow in an embodiment of a method for implementing a KVM virtual machine WEB terminal according to the present invention.
FIG. 5 is a schematic diagram of a WEB terminal display query flow in an embodiment of a method for implementing a KVM virtual machine WEB terminal of the present invention.
Detailed Description
For a further understanding of the present invention, preferred embodiments of the invention are described below in conjunction with the examples, but it should be understood that these descriptions are merely intended to illustrate further features and advantages of the invention, and are not limiting of the claims of the invention.
Noun interpretation:
KVM virtual machine: i.e., kernel-based Virtual Machine, is an open-source system virtualization module, integrated in each major release of Linux since Linux 2.6.20.
Libvirt: an open source API for managing a virtualized platform, a daemon and a management tool. It may be used to manage KVM, XEN, vmwareESX, qemu, etc. other virtualization techniques. These APIs are widely used in cloud computing solutions. The management tool provides a plurality of convenient virtual machine management interfaces, and can conveniently operate the storage, network and other components of the virtual machine according to the interfaces.
Host machine: the physical server where the KVM virtual machine operates provides a required software and hardware environment for the operation of the KVM virtual machine.
Cloud platform management and control: and the cloud computing operation and maintenance management platform is responsible for WEB management services of man-machine interaction. The operation of the platform operation and the customer can be converted into an API interface provided by the cloud computing base; further, operation and maintenance management of the cloud computing platform is achieved through calling and function execution of various API interfaces.
Cloud platform gateway: the physical server is used for the cloud computing platform to manage access nodes and is used for deploying a server-side program on which the cloud computing platform manages and controls dependence.
The virtual serial device is a virtualization device of the KVM virtual machine and is used for simulating serial services.
And the WEB terminal module is used for: and a control Console (Console) terminal realized by WEB is integrated in cloud platform management and control and used as input and output of an interactive window simulation terminal. In the embodiment of the invention, the WEB terminal module provides cursor instruction interaction and text command interaction for a user through the virtual terminal window, wherein the cursor instruction comprises: the cursor is upward, the cursor is downward, TAB complement records and the like, a text command, namely a command which needs to be executed by a user, is input into a virtual terminal window, and the key-in is knocked out to execute and acquire a return result.
The WEB service end module: and the server program of the WEB terminal is deployed on the cloud platform gateway server. In the embodiment of the invention, the WEB server module is responsible for receiving and processing the API request sent by the WEB terminal module, and further, packages the received data into a serial port communication instruction according to the API request and sends the serial port communication instruction to the serial port gateway module of the corresponding host.
Serial port gateway module: the system is deployed on a host server and is responsible for managing and maintaining all virtual serial port devices (unix_socket) corresponding to the current host. In the embodiment of the invention, the serial port gateway module receives the data from the WEB server module, and forwards the serial port data to the corresponding socket equipment (unix_socket) according to the serial number of the KVM virtual machine in the data content. In addition, when the socket device (unix_socket) has data output, the module packages and forwards the serial number of the KVM virtual machine and corresponding data content to the WEB server side module.
Socket equipment: i.e., unix_socket, also called "socket", is a data structure in the operating system kernel, and the nodes in the network are portals for intercommunication, also the IDs of the network processes. In the embodiment of the invention, the socket equipment is a/var/kvm/com-123456 channel.
Currently, mainstream operating systems (Linux, windows, unix-like systems, etc.) all support maintenance and management of the system through serial ports. In the starting stage, the user can create a virtual serial device according to the requirement. According to the virtual serial device, the external terminal can use a serial protocol to maintain and manage the cloud instance.
Based on this, a first embodiment of the present invention provides a method for implementing a KVM virtual machine WEB terminal, including the following steps:
The method comprises the steps of firstly, creating at least one KVM virtual machine configured with virtual serial port equipment on a host machine, configuring a WEB terminal module on cloud platform management and control, and registering the KVM virtual machine on the WEB terminal module based on a three-party mapping relation through socket port equipment and serial port gateway modules configured on the host machine and a WEB server module configured on a cloud platform gateway.
Specifically, referring to fig. 1-2, first, a virtual machine VM1 and a virtual machine VM2, … including a virtual serial device (vcom) are created on a host H by using Libvirtd tools, and the specific creation flow is as follows:
1) Defining Libvirtd a virtual machine xml configuration relied on by the tool, wherein the xml configuration comprises a virtual serial device (vcom), and the detailed configuration is as follows:
……
<channel type='unix'>
<source mode='bind' path='/var/kvm/ com-123456'/>
<target type='virtio' name='org.qemu.guest_cloud' state='connected'/>
<alias name='channel0'/>
<address type='virtio-serial' controller='0' bus='0' port='3'/>
</channel>
……
2) And initializing CPU, memory and disk resources relied by the virtual machine, and starting the virtual machine.
In the process of completing the starting of the KVM virtual machine, a virtual serial device (vcom) is created, and the virtual serial device (vcom) of the virtual machine is mapped to a socket device (unix_socket) of the host machine, wherein the specific mapping process is as follows:
When the creation of the virtual machine VM1 and the virtual machine VM2 is successful and the starting is completed, the virtual machine module creates two socket devices (unix_socket) on the host machine H, namely, a/var/kvm/com-1 and a/var/kvm/com-2, wherein vcom and/var/kvm/com-1 of the virtual machine VM1 are connected, and vcom and/var/kvm/com-2 of the virtual machine VM2 are connected.
And then, the connected socket equipment is scanned at fixed time through a serial port gateway module P deployed on the host machine, a virtual serial port equipment mapping table T1 is established and maintained and updated, and the mapping relation between the virtual serial port equipment and the socket equipment is recorded by the virtual serial port equipment mapping table.
Specifically, the serial gateway module P may scan/var/kvm directory periodically, when checking that com-beginning unix_socket exists, query the virtual serial device mapping table T1 maintained by the current module, attempt to connect/var/kvm/com-1 and/var/kvm/com-2 if no record is registered, update the mapping table T1 after the device is successfully connected, and record the mapping relationship between VM1 and/var/kvm/com-1, vm2 and/var/kvm/com-2.
And then, the serial port gateway module scans the virtual serial port equipment mapping table T1 at fixed time, and sends the serial numbers of the virtual machines VM1 and VM2 and the management IP address of the current host to the WEB server side module S of the cloud platform gateway.
After receiving the serial numbers ID of the virtual machines VM1 and VM2 and the management IP address of the host, the WEB server module S establishes and maintains an updated virtual machine host mapping table T2, records that the virtual machine VM1 is on the host H, and the virtual machine VM2 is on the host H.
Finally, the WEB terminal module C can call the com_list interface at regular time to inquire the virtual machine terminal list information from the WEB server module S; the WEB service end program S responds to the com_list interface, generates full virtual machine terminal information according to the virtual machine host machine mapping list T2, and returns the full virtual machine terminal information to the WEB terminal module C, thereby completing the registration of the KVM virtual in the WEB terminal module.
And secondly, creating a virtual terminal window through the WEB terminal module C, monitoring a system mouse key message when the virtual terminal window is activated or locked, displaying input text information in the virtual terminal window based on the monitored mouse key message, calling a corresponding API interface based on a preset mouse trigger message to form a control instruction, and sending the control instruction and the virtual machine serial number ID as request data to the WEB server module.
Specifically, referring to fig. 1 and 3, when an operator needs to connect to the virtual machine VM1, a virtual terminal window VM1 is created using the WEB terminal module C. When the window of the user is locked to the virtual terminal window vm1, the WEB terminal module C starts to monitor the system keyboard and mouse messages:
when the input key is detected to be a text, namely 0-9, a-Z or A-Z, the WEB terminal module additionally displays text information into a virtual terminal window;
When the input key is detected to be a preset key mouse trigger message, the WEB terminal module acquires text information input by the current virtual terminal window and forms a control instruction according to different calls of the input key. The preset key mouse triggering message comprises a cursor up, a cursor down, a Tab key, a ctrl+c or an Enter key triggering message. The method comprises the steps that a preset mouse trigger message is a command line message of the last window and a command line message of the last window are obtained when the preset mouse trigger message is an Enter key, the command line message of the last window is called, the command line message of the request command is called, the command is called, and the command is called when the preset mouse trigger message is a ctrl+C. And the WEB terminal module sends the serial number ID of the virtual machine VM1 and the command content information to the WEB server module S.
Third, the WEB server module S receives and analyzes the request data, obtains the serial number ID of the virtual machine and the content of the control instruction, converts the content of the control instruction into a serial port protocol instruction, and sends the serial port protocol instruction to the virtual serial port equipment corresponding to the virtual machine based on the three-party mapping relation to complete execution of the serial port instruction.
Specifically, after receiving the com_submit interface message, the WEB service side module S analyzes the request data and obtains the serial number ID and the control instruction content of the virtual machine VM1, converts the control instruction content into a serial port protocol instruction, queries the host mapping relation table T2 of the virtual machine to obtain the host management IP address of the virtual machine corresponding to the obtained virtual machine serial number, and sends the virtual machine serial number and the converted serial port protocol instruction to the serial port gateway module P on the corresponding host H.
Then, the serial port gateway module P queries the virtual serial port device mapping table according to the received serial number of the virtual machine, obtains the socket device (unix_socket) mapped by the virtual serial port device (vcom) on the virtual machine VM1, and sends the received serial port protocol instruction to the corresponding virtual serial port device (vcom) through the socket device (unix_socket), so as to complete execution of the serial port protocol instruction.
Specifically, converting the control instruction content into a serial port protocol instruction specifically includes:
Convert com_up command to " ", Convert com_down command to"/>", Convert com_tab command to"/>", Convert com_cancel command to"/>”;
When the com_submit interface is called, the cmd field in the request message is acquired, and the serial port message is encapsulated: cmd field message + ".And forwarding the message information to the serial gateway module of the corresponding host.
Referring to fig. 1 and 4, in a specific example, when a user locks a mouse cursor on a virtual terminal window vm1 interface, command text information "ping www.baidu.com" is input, and an Enter key is pressed;
The WEB terminal module C requests a com_submit interface and requests parameters:
The WEB service side module S responds to the com_submit request, inquires of a host machine H where the virtual machine VM1 is located, and encapsulates a request command The data is sent to a serial port gateway module P on a host H;
The serial gateway module P on the host machine H receives the request message, inquires unix_socket corresponding to the virtual machine VM1, and sends the message Forward to/var/kvm/com-1;
Vcom on virtual machine VM1 performs a request ping www.baidu.com.
Fourth, the WEB server module queries the serial port gateway module of the corresponding host based on the query request of the WEB terminal module, acquires serial port data returned by the virtual serial port device, converts the serial port data into text data which can be displayed by the WEB terminal, packages the serial number and the text data of the virtual machine into an HTTP protocol, and sends the HTTP protocol to the WEB terminal module.
Specifically, referring to fig. 5, the virtual terminal window on the web terminal module C calls the com_status interface at regular time, and sends the VM1 serial number of the virtual machine to inquire whether the virtual machine has content to be output and displayed to the virtual terminal window VM1;
after receiving the call of the com_status interface, the WEB service end module S analyzes the VM1 serial number of the virtual machine, and inquires the output state of the VM1 terminal from the serial gateway module P of the corresponding host H;
The serial port gateway module P can check the states of socket devices (unix_socket) on all hosts in the virtual serial port device mapping table T1 at regular time, and check and record the output state information of the corresponding virtual serial port devices;
When the serial gateway module P receives a query request of the WEB server module, checking output state information of virtual serial equipment (vcom) recorded in a virtual serial equipment mapping table T1, and if the output state of the virtual serial equipment (vcom) is data, reading the serial data output by vcom from a/var/kvm/com-1 channel and returning the serial data to the WEB server module; if the/var/kvm/com-1 channel has no data, immediately answer and return null data.
Finally, the WEB service end module S checks the data returned by the serial port gateway module P, if the data is returned, the returned serial port data is converted into text content which can be displayed by the WEB terminal, and the virtual machine serial number and the text data are packaged into an HTTP protocol and sent to the WEB terminal module C.
And fifthly, after receiving query data returned by the WEB server module, the WEB terminal module updates the received data to the last row of the virtual terminal window vm1, refreshes interface display and completes command interaction between the WEB terminal module and the KVM virtual machine serial port equipment.
The second embodiment of the present invention further provides a device for implementing a KVM virtual machine WEB terminal, which is configured to implement the method for implementing a KVM virtual machine WEB terminal described in the foregoing embodiment, referring to fig. 1, and includes:
The host H is provided with at least one KVM virtual machine configured with virtual serial devices, socket devices corresponding to the virtual serial devices and a serial gateway module P, wherein the serial gateway module P establishes and maintains an updated virtual serial device mapping table T1, and the virtual serial device mapping table T1 records the mapping relation between the virtual serial devices and the socket devices;
The cloud platform gateway G is provided with a WEB server side module S, the WEB server side module S obtains a virtual machine serial number and a management IP address of a current host machine based on a virtual serial device mapping table, a virtual machine host machine mapping table T2 is established and maintained and updated, and the virtual machine host machine mapping table T2 records the corresponding relation between the KVM virtual machine and the host machine;
And the cloud platform management and control Z is provided with a WEB terminal module C, the WEB terminal module C creates virtual terminal windows vm1 and vm2 corresponding to the virtual machine, monitors a system mouse key message when the virtual terminal window is activated or locked, and transmits data and commands with the serial port gateway module P through the WEB server module S to complete command interaction of the WEB terminal module and the serial port equipment of the KVM virtual machine.
The above description of the embodiments is only for aiding in the understanding of the method of the present invention and its core ideas. It should be noted that it will be apparent to those skilled in the art that various modifications and adaptations of the invention can be made without departing from the principles of the invention and these modifications and adaptations are intended to be within the scope of the invention as defined in the following claims.

Claims (8)

1. The method for realizing the WEB terminal of the KVM virtual machine is characterized by comprising the following steps of:
S1, creating at least one KVM virtual machine configured with virtual serial port equipment on a host machine, configuring a WEB terminal module on cloud platform management and control, and registering the KVM virtual machine on the WEB terminal module based on a three-party mapping relation through socket port equipment and serial port gateway modules configured on the host machine and a WEB server module configured on a cloud platform gateway;
s2, creating a virtual terminal window through a WEB terminal module, monitoring a system mouse message when the virtual terminal window is activated or locked, displaying input text information in the virtual terminal window based on the monitored mouse message, calling a corresponding API interface based on a preset mouse trigger message to form a control instruction, and sending the control instruction in combination with a virtual machine serial number as request data to the WEB server module;
S3, the WEB server module receives and analyzes the request data, acquires the serial number of the virtual machine and the content of the control instruction, converts the content of the control instruction into a serial port protocol instruction, and sends the serial port protocol instruction to virtual serial port equipment corresponding to the virtual machine based on the three-party mapping relation to finish execution of the serial port instruction;
S4, the WEB server module queries a serial port gateway module of a corresponding host based on a query request of the WEB terminal module, acquires serial port data returned by the virtual serial port device, converts the serial port data into text data which can be displayed by the WEB terminal, packages the serial number and the text data of the virtual machine into an HTTP protocol, and sends the HTTP protocol to the WEB terminal module;
and S5, the WEB terminal module receives the data returned by the WEB server module, updates the received data to the virtual terminal window, refreshes interface display, and completes command interaction between the WEB terminal module and the KVM virtual machine serial device.
2. The method for implementing the KVM virtual machine WEB terminal of claim 1, wherein step S1 specifically includes:
S11, creating a KVM virtual machine configured with virtual serial port equipment on a host, and creating socket equipment after the starting of the KVM virtual machine is completed, wherein the socket equipment is connected with the virtual serial port equipment;
S12, scanning and connecting the socket equipment through a serial port gateway module deployed on a host machine, and establishing and maintaining and updating a virtual serial port equipment mapping table, wherein the virtual serial port equipment mapping table records the mapping relation between the virtual serial port equipment and the socket equipment;
s13, the serial port gateway module scans the mapping table of the virtual serial port equipment at regular time, and sends the serial number of the virtual machine and the management IP address of the current host to the WEB server module of the cloud platform gateway;
S14, after receiving the serial number of the virtual machine and the management IP address of the host, the WEB server module establishes and maintains and updates a mapping table of the host machine of the virtual machine, wherein the mapping table of the host machine of the virtual machine records the corresponding relation between the KVM virtual machine and the host machine;
S15, the WEB server side module responds to the query request of the WEB terminal module configured on the cloud platform management and control, generates full-quantity virtual machine terminal information based on the virtual machine host mapping table and returns the full-quantity virtual machine terminal information to the WEB terminal module, and the WEB terminal module registers the KVM virtual machine based on the returned information.
3. The method for implementing the KVM virtual machine WEB terminal of claim 2, wherein in step S2, displaying the input text information in the virtual terminal window based on the monitored mouse trigger message, and calling the corresponding API interface based on the preset mouse trigger message to form the control command in combination with the virtual machine serial number as the request data, and sending the request data to the WEB server module specifically comprises:
When the fact that the keyboard input key is a text is detected, namely 0-9, a-Z or A-Z, the virtual terminal window displays text information into the window;
When a preset key mouse trigger message is detected, the WEB terminal module acquires text information input by a current window and calls a corresponding API interface to form a control instruction according to the preset key mouse trigger message, wherein the preset key mouse trigger message comprises a cursor up, a cursor down, a Tab key, a ctrl+C or an Enter key trigger message.
4. The method for implementing the KVM virtual machine WEB terminal of claim 3, wherein invoking the corresponding API interface to form the control command according to the preset mouse trigger message specifically comprises:
The preset mouse trigger message is a com_up interface when a cursor is upward, the preset mouse trigger message is a com_down interface when the cursor is downward, the preset mouse trigger message is a Tab key, the com_tab interface is called, the preset mouse trigger message is a ctrl+c interface, and the preset mouse trigger message is an Enter key, the com_submit interface is called.
5. The method for implementing the KVM virtual machine WEB terminal as set forth in claim 4, wherein step S3 specifically includes:
S31, a WEB server module receives and analyzes the request data, acquires a virtual machine serial number and control instruction content, converts the control instruction content into a serial port protocol instruction, queries a virtual machine host mapping relation table to obtain a host management IP address of a virtual machine corresponding to the acquired virtual machine serial number, and sends the virtual machine serial number and the converted serial port protocol instruction to a serial port gateway module on a corresponding host;
S32, the serial port gateway module queries the virtual serial port device mapping table according to the received serial number of the virtual machine to find out the corresponding socket port device, and sends the received serial port protocol instruction to the virtual serial port device of the corresponding virtual machine through the socket port device, so that execution of the serial port instruction is completed.
6. The method for implementing a KVM virtual machine WEB terminal as recited in claim 5, wherein in step S31, converting the control command content into a serial port protocol command specifically includes:
Convert com_up command to " ", Convert com_down command to"/>", Convert com_tab command to"/>", Convert com_cancel command to"/>”;
When the com_submit interface is called, the cmd field in the request message is acquired, and the serial port message is encapsulated: cmd field message + ".”。
7. The method for implementing the KVM virtual machine WEB terminal as set forth in claim 6, wherein step S4 specifically includes:
S41, a virtual terminal window on the WEB terminal module is used for calling a com_status interface at fixed time to send a virtual machine serial number to inquire whether the virtual machine has contents to be output and displayed to the virtual terminal window;
s42, the WEB service end module analyzes the serial number of the virtual machine after receiving the call of the com_status interface, and inquires a serial port gateway module of a corresponding host;
S43, the serial port gateway module checks the states of the socket devices on all hosts in the virtual serial port device mapping table at regular time, and records the output state information of the corresponding virtual serial port device;
S44, when the serial gateway module receives the query request of the WEB server module, checking output state information of the virtual serial device recorded in the mapping table of the virtual serial device, and if the output state of the virtual serial device is data, reading the serial data and returning the serial data to the WEB server module; if no data exists, immediately replying and returning empty data;
S45, the WEB server side module checks the data returned by the serial port gateway module, if the data is returned, the returned serial port data is converted into text data which can be displayed by the WEB terminal, and the serial number of the virtual machine and the text data are packaged into an HTTP protocol and sent to the WEB terminal module.
8. An implementation device of a KVM virtual machine WEB terminal, configured to implement a method of implementing a KVM virtual machine WEB terminal as set forth in any one of claims 1 to 7, and comprising:
The system comprises a host machine, at least one KVM virtual machine provided with virtual serial port equipment, socket equipment corresponding to the virtual serial port equipment and a serial port gateway module, wherein the serial port gateway module establishes and maintains and updates a virtual serial port equipment mapping table, and the virtual serial port equipment mapping table records the mapping relation between the virtual serial port equipment and the socket equipment;
The cloud platform gateway is provided with a WEB server side module, the WEB server side module acquires a virtual machine serial number and a management IP address of a current host machine based on the virtual serial device mapping table, establishes and maintains an updated virtual machine host machine mapping table, and the virtual machine host machine mapping table records the corresponding relation between the KVM virtual machine and the host machine;
and the cloud platform management and control is provided with a WEB terminal module, the WEB terminal module creates a virtual terminal window corresponding to the virtual machine, monitors a system mouse key message when the virtual terminal window is activated or locked, and transmits data and commands with the serial port gateway module through the WEB server module to complete command interaction of the WEB terminal module and the serial port equipment of the KVM virtual machine.
CN202410071465.XA 2024-01-18 2024-01-18 Method and device for realizing WEB terminal of KVM (keyboard video mouse) virtual machine Active CN117591246B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410071465.XA CN117591246B (en) 2024-01-18 2024-01-18 Method and device for realizing WEB terminal of KVM (keyboard video mouse) virtual machine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410071465.XA CN117591246B (en) 2024-01-18 2024-01-18 Method and device for realizing WEB terminal of KVM (keyboard video mouse) virtual machine

Publications (2)

Publication Number Publication Date
CN117591246A CN117591246A (en) 2024-02-23
CN117591246B true CN117591246B (en) 2024-05-03

Family

ID=89918682

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410071465.XA Active CN117591246B (en) 2024-01-18 2024-01-18 Method and device for realizing WEB terminal of KVM (keyboard video mouse) virtual machine

Country Status (1)

Country Link
CN (1) CN117591246B (en)

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2015188483A1 (en) * 2014-06-10 2015-12-17 中兴通讯股份有限公司 Method for serial-parallel port mapping, cloud terminal and virtual machine
CN106487829A (en) * 2015-08-26 2017-03-08 鸿富锦精密工业(深圳)有限公司 A kind of virtual machine control system, method and user terminal
CN107122224A (en) * 2016-02-25 2017-09-01 中兴通讯股份有限公司 A kind of data transmission method, virtual machine and host
CN108632360A (en) * 2018-04-12 2018-10-09 北京百悟科技有限公司 A kind of virtual cloud terminal and virtual cloud terminal server
CN109002344A (en) * 2018-06-12 2018-12-14 广东睿江云计算股份有限公司 A kind of method of cloud management platform resetting KVM virtual machine password
CN112565372A (en) * 2020-11-27 2021-03-26 山东乾云启创信息科技股份有限公司 Communication method and system for virtual machine and client during network isolation
CN113641467A (en) * 2021-10-19 2021-11-12 杭州优云科技有限公司 Distributed block storage implementation method of virtual machine
CN113938474A (en) * 2021-10-13 2022-01-14 网易(杭州)网络有限公司 Virtual machine access method and device, electronic equipment and storage medium
CN113986451A (en) * 2021-09-29 2022-01-28 阿里巴巴(中国)有限公司 Virtual machine migration method and device, electronic equipment and storage medium
CN115134344A (en) * 2022-06-29 2022-09-30 济南浪潮数据技术有限公司 Control method and component of virtual machine console
CN115237735A (en) * 2022-07-28 2022-10-25 苏州浪潮智能科技有限公司 Method, device, equipment and medium for collecting logs of serial port of virtual machine
CN115658216A (en) * 2022-12-26 2023-01-31 飞腾信息技术有限公司 Application program window processing method and device and computer readable storage medium

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2015188483A1 (en) * 2014-06-10 2015-12-17 中兴通讯股份有限公司 Method for serial-parallel port mapping, cloud terminal and virtual machine
CN106487829A (en) * 2015-08-26 2017-03-08 鸿富锦精密工业(深圳)有限公司 A kind of virtual machine control system, method and user terminal
CN107122224A (en) * 2016-02-25 2017-09-01 中兴通讯股份有限公司 A kind of data transmission method, virtual machine and host
CN108632360A (en) * 2018-04-12 2018-10-09 北京百悟科技有限公司 A kind of virtual cloud terminal and virtual cloud terminal server
CN109002344A (en) * 2018-06-12 2018-12-14 广东睿江云计算股份有限公司 A kind of method of cloud management platform resetting KVM virtual machine password
CN112565372A (en) * 2020-11-27 2021-03-26 山东乾云启创信息科技股份有限公司 Communication method and system for virtual machine and client during network isolation
CN113986451A (en) * 2021-09-29 2022-01-28 阿里巴巴(中国)有限公司 Virtual machine migration method and device, electronic equipment and storage medium
CN113938474A (en) * 2021-10-13 2022-01-14 网易(杭州)网络有限公司 Virtual machine access method and device, electronic equipment and storage medium
CN113641467A (en) * 2021-10-19 2021-11-12 杭州优云科技有限公司 Distributed block storage implementation method of virtual machine
CN115134344A (en) * 2022-06-29 2022-09-30 济南浪潮数据技术有限公司 Control method and component of virtual machine console
CN115237735A (en) * 2022-07-28 2022-10-25 苏州浪潮智能科技有限公司 Method, device, equipment and medium for collecting logs of serial port of virtual machine
CN115658216A (en) * 2022-12-26 2023-01-31 飞腾信息技术有限公司 Application program window processing method and device and computer readable storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
基于VMM的虚拟机隐藏网络连接检测研究;蔡梦娟;;现代计算机;20191125(33);全文 *
面向虚拟机的分布式系统测试分析框架;王宇新;刘玮;郭禾;;系统仿真学报;20130208(02);全文 *

Also Published As

Publication number Publication date
CN117591246A (en) 2024-02-23

Similar Documents

Publication Publication Date Title
US10827008B2 (en) Integrated user interface for consuming services across different distributed networks
US11409719B2 (en) Co-locating microservice persistence containers within tenant-specific database
US10491700B2 (en) Application managed service instances
US10659449B2 (en) Application managed service instances
US6976262B1 (en) Web-based enterprise management with multiple repository capability
US10073709B2 (en) Session monitoring of virtual desktops in a virtual machine farm
US6643690B2 (en) Apparatus and method for determining a program neighborhood for a client node in a client-server network
JP3490369B2 (en) Content information acquisition method, collaboration system and collaboration server
US7702729B2 (en) Event heap: a coordination infrastructure for dynamic heterogeneous application interactions in ubiquitous computing environments
US9117019B2 (en) Debugging remote software applications across WAN connections
CN109395400B (en) Cross-game chat information processing method and device, electronic equipment and storage medium
US8407718B2 (en) Method and apparatus for composite user interface generation
US20140366093A1 (en) Apparatus and method for virtual desktop service
US20080288622A1 (en) Managing Server Farms
US5454109A (en) Data processing system with interface between application programs and external tools residing in separate environments
US20100077090A1 (en) Fast switching between multiple user sessions
US10798097B2 (en) Intelligent redirection of authentication devices
CA3159291A1 (en) Virtual workspace experience visualization and optimization
CN108255547B (en) Application program control method and device
CN117591246B (en) Method and device for realizing WEB terminal of KVM (keyboard video mouse) virtual machine
EP1061445A2 (en) Web-based enterprise management with transport neutral client interface
CN102255872B (en) Method and device for accessing non-remote object
CN113867878A (en) Engineering deployment method and device, electronic equipment and storage medium
CN116016480B (en) Flow automatic control method and system based on virtual desktop
US20240020080A1 (en) Handling local application events while working on remote desktops

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant