Virtualized serial port communication method, apparatus and device, and computer readable storage medium

By exposing serial ports and character devices between the virtual machine and the host machine and using the Virtio protocol to manage multiple port devices, the high development cost of virtio-serial multi-serial device communication in the cloud-hypervisor is solved, and stable and efficient virtualized communication is achieved.

CN120610918APending Publication Date: 2025-09-09BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202410263739.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-07
Publication Date
2025-09-09

AI Technical Summary

Technical Problem

In cloud computing environments, the single bus architecture of the cloud-hypervisor virtualization management software limits the communication of virtio-serial multi-port devices between virtual machines and the host, resulting in high development costs and difficulty in scalability.

Method used

By exposing serial port devices and multiple port devices inside the virtual machine and exposing character devices inside the host machine, the virtio protocol is used to realize communication between the virtual machine and the host machine, and multiple port devices can be managed without modifying the single bus logic of the cloud-hypervisor.

Benefits of technology

It reduces development costs, improves the stability and efficiency of the virtualization environment, supports communication between multiple VirtSerialPort port devices, and eliminates the need to write additional bus implementation logic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120610918A_ABST
    Figure CN120610918A_ABST
Patent Text Reader

Abstract

The invention relates to a virtualized serial port communication method, device and equipment and a computer readable storage medium, and the method comprises the steps that serial port equipment and multiple pieces of port equipment are exposed to the interior of a virtual machine, and the serial port equipment is used for managing the multiple pieces of port equipment; character equipment is exposed to the interior of a host machine, and the virtual machine runs in the host machine; and realizing communication between the virtual machine and the host machine through the port equipment and the character equipment. According to the method and the device, the plurality of port devices are managed through the serial port device, the logic of a single bus in the cloud-hypervisor does not need to be changed, the plurality of virtserial port port devices are supported under the condition that the implementation logic of the original virtio console device is not changed, the bus implementation logic does not need to be additionally compiled to manage each port device, and the development cost is greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of virtual machine technology, and in particular to a virtualized serial port communication method, apparatus, device, and computer-readable storage medium. Background Art

[0002] A virtual machine is a computer system emulated through software, with a complete hardware system, running in an isolated environment within a host computer. It provides the same operating and runtime environment as a physical computer. There are many different types of virtualization, each using different virtualization management software and hardware virtualization technologies to emulate different devices and virtualization types.

[0003] Virtio-serial devices are a type of Virtio device that provide reliable, high-performance serial communication between virtual machines and the host. In the virtualization management software QEMU, a layer of virtio serial bus logic is added to enable virtio-serial devices to manage virtio console ports and standard virtserialport ports, thereby enabling communication and collaboration between virtual machines, the host, and other virtual machines.

[0004] As different types of virtualization management software continue to mature, new virtualization management software such as cloud-hypervisor has advantages over QEMU in terms of performance, resource usage, and feature expansion. However, due to the single bus limitation of the cloud-hypervisor software architecture, if you need to support virtio-serial multi-port serial devices for communication between virtual machines and host machines, you need to modify the single bus logic of cloud-hypervisor and additionally implement the logic for using multiple PCI buses. This requires a lot of development work and high development costs. Summary of the Invention

[0005] In order to solve the above technical problems, the present disclosure provides a virtualized serial port communication method, apparatus, device and computer-readable storage medium to reduce development costs.

[0006] In a first aspect, an embodiment of the present disclosure provides a virtualized serial port communication method, which is applied to a virtualization system deployed with single-layer bus architecture virtualization management software, the method comprising:

[0007] Exposing a serial port device and multiple port devices to the virtual machine, wherein the serial port device is used to manage the multiple port devices;

[0008] Exposing a character device to the inside of a host machine, wherein the virtual machine runs in the host machine;

[0009] The communication between the virtual machine and the host machine is achieved through the port device and the character device.

[0010] In some embodiments, after exposing the character device to the host machine, the method further includes:

