A method for supporting priority-based inter-virtual machine real-time communication

CN116795567BActive Publication Date: 2026-08-11BEIJING INST OF COMP TECH & APPL
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-27
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0010]本发明要解决的技术问题是如何提供一种支持优先级的虚拟机间实时通信方法,以解决现有虚拟机间通信实时性的不足:效率较低、资源开销过大、无法提供消息优先级支持等方面的问题

Benefits of technology

[0033] This invention proposes a priority-based real-time communication method between virtual machines (VMs). This method provides a more efficient and real-time solution for virtualization platforms, meeting the high real-time requirements of embedded applications. By combining hardware characteristics with VM core binding and an inter-core interrupt mechanism, this invention reduces the overhead of the virtual machine manager allocating and switching cores for VMs. The inter-core interrupt mechanism reduces the complexity of inter-VM communication, decreases the multi-level context switching overhead involved in the interrupt controller or virtual interrupt controller, lowers software design difficulty, significantly improves communication response speed, and optimizes real-time performance. Through software design, priority binding between VMs and shared memory domains allows for privileged priority communication settings for VMs with different high real-time requirements, further optimizing real-time performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116795567B_ABST
    Figure CN116795567B_ABST
Patent Text Reader

Abstract

This invention relates to a priority-based real-time communication method between virtual machines, belonging to the field of virtualization technology. This invention sets priority privileges for inter-virtual machine communication for different virtual machines. Messages are stored in a shared memory domain with priority attributes based on the priority privileges of the target machine. When concurrent virtual machine communication occurs, data from higher-priority virtual machines is processed first. This invention, combined with hardware characteristics, reduces the overhead of the virtual machine manager allocating and switching cores for virtual machines by binding virtual machines to cores and incorporating an inter-core interrupt mechanism. The inter-core interrupt mechanism reduces the complexity of inter-virtual machine communication, reduces the multi-level context switching overhead involved in the interrupt controller or virtual interrupt controller, lowers software design difficulty, significantly improves communication response speed, and optimizes real-time performance. This invention implements priority-based communication privilege settings for virtual machines with different real-time requirements, further optimizing real-time performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of virtualization technology, specifically relating to a real-time communication method between virtual machines that supports priority. Background Technology

[0002] With the rapid development of computer technology and the improvement of hardware performance, people have higher demands for hardware utilization. In many application scenarios, the utilization rate of resources is far from the theoretical value, resulting in resource waste. The emergence of virtualization technology has solved this problem well. The core of virtualization technology is to run different software architectures on a single hardware resource to meet diverse software needs. This involves an important technology - inter-virtual machine communication, which is an unavoidable technology of virtualization technology and the most core requirement in application scenarios.

[0003] Current virtualization technologies employ a variety of inter-virtual machine communication techniques, but their underlying logic implementations can generally be categorized into the following two types:

[0004] Virtual peripheral device communication: Virtualization technology provides a way for virtual peripheral devices to communicate with each other. The implementation is similar to that of an operating system running on a physical machine. Users write drivers and register them with the virtual machine, while the underlying virtual machine provides software-based switches or mapped shared I / O for message exchange.

[0005] Communication mechanisms such as event channels and shared memory are implemented at the underlying level based on the interrupt mechanism of shared memory and interrupt controller. The virtual machine that sends the message triggers a virtual interrupt, which in turn triggers a physical interrupt. The physical interrupt then triggers the interrupt vector corresponding to the target virtual machine. At this time, the interrupt service routine registered by the interrupt vector runs and reads the data from the shared memory.

[0006] The above summarizes the main technologies currently used for inter-virtual machine communication.

[0007] Inter-virtual machine communication generally involves two approaches: one using virtual peripheral devices and the other combining interrupts and memory. The former is more commonly used in full virtualization technology. Because virtual machines in full virtualization believe they are running on a physical machine, they use virtual devices in the same way as the operating system on the physical machine. Each virtual device needs to be registered with its host virtual machine, and corresponding drivers and applications need to be written. This process is cumbersome, and data needs to be transferred through multiple levels, resulting in low efficiency. In full virtualization technology, virtual machines are generally run as processes on the host machine, which cannot provide real-time characteristics for real-time operating system virtual machines.

[0008] Another approach combining interrupts and shared memory is commonly used in paravirtualization. Virtual machines communicate through a virtual interrupt controller, which assigns an interrupt vector to each machine. The virtual machine registers an interrupt service routine with the controller. While this interrupt allocation meets the communication needs between virtual machines, each interrupt execution by the virtual machine and the physical machine involves a context switch, which is resource-intensive. These two switches significantly impact interrupt response time, causing message communication delays. In paravirtualization, messages are read from shared memory via interrupt routines. However, during concurrent communication between virtual machines, a first-in, first-out (FIFO) approach is required. This can cause delays in messages from virtual machine operating systems with high real-time requirements, while messages from non-real-time virtual machine operating systems are processed first, resulting in a counterproductive outcome. Summary of the Invention

