Virtual machine cross-operating system communication method
By setting up shared memory areas for virtual machines in the microkernel operating system and establishing a priority event notification mechanism, the communication performance overhead and security problems between virtual machines are solved, and efficient and secure cross-operating system communication is achieved.
Patent Information
- Application Number
- CN202510182410.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-19
- Publication Date
- 2025-05-16
AI Technical Summary
Existing inter-VM communication methods have performance overhead and security issues, such as poor performance of network socket communication and insufficient security of shared memory technology.
By creating virtual machines in the microkernel operating system and allocating static physical resources to each virtual machine, setting up shared memory areas and protecting their access rights through power mechanisms, establishing a priority-based event notification mechanism to achieve efficient and secure communication between virtual machines.
Improves the efficiency and security of communication between virtual machines, ensures that only authorized virtual machines can access the shared memory area, and optimizes resource allocation and communication efficiency.
Smart Images

Figure CN120010999A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of virtual machines, and more specifically, relates to a virtual machine cross-operating system communication method. Background Art
[0002] Virtual machine technology is widely used in servers, desktop environments, embedded systems and other fields. It abstracts physical hardware resources into virtual resources to achieve resource isolation. Virtualization technology can make full use of limited resources and support multiple operating systems to run on the same hardware platform, each playing a different role. The virtual machine manager (Hypervisor) implements the isolation and sharing of processor resources, memory resources and peripheral resources between different partitions, so the upper-level virtual machines cannot communicate directly. However, a key function of virtualization is the sharing of data and memory between virtual machines and between the host system and virtual machines. In order to achieve this goal, the industry has proposed various inter-virtual machine communication methods. The main inter-virtual machine communication methods include communication between virtual machines through network sockets, shared memory technology, XenSocket, XenLoop and IVSHMEM. These methods have their own advantages and disadvantages, but they all have certain performance overhead and security issues:
[0003] Although network socket communication has a wide range of applications, data transmission needs to go through the protocol stack, which results in multiple data copies and network delays, resulting in high performance overhead;
[0004] Shared memory technology: Although it can improve communication efficiency, existing shared memory technologies (such as XenSocket, XenLoop, and IVSHMEM) still rely on the network protocol stack or virtual PCI devices, cannot directly access shared memory, and lack precise protection of shared memory areas;
[0005] Virtual PCI device communication: It relies on virtual PCI devices. It is not applicable to operating systems that do not support PCI devices (such as some embedded systems), and cannot guarantee data synchronization and real-time performance when multiple virtual machines access shared memory at the same time. Summary of the invention
[0006] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a method for virtual machine cross-operating system communication. By utilizing the unique characteristics of a microkernel operating system, a reliable event notification mechanism is implemented by establishing an efficient communication channel between virtual machines. At the same time, the permission protection mechanism of the microkernel is utilized to strictly protect the shared memory area between virtual machines, ensuring that only virtual machines that are authorized and mapped to this memory area can access it, thereby solving the performance overhead and security problems of communication between virtual machines in the prior art.
[0007] In order to achieve the above-mentioned object of the invention, the virtual machine cross-operating system communication method of the present invention comprises the following steps:
[0008] S1: The microkernel hypervisor creates virtual machines and allocates static physical resources to each virtual machine;
[0009] S2: Set a shared memory area for any two virtual machines and map the shared memory area to the virtual address spaces of the corresponding two virtual machines;
[0010] S3: Set the shared memory area through the capability mechanism so that only the associated virtual machine can access the corresponding shared memory area;
[0011] S4: Establish a priority-based event notification mechanism in the microkernel hypervisor to schedule and manage communication tasks of different priorities;
[0012] S5: When two virtual machines need to communicate, data is transmitted through the corresponding shared memory area. The specific method is as follows: the sending virtual machine writes data into the shared memory area and sends communication information to the microkernel hypervisor. After receiving the communication information, the microkernel hypervisor determines the priority of the current communication and sorts the existing communications according to the priority-based event notification mechanism. When this communication has the highest priority, a notification is sent to the corresponding receiving virtual machine. After receiving the notification, the receiving virtual machine reads the data from the shared memory area to complete this communication.
[0013] The invention discloses a virtual machine cross-operating system communication method. A microkernel hypervisor creates a virtual machine and allocates static physical resources to each virtual machine. A shared memory area is set for any two virtual machines and bound to the corresponding virtual machines. A sending virtual machine initiates communication and writes data into the shared memory area, while a receiving virtual machine reads the data from the shared memory, thereby realizing cross-operating system communication of the virtual machines.
[0014] The present invention has the following beneficial effects:
[0015] 1) The present invention is based on shared memory technology. Only the two virtual machines that have established a communication connection can access these memory areas, while other virtual machines cannot access them, thereby greatly improving data security;
[0016] 2) The present invention designs a priority-driven message notification mechanism, which ensures that in the event of an urgent communication event, virtual machines with high priorities can share data first, thereby optimizing resource allocation and communication efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1is a flowchart of a specific implementation method of the cross-operating system communication method of the present invention;
[0018] Figure 2 It is a structural diagram of the priority queue in this embodiment. DETAILED DESCRIPTION
[0019] The specific implementation of the present invention is described below in conjunction with the accompanying drawings so that those skilled in the art can better understand the present invention. It should be noted that in the following description, when the detailed description of known functions and designs may dilute the main content of the present invention, these descriptions will be omitted here.
[0020] Example
[0021] Figure 1 FIG. 1 is a flow chart of a specific implementation method of the cross-operating system communication method of the present invention. Figure 1 As shown, the specific steps of the cross-operating system communication method of the present invention include:
[0022] S101: Create a virtual machine
[0023] The microkernel hypervisor creates a virtual machine and allocates static physical resources to each virtual machine. That is to say, the microkernel hypervisor in the present invention directly allocates the required physical resources (such as CPU, memory, peripherals, etc.) to the virtual machine when the virtual machine is started, and no dynamic allocation is performed after the virtual machine is running. The hypervisor reads the configuration file, which contains the configuration parameters required for each virtual machine to communicate, mainly including shmid (unique ID of the virtual machine communication channel), shared memory address shm_addr, shared memory size shm_size, interrupt number irq_num, etc.
[0024] S102: Setting up the shared memory area:
[0025] A shared memory area is set for any two virtual machines, and the shared memory area is mapped into the virtual address spaces of the corresponding two virtual machines.
[0026] In this embodiment, the shared memory area is divided into two blocks, one for write buffer and the other for read buffer. The core advantage of this design is that it implements asynchronous full-duplex communication, that is, the virtual machine can perform read and write operations at the same time without waiting for the other party to complete the operation, thereby improving the efficiency of data transmission between virtual machines.
[0027] S103: Bind shared memory area:
[0028] The shared memory area is set through the capability mechanism so that only the associated virtual machine can access the corresponding shared memory area.
[0029] Since the Hypervisor is based on a microkernel architecture, all resources are protected based on capabilities. Each virtual machine corresponds to a kernel object CAP_VM. According to the size of shm_size, the Hypervisor uses the malloc function to allocate a piece of memory for the shared memory area for data transmission between virtual machines. This shared memory area is protected by capabilities, and only the relevant virtual machines have access rights. The Hypervisor maps this memory area to the virtual machine through the stage-2 page table so that it can access it. It should be noted that although the shared memory area accessed between the two virtual machines is the same piece of memory, the physical address of the shared memory seen by each virtual machine may be different. This is because the Hypervisor maps the shared memory address seen by the VM itself separately to ensure that the virtual machine can access the correct address.
[0030] S104: Establishing an event notification mechanism:
[0031] The microkernel hypervisor establishes a priority-based event notification mechanism to schedule and manage communication tasks of different priorities.
[0032] In this embodiment, the microkernel hypervisor constructs a priority queue priority_queue_t in the root service rootserver for managing communications between all virtual machines, which is mainly implemented based on a bidirectional linked list. Figure 2 is a structural diagram of the priority queue in this embodiment. Figure 2 As shown, in this embodiment, the priority queue mainly includes a bidirectional linked list node structure list_head_t, which contains pointers to the previous node and the next node, and a queue element structure queue_node_t, which contains a priority prio, a shared memory identifier shmid, a data buffer pointer buf, and a bidirectional linked list node node. The microkernel hypervisor configures the event priority according to the priority of the virtual machine, and adds it to the priority queue, selecting the highest priority communication for execution each time, thereby ensuring that the high-priority virtual machine can have priority in data transmission.
[0033] S105: Execute communication:
[0034] When two virtual machines need to communicate, data is transmitted through the corresponding shared memory area. The specific method is as follows: the sending virtual machine writes data into the shared memory area and sends communication information to the microkernel hypervisor. After receiving the communication information, the microkernel hypervisor determines the priority of the current communication and sorts the existing communications according to the priority-based event notification mechanism. When this communication has the highest priority, a notification is sent to the corresponding receiving virtual machine. After receiving the notification, the receiving virtual machine reads the data from the shared memory area to complete this communication.
[0035] In this embodiment, when the shared memory area is divided into a write buffer and a read buffer, the specific method for the virtual machine to perform data transmission through the shared memory area is:
[0036] 1) The sending virtual machine writes data to the write buffer of the bound shared memory area; initiates a hypercall and notifies the virtual machine hypervisor;
[0037] 2) After receiving the hypercall, the microkernel hypervisor jumps to the kernel's aborts_sync_handler function to handle the synchronization exception;
[0038] 3) The service thread in the root service is unblocked, the parameters from the hypercall are extracted and inserted into the priority queue;
[0039] 4) The microkernel hypervisor extracts the queue head node from the priority queue and copies the data to the read buffer of the receiving virtual machine;
[0040] 5) The receiving virtual machine reads the data through the interrupt mechanism and completes a communication.
[0041] Although the above describes the illustrative specific embodiments of the present invention to facilitate those skilled in the art to understand the present invention, it should be clear that the present invention is not limited to the scope of the specific embodiments. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations using the concept of the present invention are protected.
Claims
1. A virtual machine cross-operating system communication method, characterized in that: The following steps are involved: S1: The microkernel hypervisor creates virtual machines and allocates static physical resources to each virtual machine; S2: Set a shared memory area for any two virtual machines and map the shared memory area to the virtual address spaces of the corresponding two virtual machines; S3: Set the shared memory area through the capability mechanism so that only the associated virtual machine can access the corresponding shared memory area; S4: Establish a priority-based event notification mechanism in the microkernel hypervisor to schedule and manage communication tasks of different priorities; S5: When two virtual machines need to communicate, data is transmitted through the corresponding shared memory area. The specific method is as follows: the sending virtual machine writes data into the shared memory area and sends communication information to the microkernel hypervisor. After receiving the communication information, the microkernel hypervisor determines the priority of the current communication and sorts the existing communications according to the priority-based event notification mechanism. When this communication has the highest priority, a notification is sent to the corresponding receiving virtual machine. After receiving the notification, the receiving virtual machine reads the data from the shared memory area to complete this communication.
2. The virtual machine cross-operating system communication method according to claim 1, characterized in that: The shared memory area is divided into a write buffer and a read buffer.
3. The virtual machine cross-operating system communication method according to claim 2, characterized in that: The specific method for the virtual machine to perform data transmission through the shared memory area in step S5 is: S5.1: The sending VM writes data to the write buffer of the bound shared memory area, initiates a hypercall and notifies the VM hypervisor; S5.2: After receiving the hypercall, the microkernel hypervisor jumps to the kernel's aborts_sync_handler function to handle the synchronization exception; S5.3: The service thread in the root service is unblocked, the parameters from the hypercall are extracted and inserted into the priority queue; S5.4: The microkernel hypervisor extracts the queue head node from the priority queue and copies the data to the read buffer of the receiving virtual machine; S5.5: The receiving virtual machine reads the data through the interrupt mechanism and completes a communication.
4. The virtual machine cross-operating system communication method according to claim 1, characterized in that: The specific method of the priority-based event notification mechanism in step S4 is: The microkernel hypervisor builds a priority queue priority_queue_t based on a bidirectional linked list in the root service rootserver to manage communications between all virtual machines. It configures the event priority according to the priority of the virtual machine and adds it to the priority queue, selecting the highest priority communication for execution each time.
Citation Information
Cited By
A dds communication method under a static partition virtualization environment
CN122593907A