[0011] A data recording file corresponding to the port device is established inside the host machine. The data recording file and the port device are synchronized based on the virtio protocol. The character device is used to process the data in the data recording file.

[0012] In some embodiments, implementing communication between the virtual machine and the host machine through the port device and the character device includes:

[0013] When an application in the virtual machine initiates a communication request, binding the application to a target port device among the multiple port devices;

[0014] In response to the communication request, performing data reading and writing operations on the target port device through the application program;

[0015] Monitor the target port device through the host machine to obtain data corresponding to the data read and write operation;

[0016] The data is synchronized to the data log file.

[0017] In some embodiments, the host machine includes a backend device, and the method further includes:

[0018] The operating state of the serial port device is controlled by the operating state of the back-end device.

[0019] In some embodiments, controlling the operating state of the serial port device by the operating state of the back-end device includes:

[0020] When the backend device is in the on state, open the serial port device; or,

[0021] When the backend device is in a closed state, the serial port device is closed.

[0022] In a second aspect, an embodiment of the present disclosure provides a virtualized serial port communication device, comprising:

[0023] A first exposure module is used to expose a serial port device and multiple port devices to the virtual machine, wherein the serial port device is used to manage the multiple port devices;

[0024] a second exposing module, configured to expose a character device to a host machine in which the virtual machine runs;

[0025] A communication module is used to realize communication between the virtual machine and the host machine through the port device and the character device.

[0026] In some embodiments, the apparatus further comprises:

[0027] An establishment module is used to establish a data recording file corresponding to the port device in the host machine, the data recording file and the port device are synchronized based on the virtio protocol, and the character device is used to process the data in the data recording file.

[0028] In some embodiments, the host machine includes a backend device, and the apparatus further includes:

[0029] The control module is used to control the operating state of the serial port device through the operating state of the back-end device.

[0030] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:

[0031] Memory;

[0032] processor; and

[0033] computer programs;

[0034] The computer program is stored in the memory and is configured to be executed by the processor to implement the method as described in the first aspect.

[0035] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the method described in the first aspect.

[0036] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, implements the virtualized serial port communication method as described above.

[0037] The virtualized serial port communication method, apparatus, device, and computer-readable storage medium provided by the embodiments of the present disclosure manage multiple port devices through a serial port device without changing the logic of a single bus in the cloud-hypervisor. This supports multiple VirtSerialPort port devices without changing the original VirtIO Console device implementation logic, eliminating the need to write additional bus implementation logic to manage each port device, significantly reducing development costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0039] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0040] Figure 1 This is a diagram of the device-bus-device model architecture in the qemu project;

[0041] Figure 2 A flow chart of a virtualized serial port communication method provided in an embodiment of the present disclosure;

[0042] Figure 3 A schematic diagram of an application scenario provided by an embodiment of the present disclosure;

[0043] Figure 4 A schematic diagram of a device-device model provided in an embodiment of the present disclosure;

[0044] Figure 5 A schematic diagram of the structure of a virtualized serial port communication device provided in an embodiment of the present disclosure;

[0045] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0046] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features therein can be combined with each other in the absence of conflict.

[0047] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0048] Communication between the host and virtual machines is typically conducted over the Transmission Control Protocol (TCP) or IP sockets. However, in a virtualized environment, there are some special limitations that complicate communication. First, the virtual machine and the host are different machines, managed by different administrators. Second, the virtual machine administrator and the host administrator may be different personnel, and IP communication may be blocked when firewall rules are implemented. In particular, due to the principles of data security and openness to the outside world, there is a conflict between virtual machine administrators and host administrators. virtio-serial is based on the implementation of virtio, allowing customized devices to be exposed to virtual machines and communicate over a universal serial virtual bus.

[0049] There are many types of virtual machines, and different virtualization management software and hardware virtualization technologies simulate different devices and virtualization types. The virtualization types are divided according to the virtualization management software, such as qemu, XEN, cloud-hypervisor, etc. Different virtualization types require separate management interfaces and control architectures.