[0009] (a) Technical problems to be solved

[0010] The technical problem to be solved by this invention is how to provide a real-time inter-virtual machine communication method that supports priority, so as to solve the shortcomings of existing inter-virtual machine communication in terms of real-time performance, such as low efficiency, excessive resource overhead, and inability to provide message priority support.

[0011] (II) Technical Solution

[0012] To address the aforementioned technical problems, this invention proposes a priority-based real-time communication method between virtual machines, comprising the following steps:

[0013] S01. Virtual machine core binding startup: Each virtual machine is assigned a configuration file, including: the core paired with each virtual machine, the priority of each virtual machine and the message memory domain address information;

[0014] S02, The application of the sending virtual machine requests virtual machine communication;

[0015] S03. The application of the sending virtual machine writes data into the sending buffer, and the data includes the target virtual machine information.

[0016] S04. The sending virtual machine stores the data in the sending buffer into the message memory field corresponding to the target virtual machine via the virtual machine manager.

[0017] S05, The sending virtual machine then handles the inter-core interrupt distribution through the virtual machine manager;

[0018] S06, The sending virtual machine triggers an inter-core interrupt;

[0019] S07. The sending virtual machine returns the task and continues to execute the task;

[0020] S08. The interrupt service routine checks the cumulative number of messages in the message memory field corresponding to each priority level, determines whether there are messages in the message memory field corresponding to each priority level, and prioritizes processing the operating system message memory field with higher priority.

[0021] S09. The interrupt service routine reads the message from the corresponding operating system message memory domain into the target virtual machine's receive buffer.

[0022] S10, The receiving virtual machine application retrieves the data from the receive buffer in the message memory field.

[0023] Furthermore, in step S01, each virtual machine corresponds to one or more cores.

[0024] Furthermore, in step S01, each virtual machine corresponds to a priority, and each priority corresponds to a message memory domain address.

[0025] Furthermore, in step S05, the virtual machine manager distributes an inter-core interrupt to the core to which the target virtual machine is bound. If multiple cores are bound at the same time, the interrupt is distributed to any one of them.

[0026] Furthermore, in step S06, the virtual machine manager is responsible for obtaining information between the two virtual machines that are communicating via inter-core interrupt, identifying which virtual machine is the sender and the core corresponding to the sending virtual machine, identifying which virtual machine is the receiver and the core corresponding to the receiving virtual machine, and then calling the function interface for managing inter-core interrupts based on the statistical information.

[0027] Furthermore, a structure memory area and a message memory area are set up in memory. The structure memory area is used to store the structure structmsg_status that describes the message memory area. The structure memory area and the message memory area are managed separately.

[0028] Furthermore, the structure structmsg_status manages the addresses of message memory fields with different priorities and the cumulative number of messages in the message memory field under that priority. In step S08, it is determined whether there are messages in the message memory field based on the cumulative number of messages managed in the structure structmsg_status.

[0029] Furthermore, msg_pri0_count indicates the number of messages with priority 0 currently. When a storage event occurs in the message's memory field, i.e., a virtual machine communication event occurs, msg_pri0_count is incremented by 1. When an interrupt response event occurs and the message is retrieved, msg_pri0_count is decremented by 1. Each time an interrupt is processed, it is first checked whether there is data in the higher priority count, and data is retrieved from the higher priority message memory field first.

[0030] Furthermore, the message memory domain allocates a fixed segment of memory space for virtual machine messages of various priorities according to user needs, and continuously allocates N segments of memory space of the same size, where N is the number of priorities.

[0031] Furthermore, within a specific priority message memory domain, a circular queue or circular linked list is used for message management within that priority message memory domain.

[0032] (III) Beneficial Effects

[0033] This invention proposes a priority-based real-time communication method between virtual machines (VMs). This method provides a more efficient and real-time solution for virtualization platforms, meeting the high real-time requirements of embedded applications. By combining hardware characteristics with VM core binding and an inter-core interrupt mechanism, this invention reduces the overhead of the virtual machine manager allocating and switching cores for VMs. The inter-core interrupt mechanism reduces the complexity of inter-VM communication, decreases the multi-level context switching overhead involved in the interrupt controller or virtual interrupt controller, lowers software design difficulty, significantly improves communication response speed, and optimizes real-time performance. Through software design, priority binding between VMs and shared memory domains allows for privileged priority communication settings for VMs with different high real-time requirements, further optimizing real-time performance. Attached Figure Description

[0034] Figure 1 This is a flowchart of the real-time inter-virtual machine communication method supporting priority according to the present invention;