[0050] Figure 1 This is a diagram of the device-bus-device model architecture in the qemu project. Figure 1 As shown in Figure 1, this model adds a virtio serial bus layer to the existing virtiobus to manage virtio console port devices and standard virtserialport port devices. Cloud-hypervisor is an open-source virtual machine manager (VMM) that uses HTTP to interact with virtual machines. Built on the Rust programming language, it focuses on supporting modern cloud workloads. The aforementioned device-bus-device model is not applicable to the single-layer bus setup used in the cloud-hypervisor project.

[0051] To address this issue, an embodiment of the present disclosure provides a virtualized serial port communication method, which is described below in conjunction with specific embodiments.

[0052] Figure 2 Flowchart of the virtualized serial port communication method provided by the embodiment of the present disclosure. This method can be applied to Figure 3 The application scenario shown in FIG. 1 includes a virtualization system deployed with a single-layer bus architecture virtualization management software. Figure 3 As shown, the scenario includes a host machine (host) 31 , a virtual machine (guest) 32 and a virtualization management software (Cloud-hypervisor) 33 .

[0053] The following combination Figure 2 The application scenario shown is Figure 1 The virtualized serial port communication method shown in FIG. 1 is introduced, and the specific steps of the method are as follows:

[0054] S201. Expose a serial port device and multiple port devices to a virtual machine, where the serial port device is used to manage the multiple port devices.

[0055] Serial devices (virtio serial devices) are used to implement serial communication in a virtualized environment. Based on the Virtio specification, they provide a standardized, cross-platform method for communicating with virtual serial devices. By using a Virtioserial device, a virtual machine can communicate with serial devices on the host machine for data transmission and control. Virtioserial devices are efficient, reliable, and scalable, offering improved performance and stability while supporting multiple serial communication protocols.

[0056] The Virtio protocol is an open standard for device drivers in virtualized environments. It provides high-performance device access and sharing by reducing communication overhead between virtual machines and the host. It is a commonly used technology in modern virtualization platforms, providing improved performance and efficiency.

[0057] During virtual machine creation and management, serial port communication functionality can be generated, enabled, and configured by configuring a Virtio serial device. In the disclosed embodiment, the serial port device is used to manage one or more port devices (virtserialport devices) by communicating control information with the corresponding kernel driver, and also functions as a Virtio device to process the Virtio protocol.

[0058] The port device is the front-end driver for serial communication, running in the virtual machine. It is responsible for communicating with the application, transferring data information with the kernel driver, and sending the application's serial communication request to the back-end driver. The back-end driver runs on the host machine, is responsible for communicating with the host machine's application, and sends the received data back to the front-end driver.

[0059] Figure 4 A schematic diagram of a device-device model provided in an embodiment of the present disclosure. Figure 4 As shown, the serial port device (virtio serial device) is directly connected to the virtiobus bus and acts as a controller to manage multiple port devices (virtserialport devices) under it.

[0060] Meanwhile, the Virtio console device shown in the figure is a data input and output device for transferring information between the front-end driver and the back-end driver.

[0061] S202: Exposing a character device to the inside of a host machine, wherein the virtual machine runs in the host machine.

[0062] The character device is exposed to the host by the chardev backend device. The chardev backend device runs on the host as a backend driver, responsible for communicating with the actual serial port device and sending the received data back to the front-end driver.

[0063] S203: Implement communication between the virtual machine and the host machine through the port device and the character device.

[0064] After the above steps, if Figure 3 As shown, the serial port device and the corresponding port device created by the virtualization management software (Cloud-hypervisor) 33 are exposed to the virtual machine (guest) 32, and the character device (unixsocket type character device) is exposed to the host (host) 31, and the communication between the virtual machine and the host is realized through the port device and the character device.