[0035] Figure 2 This is a schematic diagram of the multi-priority memory domain of the present invention. Detailed Implementation

[0036] To make the objectives, contents, and advantages of the present invention clearer, the specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples.

[0037] The software design scheme of this invention is based on the characteristics of a general virtual machine manager, and utilizes the hardware inter-core interrupt mechanism and shared memory mechanism to design a priority-supporting, high-real-time inter-virtual machine communication method.

[0038] While improving real-time performance, this invention also sets priority privileges for inter-virtual machine communication for different virtual machines. Messages are stored in a shared memory domain with priority attributes according to the priority privileges of the communication target machine. When concurrent communication between virtual machines occurs, data from higher-priority virtual machines is processed first.

[0039] like Figure 1 As shown, the priority-supported real-time inter-virtual machine communication method of the present invention includes the following steps:

[0040] S01, [Start] Virtual machine core binding startup, each virtual machine is assigned a configuration file, including: the core paired with each virtual machine, the priority of each virtual machine and the message memory domain address information;

[0041] Each virtual machine corresponds to one or more cores;

[0042] Each virtual machine corresponds to a priority, and each priority corresponds to a message memory domain address;

[0043] S02, The application of the sending virtual machine requests virtual machine communication;

[0044] S03. The application of the sending virtual machine writes data into the sending buffer, and the data includes the target virtual machine information.

[0045] S04. The sending virtual machine stores the data in the sending buffer into the message memory field corresponding to the target virtual machine via the virtual machine manager.

[0046] S05, The sending virtual machine then handles the inter-core interrupt distribution through the virtual machine manager;

[0047] Specifically, the virtual machine manager distributes an inter-core interrupt to the core bound to the target virtual machine. If multiple cores are bound at the same time, the interrupt is distributed to any one of them.

[0048] S06, The sending virtual machine triggers an inter-core interrupt;

[0049] The virtual machine manager is responsible for obtaining information between the two virtual machines that are communicating via inter-core interrupts, determining which virtual machine is the sender and the core to which the sender virtual machine is located, and which virtual machine is the receiver and the core to which the receiver virtual machine is located. Then, based on the statistical information, it calls the function interface for managing inter-core interrupts.

[0050] S07. The sending virtual machine returns the task and continues to execute the task;

[0051] S08. The interrupt service routine checks the cumulative number of messages in the message memory field corresponding to each priority level. In a certain embodiment, three priorities, 0-2, are used. The number is recorded in msg_pri0_count~msg_pri2_count. It checks whether there are messages in the message memory field corresponding to each priority level and processes the operating system message memory field with higher priority first.

[0052] Among them, msg_pri0_count is a member of the structure structmsg_status, which describes the memory fields that store messages with priority. It is used to describe the cumulative number of messages in the memory field with priority 0. Similarly, msg_pri2_count is used to describe the cumulative number of messages in the memory field with priority 2.

[0053] S09. The interrupt service routine reads the message from the corresponding operating system message memory domain into the target virtual machine's receive buffer.

[0054] S10, The receiving virtual machine application retrieves the data from the receive buffer in the message memory field.

[0055] like Figure 2 The memory distribution shown is divided into two parts:

[0056] One is a structure `struct msg_status` used to store descriptions of message memory domains. This structure is stored in a specific structure memory area and managed separately from the message memory domains. This structure manages the addresses of message memory domains with different priorities and the cumulative number of messages in each priority memory domain. `msg_pri0_count` indicates the number of messages with priority 0 (a memory domain with priority 0 may correspond to one or more virtual machine operating systems). When a message in this memory domain experiences a storage event (i.e., a virtual machine communication event), `msg_pri0_count` is incremented by 1. When an interrupt response event occurs and a message is retrieved, `msg_pri0_count` is decremented by 1. Each time an interrupt is handled, the system first checks if the higher-priority `count` has data and retrieves data from the higher-priority message memory domain first. Similarly, `msg_pri1_count` indicates the number of messages with priority 1, and `msg_pri2_count` indicates the number of messages with priority 2.

[0057] Another is the memory starting address of the message memory field for each priority. For example, msg_pri0_addr is the memory starting address of the message memory field for priority 0. According to user needs, a memory space is allocated for virtual machine messages of each priority, and N consecutive memory spaces of the same size are allocated (which can be customized according to user needs). N is the number of priorities. Within a specific priority message memory field, message management of that priority message memory field is carried out using methods including but not limited to circular queues, circular linked lists, etc.

[0058] The virtual machine communication method of this invention fully combines hardware and software characteristics, optimizes real-time performance, and enhances virtual machine priority features. This invention has the following key features:

[0059] 1. Virtual machines are bound to cores and inter-core interrupt technology is used to reduce overhead, improve efficiency, and enhance real-time performance;