[0065] The disclosed embodiments expose a serial port device and multiple port devices to the inside of a virtual machine, where the serial port device is used to manage the multiple port devices; expose a character device to the inside of a host machine where the virtual machine runs; implement communication between the virtual machine and the host machine through the port device and the character device, and manage multiple port devices through the serial port device without changing the logic of a single bus in the cloud-hypervisor. Without changing the original virtio console device implementation logic, multiple virtserialport port devices are supported, eliminating the need to write additional bus implementation logic to manage each port device, thereby significantly reducing development costs.

[0066] At the same time, the disclosed embodiment manages multiple port devices (virtserialport devices) through a serial port device (virtio serial device) without using the layer virtio serial bus bus management. Multiple port devices can be seen in the virtual machine, and the management of the virtio console device and the virtserialport port device by the virtio serial device is decoupled. Therefore, there is no need to consider compatibility issues. Figure 1 The architecture of the qemu project shown has one more available port device, while port 0 in the qemu project is not available.

[0067] In addition, through serial port devices, the performance indicators, operating status and resource utilization of virtual machines can be monitored and collected in real time, and automated and intelligent management strategies can be adopted to improve the stability, reliability and efficiency of the virtualization environment and provide better services for cloud computing.

[0068] Based on the above embodiment, after exposing the character device to the host machine, the method further includes: establishing a data recording file corresponding to the port device inside the host machine, the data recording file and the port device synchronize data based on the virtio protocol, and the character device is used to process the data in the data recording file.

[0069] Specifically, the communication between the virtual machine and the host machine is realized through the port device and the character device, including: when the application in the virtual machine initiates a communication request, binding the application to a target port device among the multiple port devices; in response to the communication request, performing data reading and writing operations on the target port device through the application; monitoring the target port device through the host machine to obtain data corresponding to the data reading and writing operations; and synchronizing the data to the data recording file.

[0070] like Figure 3 As shown, one or more applications are running in the virtual machine. When one of the applications (for example Figure 3 The APP-agent shown in needs to communicate with the host, so it initiates a communication request and binds the target port device (for example, Figure 3 XXX.100) is used for communication. The target port device can be one or more, depending on the actual needs of the communication request. The name of the target port device can also be configured according to actual needs.

[0071] Accordingly, a data record file is created in the host machine (for example Figure 3 At the same time, based on the communication protocol (such as the Virtio protocol described in the above embodiment), the data read and write operations in the target port device are monitored, and the data corresponding to the data read and write operations in the target port device are synchronized to the data record file. The character device processes the data in the data record file, and the application running in the host machine (such as Figure 3 The APP-host shown in FIG can obtain the data in the virtual machine from the data record file, thereby realizing the communication between the virtual machine and the host machine.

[0072] In some embodiments, not only Unix socket-type character devices can be used as communication devices, but also file, pty, and tty types. Unix socket-type character devices enable bidirectional communication. Specifically, an application on the host machine updates data in a data log file and synchronizes that data to the target port device corresponding to the data log file, thereby enabling communication between the host machine and the virtual machine.

[0073] The embodiment of the present disclosure implements communication between the virtual machine and the host machine through port devices and data recording files, without the need to write additional bus implementation logic to manage each port device, thereby greatly reducing development costs.

[0074] In some embodiments, the host machine includes a backend device, and the method further includes: controlling the operating state of the serial port device through the operating state of the backend device.

[0075] Specifically, when the backend device is in an on state, the serial port device is turned on; or when the backend device is in an off state, the serial port device is turned off.

[0076] The backend device (chardev device) is the backend device of the virtserialport device, which is used to connect to the application in the host machine. To ensure the security of data transmission, the opening and closing of the chardev device in the host machine controls the opening and closing of the serial port device in the virtual machine. The following is an example implementation:

[0077] / / / Provide the trait that notifies device the socket is opened onclosed.impl ChardevNotifyDevice for SerialPort{

[0078] fn chardev_notify(&mut self,status:ChardevStatus){

[0079] match(&status,self.host_connected){

[0080] (ChardevStatus::Close,_)=>self.host_connected=false,

[0081] (ChardevStatus::Open,false)=>self.host_connected-true,

[0082] (ChardevStatus::Open,true)=>return,

[0083] }

[0084] if let Some(handler:&Weak<Mutex <serialcontrolhandler>>)=&self.ctrl_handler{

[0085] let handler:Arc<Mutex <serialcontrolhandler>>=

[0086] handler.upgrade().unwrap();

[0087] handler.lock().unwrap().send_control_event(

[0088] id:self.nr,

[0089] event:VIRTIO_CONSOLE_PORT_OPEN,

[0090] value:status as u16, );

[0092] }else{

[0093] error! ("Control handler for port{}is None",self.nr);

[0094] }

[0095] }

[0096] In some embodiments, to ensure stability when the host machine communicates with the virtual machine, a stream event is added when the accept socket event response is triggered.

[0097] Specifically, when handling network communications, especially when using sockets, you may encounter the need to handle a variety of different types of events, including accepting connections (accept), reading data (read or recv), and writing data (write or send). When the accept socket event response is triggered, it responds to the application's communication request, connects to the corresponding port device and character device, and monitors the newly established connection.

[0098] In some embodiments, the communication in the present invention uses an event-driven I / O model based on epoll to handle data transmission between port devices and backend devices. Taking a Unix socket character device as the host machine's communication interface as an example, the connection establishment, established connection, send, and receive events during the communication process are all placed into the epoll pool as events. The triggering and processing of each event are automatic, which greatly improves communication efficiency.

[0099] Figure 5 Schematic diagram of the structure of the virtualized serial port communication device provided in the embodiment of the present disclosure. The virtualized serial port communication device can be a virtualized system deployed with Cloud-hypervisor virtualization management software as described in the above embodiment, or the virtualized serial port communication device can be a component or assembly in the virtualized system. The virtualized serial port communication device provided in the embodiment of the present disclosure can execute the processing flow provided in the embodiment of the virtualized serial port communication method, such as Figure 5 As shown, the virtualized serial port communication device 50 includes: a first exposure module 51, a second exposure module 52, and a communication module 53; the first exposure module 51 is used to expose a serial port device and multiple port devices to the inside of the virtual machine, and the serial port device is used to manage the multiple port devices; the second exposure module 52 is used to expose a character device to the inside of the host machine, and the virtual machine runs in the host machine; the communication module 53 is used to realize communication between the virtual machine and the host machine through the port device and the character device.

[0100] Optionally, the virtualized serial port communication device 50 also includes an establishment module 54, which is used to establish a data recording file corresponding to the port device inside the host machine, and the data recording file and the port device are synchronized based on the virtio protocol. The character device is used to process the data in the data recording file.

[0101] Optionally, the communication module 53 includes a binding unit 531, a read-write unit 532, a monitoring unit 533, and a synchronization unit 534; the binding unit 531 is used to bind the application in the virtual machine to the target port device among the multiple port devices when the application in the virtual machine initiates a communication request; the read-write unit 532 is used to respond to the communication request and perform data read and write operations on the target port device through the application; the monitoring unit 533 is used to monitor the target port device through the host machine to obtain data corresponding to the data read and write operations; the synchronization unit 534 is used to synchronize the data to the data recording file.

[0102] Optionally, the host machine includes a backend device, and the virtualized serial port communication apparatus 50 further includes a control module 55 for controlling the operating state of the serial port device according to the operating state of the backend device.

[0103] Optionally, the control module 55 is configured to turn on the serial port device when the back-end device is in an on state; or to turn off the serial port device when the back-end device is in an off state.

[0104] Figure 5 The virtualized serial port communication device of the illustrated embodiment can be used to implement the technical solution of the above-mentioned method embodiment. Its implementation principle and technical effects are similar and will not be repeated here.

[0105] Figure 6 The electronic device provided in the embodiment of the present disclosure can be a device where the virtualization system described in the above embodiment is located. The electronic device provided in the embodiment of the present disclosure can execute the processing flow provided in the embodiment of the virtualized serial port communication method, such as Figure 6 As shown, the electronic device 60 includes: a memory 61, a processor 62, a computer program and a communication interface 63; wherein the computer program is stored in the memory 61 and is configured so that the processor 62 executes the virtualized serial port communication method as described above.

[0106] In addition, an embodiment of the present disclosure further provides a computer-readable storage medium on which a computer program is stored. The computer program is executed by a processor to implement the virtualized serial port communication method described in the above embodiment.

[0107] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.

[0108] In some embodiments, the client and server can communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0109] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0110] In addition, an embodiment of the present disclosure further provides a computer program product, which includes a computer program or instructions. When the computer program or instructions are executed by a processor, the virtualized serial port communication method described above is implemented.

[0111] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0112] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.

[0113] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0114] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.