[0060] 2. A memory management method that supports virtual machine communication priority;

[0061] This invention provides a priority-based real-time communication method between virtual machines, offering a more efficient and real-time solution for virtualization platforms and meeting the high real-time requirements of embedded applications. This invention leverages hardware characteristics by binding virtual machines to cores and incorporating an inter-core interrupt mechanism. This reduces the overhead of the virtual machine manager allocating and switching cores for virtual machines. The inter-core interrupt mechanism reduces the complexity of inter-virtual machine communication, decreases the multi-level context switching overhead involved in the interrupt controller or virtual interrupt controller, lowers software design difficulty, significantly improves communication speed, and enhances real-time performance. Through software design, priority binding between virtual machines and shared memory domains allows for privileged priority communication settings for virtual machines with different high real-time requirements, further optimizing real-time performance.

[0062] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A real-time inter-virtual machine communication method supporting priority, characterized in that, The method includes the following steps: S01. Virtual machine core binding startup: Each virtual machine is assigned a configuration file, including: the core paired with each virtual machine, the priority of each virtual machine and the message memory domain address information; S02, The application of the sending virtual machine requests virtual machine communication; S03. The application of the sending virtual machine writes data into the sending buffer, and the data includes the target virtual machine information. S04. The sending virtual machine stores the data in the sending buffer into the message memory field corresponding to the target virtual machine via the virtual machine manager. S05, The sending virtual machine then handles the inter-core interrupt distribution through the virtual machine manager; S06, The sending virtual machine triggers an inter-core interrupt; S07. The sending virtual machine returns the task and continues to execute the task; S08. The interrupt service routine checks the cumulative number of messages in the message memory field corresponding to each priority level, determines whether there are messages in the message memory field corresponding to each priority level, and prioritizes processing the operating system message memory field with higher priority. S09. The interrupt service routine reads the message from the corresponding operating system message memory domain into the target virtual machine's receive buffer. S10, The receiving virtual machine application retrieves the data from the receive buffer in the message memory field.

2. The real-time inter-virtual machine communication method supporting priority as described in claim 1, characterized in that, In step S01, each virtual machine corresponds to one or more cores.

3. The real-time inter-virtual machine communication method supporting priority as described in claim 1, characterized in that, In step S01, each virtual machine corresponds to a priority, and each priority corresponds to a message memory domain address.

4. The real-time inter-virtual machine communication method supporting priority as described in claim 1, characterized in that, In step S05, the virtual machine manager distributes an inter-core interrupt to the core bound to the target virtual machine. If multiple cores are bound at the same time, the interrupt is distributed to any one of them.

5. The real-time inter-virtual machine communication method supporting priority as described in claim 4, characterized in that, In step S06, the virtual machine manager is responsible for obtaining information between the two virtual machines that are communicating via inter-core interrupt, identifying which virtual machine is the sender and the core corresponding to the sending virtual machine, identifying which virtual machine is the receiver and the core corresponding to the receiving virtual machine, and then calling the function interface for managing inter-core interrupts based on the statistical information.

6. The real-time inter-virtual machine communication method supporting priority as described in any one of claims 1-5, characterized in that, The memory is divided into a structure memory area and a message memory area. The structure memory area is used to store the structure structmsg_status that describes the message memory area. The structure memory area and the message memory area are managed separately.

7. The real-time inter-virtual machine communication method supporting priority as described in claim 6, characterized in that, The structure structmsg_status manages the addresses of message memory fields with different priorities and the cumulative number of messages in the message memory field under that priority. In step S08, it is determined whether there are any messages in the message memory field based on the cumulative number of messages managed by the structure structmsg_status.

8. The real-time inter-virtual machine communication method supporting priority as described in claim 7, characterized in that, msg_pri0_count indicates the number of messages with priority 0. When a storage event occurs in the message's memory field, i.e., a virtual machine communication event occurs, msg_pri0_count is incremented by 1. When an interrupt response event occurs and the message is retrieved, msg_pri0_count is decremented by 1. Each time an interrupt is handled, the system first checks if there is data in the higher priority count and then retrieves the data from the higher priority message's memory field.

9. The real-time inter-virtual machine communication method supporting priority as described in claim 6, characterized in that, The message memory domain allocates a fixed segment of memory space for virtual machine messages of various priorities according to user needs, and allocates N consecutive segments of memory space of the same size, where N is the number of priorities.

10. The real-time inter-virtual machine communication method supporting priority as described in claim 9, characterized in that, Within a specific priority message memory domain, a circular queue or circular linked list is used for message management of that priority message memory domain.

Citation Information

Patent Citations

  • Resource monitoring method and system for multi-core processor based on virtual machine

    CN101403983A

  • Method for process communication among multiple virtual machines on multi-core platform based on shared memory and intercore interruption

    CN102693162A