[0115] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprise," "include," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprises a..." does not exclude the presence of other identical elements in the process, method, article, or device that includes the element.

[0116] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0117] The foregoing description is intended only to provide specific embodiments of the present disclosure, intended to enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the embodiments described herein, but rather to be construed in the broadest manner consistent with the principles and novel features disclosed herein.< / serialcontrolhandler> < / serialcontrolhandler>

Claims

1. A virtualized serial port communication method, characterized in that: Applied to a virtualization system deployed with single-layer bus architecture virtualization management software, the method includes: Exposing a serial port device and multiple port devices to the virtual machine, wherein the serial port device is used to manage the multiple port devices; Exposing a character device to the inside of a host machine, wherein the virtual machine runs in the host machine; The communication between the virtual machine and the host machine is achieved through the port device and the character device.

2. The method according to claim 1, characterized in that After exposing the character device to the host machine, the method further includes: A data recording file corresponding to the port device is established inside the host machine. The data recording file and the port device are synchronized based on the virtio protocol. The character device is used to process the data in the data recording file.

3. The method according to claim 2, characterized in that The implementing of communication between the virtual machine and the host machine through the port device and the character device includes: When an application in the virtual machine initiates a communication request, binding the application to a target port device among the multiple port devices; In response to the communication request, performing data reading and writing operations on the target port device through the application program; Monitor the target port device through the host machine to obtain data corresponding to the data read and write operation; The data is synchronized to the data log file.

4. The method according to claim 1, wherein The host machine includes a backend device, and the method further includes: The operating state of the serial port device is controlled by the operating state of the back-end device.

5. The method according to claim 4, characterized in that The controlling the operating state of the serial port device by the operating state of the back-end device includes: When the backend device is in the on state, open the serial port device; or, When the backend device is in a closed state, the serial port device is closed.

6. A virtualized serial port communication device, characterized in that: include: A first exposure module is used to expose a serial port device and multiple port devices to the virtual machine, wherein the serial port device is used to manage the multiple port devices; a second exposing module, configured to expose a character device to a host machine in which the virtual machine runs; A communication module is used to realize communication between the virtual machine and the host machine through the port device and the character device.

7. The device according to claim 6, characterized in that The device further comprises: An establishment module is used to establish a data recording file corresponding to the port device in the host machine, the data recording file and the port device are synchronized based on the virtio protocol, and the character device is used to process the data in the data recording file.

8. The device according to claim 6, characterized in that The host machine includes a backend device, and the apparatus further includes: The control module is used to control the operating state of the serial port device through the operating state of the back-end device.

9. An electronic device, characterized in that: include: Memory; processor; as well as computer programs; The computer program is stored in the memory and configured to be executed by the processor to implement the method according to any one of claims 1 to 5.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Virtual system restarting method and device

    CN112114937A

  • Virtual machine serial port log collection method and device, equipment and medium

    CN115237735A

  • Virtual Serial Apparatus

    US20070124527A1

  • High-availability computing node apparatus for openstack virtual machine capable of preventing split-brain and management method

    WO2020113669A1