Virtual machine communication method and device, equipment and storage medium
By creating an independent communication queue in the NVMe controller, direct communication between virtual machines is achieved, and the problems of low and high cost of virtual machines are solved, which improves communication efficiency and reduces development and maintenance costs.
Patent Information
- Application Number
- CN202510687857.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-27
- Publication Date
- 2025-08-26
AI Technical Summary
In the prior art, virtual machines have low communication efficiency and high development and maintenance costs, especially in the fact that the communication paths relying on virtual network interfaces and virtual switches are long and the delays are large, and the shared memory communication scheme has the problem of implementation complexity and compatibility.
By creating an independent target communication queue in the NVMe controller, direct communication between virtual machines is achieved using the shared memory function of the NVMe controller, reducing data transmission latency, and relying on the NVMe controller for communication without additional device simulation or complex software management.
It improves the communication efficiency of virtual machines, reduces development and maintenance costs, reduces communication delay and CPU overhead, and enhances the system's concurrent processing capabilities and communication security.
Smart Images

Figure CN120540783A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of virtualization and storage systems, and in particular to a virtual machine communication method, device, equipment and storage medium. Background Art
[0002] With the advancement of cloud computing and virtualization technologies, running multiple virtual machines (VMs) on a single physical host has become a common deployment model. In this environment, physical NVMe (NVM Express) controllers implement virtualization through physical functions (PFs) and virtual functions (VFs), allowing multiple VMs or hosts to share the same NVMe device. PFs manage device resources and create virtual functions (VFs), which can be assigned to VMs to improve performance. Traditional virtual machine communication relies primarily on virtual network interfaces (VNIs) and virtual switches. Data must be encapsulated, transmitted, and parsed through network protocol stacks (such as TCP / IP). This results in long communication paths and high latency. The computational overhead of the VSN and network protocol stack significantly reduces communication efficiency. Furthermore, some virtualization solutions utilize shared memory communication methods (such as shared memory regions within the virtualization layer). These solutions require additional device emulation or complex software management, resulting in implementation complexity and compatibility issues. Furthermore, the isolation and synchronization mechanisms for shared memory require additional logic support, increasing development and maintenance costs.
[0003] It can be seen that how to improve the communication efficiency between virtual machines and reduce the development and maintenance costs of virtual machine communication is a problem that those skilled in the art need to solve. Summary of the Invention
[0004] The purpose of the embodiments of the present invention is to provide a virtual machine communication method, apparatus, device, and storage medium that can improve the efficiency of communication between virtual machines and reduce the development and maintenance costs of virtual machine communication. The specific solution is as follows:
[0005] In a first aspect, the present application discloses a virtual machine communication method, applied to a first virtual machine, comprising:
[0006] Send a communication initialization command to the NVMe controller based on the preset virtual function;
[0007] Obtain a target communication address sent by the NVMe controller based on a communication initialization command; the target communication address is an address of a target communication queue for communication between the first virtual machine and the second virtual machine;
[0008] The target message data is written into the target communication queue based on the target communication address, and the data update identifier corresponding to the target communication queue is updated so that the second virtual machine reads the target message data from the target communication queue based on the updated data update identifier.
[0009] Optionally, a communication initialization command is sent to the NVMe controller based on a preset virtual function, including:
[0010] Generate a communication initialization command based on the local first virtual machine identifier, the second virtual machine identifier of the second virtual machine, and the target queue size of the target communication queue;
[0011] A communication initialization command is sent to the NVMe controller so that the NVMe controller allocates a target communication queue for communication for the first virtual machine and the second virtual machine based on the communication initialization command.
[0012] Optionally, the target communication queue is located in a memory controller of the NVMe controller; the target communication queue includes a message storage area and a read / write pointer, as well as a doorbell register.
[0013] Optionally, after the NVMe controller allocates a target communication queue for communication to the first virtual machine and the second virtual machine based on the communication initialization command, the method further includes:
[0014] The NVMe controller records the queue information of the target communication queue and uses a preset address space mapping tool to map the communication address in the queue information to a preset virtual machine address space so that the first virtual machine and the second virtual machine can access the communication address based on the communication address mapped to the preset virtual machine address space.
[0015] Optionally, after writing the target message data into the target communication queue based on the target communication address and updating the data update identifier corresponding to the target communication queue so that the second virtual machine reads the target message data from the target communication queue based on the updated data update identifier, the method further includes:
[0016] A communication termination command is sent to the NVMe controller so that the NVMe controller reclaims the target communication queue based on the termination command, and uses the preset address space mapping tool to unmap the communication address corresponding to the target communication queue, and releases the preset virtual machine address space.
[0017] Optionally, writing the target message data into the target communication queue based on the target communication address, and updating the data update identifier corresponding to the target communication queue so that the second virtual machine reads the target message data from the target communication queue based on the updated data update identifier, includes:
[0018] Processing the communication data based on a preset data fixed format to obtain target message data corresponding to the communication data;
[0019] The preset data fixed format is a data transmission format in which the message header contains metadata of the data to be communicated and the message body contains the actual data content of the data to be communicated;
[0020] Based on the target communication address, the target message data is written into the message storage area of the target communication queue by using a preset virtual function;
[0021] Performing a message update operation based on a data write pointer and a doorbell register corresponding to the target communication queue to obtain queue data update information, so that the second virtual machine reads the target message data from the message storage area of the target communication queue based on the queue data update information;
[0022] The message update operation is to update the data write pointer corresponding to the target communication queue and control the doorbell register to trigger the notification operation;
[0023] The queue data update information is update information of a data write pointer obtained by the second virtual machine through a polling operation, and / or notification information corresponding to a notification operation triggered by a doorbell register.
[0024] Optionally, after the second virtual machine reads the target message data from the target communication queue based on the updated data update identifier, the method further includes:
[0025] If the updated information of the data write pointer is obtained through the polling operation, and / or the notification information corresponding to the doorbell register triggers the notification operation, the corresponding feedback data written by the second virtual machine for the target message data is read from the message storage area of the target communication queue using the preset virtual function.
[0026] In a second aspect, the present application discloses a virtual machine communication device, applied to a first virtual machine, comprising:
[0027] A command sending module, configured to send a communication initialization command to the NVMe controller based on a preset virtual function;
[0028] An address acquisition module is used to obtain a target communication address sent by the NVMe controller based on a communication initialization command; the target communication address is an address of a target communication queue for communication between the first virtual machine and the second virtual machine;
[0029] The data sending module is used to write the target message data into the target communication queue based on the target communication address, and update the data update identifier corresponding to the target communication queue so that the second virtual machine reads the target message data from the target communication queue based on the updated data update identifier.
[0030] In a third aspect, the present application discloses an electronic device, comprising:
[0031] Memory, used to store computer programs;
[0032] A processor is used to execute a computer program to implement the aforementioned virtual machine communication method.
[0033] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program, which implements the aforementioned virtual machine communication method when executed by a processor.
[0034] It can be seen that in the present invention, a communication initialization command is sent to the NVMe controller based on a preset virtual function; a target communication address sent by the NVMe controller based on the communication initialization command is obtained; the target communication address is the address of the target communication queue for communication between the first virtual machine and the second virtual machine; the target message data is written into the target communication queue based on the target communication address, and the data update identifier corresponding to the target communication queue is updated so that the second virtual machine can read the target message data from the target communication queue based on the updated data update identifier. That is, by creating a corresponding target communication queue in the NVMe controller, communication between virtual machines can be completed by directly accessing the NVMe controller, thereby reducing the delay in data transmission and improving the efficiency of virtual machine communication. Moreover, virtual machine communication can be carried out by relying solely on the NVMe controller without the need for additional device simulation or complex software management, thereby reducing the development and maintenance costs of virtual machine communication. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0036] Figure 1 A diagram of a traditional multi-virtual machine communication architecture disclosed in the present invention;
[0037] Figure 2 This is a flow chart of a virtual machine communication method disclosed in the present invention;
[0038] Figure 3 This is a diagram of a multi-virtual machine communication architecture disclosed in the present invention;
[0039] Figure 4 This is a schematic diagram of CMB area division disclosed in the present invention;
[0040] Figure 5 A schematic diagram of a data format for data transmission between virtual machines disclosed in the present invention;
[0041] Figure 6 This is a schematic diagram of the basic structure of a doorbell register disclosed in the present invention;
[0042] Figure 7 This is a schematic diagram of the NVMe protocol disclosed in the present invention;
[0043] Figure 8 This is a flow chart of a specific virtual machine communication method disclosed in the present invention;
[0044] Figure 9 This is a structural diagram of a virtual machine communication device disclosed in the present invention;
[0045] Figure 10 This is a structural diagram of an electronic device disclosed in the present invention. DETAILED DESCRIPTION
[0046] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present invention.
[0047] The terms "including" and "having," as used in the present description and accompanying drawings, and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or elements is not limited to the listed steps or elements and may include steps or elements that are not listed.
[0048] In order to enable those skilled in the art to better understand the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0049] like Figure 1 As shown in the traditional multi-VM communication architecture diagram, inter-VM communication can be achieved through virtual switches and virtual network cards, while inter-host communication relies on virtual network architectures, such as distributed virtual switches and encapsulation technologies, to optimize data transmission efficiency and security. However, current VM communication suffers from low communication efficiency and high development and maintenance costs. Therefore, this paper specifically introduces a VM communication method that can address these issues.
[0050] See also Figure 2 As shown, the embodiment of the present application discloses a virtual machine communication method, which is applied to a first virtual machine, including:
[0051] Step S11: Send a communication initialization command to the NVMe controller based on the preset virtual function.
[0052] In this embodiment, sending a communication initialization command to an NVMe controller based on a preset virtual function includes: generating a communication initialization command based on a local first virtual machine identifier, a second virtual machine identifier of a second virtual machine, and a target queue size of a target communication queue; and sending the communication initialization command to the NVMe controller, so that the NVMe controller allocates target communication queues for the first and second virtual machines based on the communication initialization command. Specifically, a virtual machine sends a communication initialization command to the NVMe controller through its corresponding preset virtual function (NVMe VF), specifying its own first virtual machine identifier, the second virtual machine identifier of the second virtual machine, and the desired communication queue size. After receiving the corresponding communication initialization command, the NVMe controller allocates independent communication queues for the first and second virtual machines. It should be noted that each virtual machine accesses the NVMe controller through its corresponding preset virtual function.
[0053] Furthermore, after the NVMe controller allocates a target communication queue for communication between the first and second virtual machines based on the communication initialization command, the NVMe controller further includes: recording queue information of the target communication queue and mapping the communication address in the queue information to the preset virtual machine address space using a preset address space mapping tool, so that the first and second virtual machines can access the communication address mapped to the preset virtual machine address space. Specifically, after the NVMe controller allocates an independent communication queue to the virtual machine pair, it records the queue information of the communication queue, where the queue information includes the queue starting address and size of the communication queue, and the read and write pointer status of the queue. Furthermore, the NVMe controller maps the queue address to the virtual machine address space using a preset address space mapping tool (PCIe BAR (Peripheral Component Interconnect Express Base Address Register), allowing the first and second virtual machines to directly access the CMB (Controller Memory Buffer), so that the first and second virtual machines can access the CMB based on the communication address mapped to the preset virtual machine address space. In a virtualized environment, NVMe SR-IOV (Single Root I / O Virtualization), a hardware-based virtualization technology, allows multiple virtual machines to share the resources of the same NVMe controller. Each VF directly accesses the shared area allocated in the CMB through the BAR (Base Address Register) of the NVMe protocol.
[0054] In general, the NVMe controller allocates an independent communication queue for each pair of virtual machines. This ensures data isolation, and the read and write pointers and doorbell registers of each queue are managed independently; multiple virtual machines can transmit data through their respective communication queues at the same time.
[0055] It should be noted that the target communication queue is located in the memory controller of the NVMe controller; the target communication queue contains the message storage area and read / write pointers, as well as the doorbell register. Figure 3 The architecture diagram of NVMe CMB multi-virtual machine communication is shown in the figure. Among them, CMB is a directly accessible memory buffer provided by the NVMe controller, which supports zero-copy data transmission between host memory and device memory. Therefore, the present invention utilizes the sharing characteristics of CMB and uses it as a shared memory buffer between virtual machines (or hosts) to support direct communication. Among them, the CMB area is divided as follows Figure 4 As shown, the CMB is divided into multiple logical areas, each area is assigned to a different virtual machine or master, and a dedicated communication area is defined for storing communication messages or data. Specifically, it includes: a read-write cache area, which is used to store read and write data buffers for traditional I / O operations, retaining the NVMe standard function; a communication area, which is allocated for data exchange between virtual machines, supporting message passing and direct data sharing; a control information area, which is used to store communication management information (such as queue pointers, metadata, status flags, etc.) to ensure synchronization and coordination of communication; a reserved area for future expansion or other dedicated purposes defined by the manufacturer. Among them, the communication area is the core part of the shared memory between virtual machines, used to store messages and data. Specifically, it includes:
[0056] (1) Virtual machine communication queue: An independent queue is allocated for each pair of communicating virtual machines. Each queue contains message storage and pointer information (such as write pointer and read pointer).
[0057] (2) Global status area: includes global metadata (such as the current usage of the communication area, virtual machine ID mapping table, etc.), which is shared and accessed by all virtual machines.
[0058] (3) Metadata area: stores metadata information of each communication queue (such as message type, message length, target virtual machine ID, etc.).
[0059] From the above, we can see that before the virtual machine requests communication resources, the NVMe controller will first divide the CMB into a communication area (storing communication queues between virtual machines), a control information area (storing queue metadata, such as read and write pointers, queue status, etc.), and a read and write cache area (retaining the traditional storage cache function of the NVMe controller); after obtaining the communication resource request of the virtual machine, an independent communication queue is allocated to each pair of virtual machines. The queue contains a message storage area, read and write pointers, and a status flag; each communication queue is allocated a doorbell register to notify the recipient to process new messages. The doorbell register contains a queue ID (identity document), write pointer, read pointer, and notification flag.
[0060] Step S12: Obtain the target communication address sent by the NVMe controller based on the communication initialization command; the target communication address is the address of the target communication queue for communication between the first virtual machine and the second virtual machine.
[0061] In this embodiment, after the NVMe controller allocates a target communication queue for communication to the first virtual machine and the second virtual machine based on the communication initialization command, it sends the target communication address corresponding to the target communication queue to the first virtual machine.
[0062] Step S13: writing the target message data into the target communication queue based on the target communication address, and updating the data update identifier corresponding to the target communication queue, so that the second virtual machine reads the target message data from the target communication queue based on the updated data update identifier.
[0063] In this embodiment, target message data is written into a target communication queue based on a target communication address, and a data update identifier corresponding to the target communication queue is updated so that the second virtual machine can read the target message data from the target communication queue based on the updated data update identifier, including: processing the communication data based on a preset data fixed format to obtain the target message data corresponding to the communication data; the preset data fixed format is a data transmission format in which a message header contains metadata of the communication data and a message body contains actual data content of the communication data; based on the target communication address, and using a preset virtual function, the target message data is written into a message storage area of the target communication queue; a message update operation is performed based on a data write pointer and a doorbell register corresponding to the target communication queue to obtain queue data update information, so that the second virtual machine can read the target message data from the message storage area of the target communication queue based on the queue data update information; the message update operation is to update the data write pointer corresponding to the target communication queue and control the doorbell register to trigger a notification operation; wherein, the queue data update information is the update information of the data write pointer obtained by the second virtual machine through a polling operation, and / or the notification information corresponding to the notification operation triggered by the doorbell register.
[0064] That is, the data to be communicated is written into the message storage area of the communication queue through NVMe VF in a preset fixed format (message header: contains metadata such as target virtual machine ID, message type, message length, etc., message body: actual data content). Figure 5 As shown, the data format for data transmission between virtual machines is as follows:
[0065] Header: includes information such as message type, length, local first virtual machine identifier, and second virtual machine identifier of the second virtual machine.
[0066] Payload: stores specific data content.
[0067] In this embodiment, after the data is written, the write pointer of the queue is updated, and the doorbell register is updated to trigger the NVMe controller to notify the second virtual machine that there is a new message. The second virtual machine detects whether there is a new message by two methods: interrupt (the NVMe controller triggers an interrupt through the doorbell register to notify the receiver) and polling (the second virtual machine periodically checks whether there is a difference between the write pointer and the read pointer of the queue). The receiver reads data from the message storage area of the queue according to the read pointer of the queue. After the reading is completed, the second virtual machine updates the read pointer and notifies the NVMe controller of the queue status change. It should be noted here that the present invention uses the producer-consumer model to manage the communication area of CMB, and each pair of virtual machines maintains a write pointer and a read pointer. When writing data, the write pointer is updated; when reading data, the read pointer is updated. At the same time, a synchronization mechanism is defined to ensure the read and write consistency between multiple virtual machines. Through the doorbell register of CMB, the target virtual machine is notified that new data has arrived; or the polling mechanism is used to periodically check the status of the communication area. Among them, the basic structure of the doorbell register is as follows Figure 6 As shown in FIG, hardware-level notification is implemented through the doorbell register. This utilizes the hardware-level notification mechanism to avoid the performance waste caused by the traditional polling method and significantly reduces the communication delay.
[0068] In this embodiment, after the second virtual machine reads the target message data from the target communication queue based on the updated data update identifier, it also includes: if the update information of the data write pointer is obtained through the polling operation, and / or the notification information corresponding to the doorbell register triggers the notification operation, then the corresponding feedback data written by the second virtual machine for the target message data is read from the message storage area of the target communication queue using the preset virtual function. Consistent with the above-mentioned operation process, the first virtual machine detects whether there is a new message through interruption and polling. The first virtual machine reads the feedback data from the message storage area of the communication queue according to the read pointer of the queue. After the reading is completed, the receiver updates the read pointer and notifies the NVMe controller of the queue status change.
[0069] In this embodiment, after writing the target message data into the target communication queue based on the target communication address and updating the data update identifier corresponding to the target communication queue so that the second virtual machine can read the target message data from the target communication queue based on the updated data update identifier, the method further includes: sending a communication termination command to the NVMe controller so that the NVMe controller reclaims the target communication queue based on the termination command, and uses a preset address space mapping tool to unmap the communication address corresponding to the target communication queue, and releases the preset virtual machine address space. That is, the first virtual machine sends a communication termination command to request the release of the communication queue, the NVMe controller reclaims the memory of the queue, and updates the global metadata. The NVMe controller reclaims the communication queue and unmaps the PCIe BAR address of the virtual machine, releasing the local address space.
[0070] During the entire data operation process, the NVMe controller maintains the communication queue status in real time (for example, whether it overflows, whether there are unread messages), and performs corresponding exception handling: queue overflow (the second virtual machine accelerates reading to release queue space), data corruption (the second virtual machine feedback error, the first virtual machine retransmits), doorbell exception (switches to polling mode to ensure message reading). In addition, when a queue overflow occurs, the queue length of the communication queue can be temporarily expanded. After the data pressure in the queue decreases, the queue length used for expansion will be retracted. To prevent data corruption, the data can be verified before data transmission. After the data verification passes, the first virtual machine is allowed to write data to the communication queue.
[0071] In this way, the robustness of the system can be guaranteed, ensuring that it can maintain stable operation under various abnormal conditions. And combining the above operation process, such as Figure 7 As shown, in order to support communication between multiple virtual machines, the present invention extends the NVMe protocol as follows for initialization of communication areas, data transmission, and queue management.
[0072] It can be seen that in this embodiment, a communication initialization command is sent to the NVMe controller based on the preset virtual function; the target communication address sent by the NVMe controller based on the communication initialization command is obtained; the target communication address is the address of the target communication queue for communication between the first virtual machine and the second virtual machine; the target message data is written into the target communication queue based on the target communication address, and the data update identifier corresponding to the target communication queue is updated so that the second virtual machine can read the target message data from the target communication queue based on the updated data update identifier. That is, the shared memory function of the NVMe controller is used to realize point-to-point data exchange, reduce communication delay and CPU overhead, and improve the overall performance in the virtualization environment. In other words, by creating a corresponding target communication queue in the NVMe controller, communication between virtual machines can be completed by directly accessing the NVMe controller, thereby reducing the delay in data transmission and improving the efficiency of virtual machine communication. Moreover, virtual machine communication can be carried out by relying solely on the NVMe controller without the need for additional device simulation or complex software management, thereby reducing the development and maintenance costs of virtual machine communication.
[0073] refer to Figure 8 As shown, the embodiment of the present application discloses a virtual machine communication method based on the entire communication system as a whole, including:
[0074] Before communication begins, the NVMe CMB's communication area is initialized. Specifically, the NVMe controller divides the CMB into a communication area, a control information area, and a read / write cache area. When virtual machine communication subsequently occurs, an independent communication queue is allocated for each pair of virtual machines. The communication queue contains a message storage area, a read / write pointer, and a status flag. Each communication queue is assigned a doorbell register, which notifies the receiving party to process new messages. The doorbell register contains a queue ID, a write pointer, a read pointer, and a notification flag. When communicating, the two virtual machines in virtual machine communication first send a communication initialization command through a preset virtual function. The communication initialization command includes the virtual machine's own identifier, the target virtual machine's identifier, and the required communication queue size. After receiving the communication initialization command, the NVMe controller allocates an independent communication queue for the virtual machine pair, records the communication queue's starting address and size, and the read / write pointer status of the communication queue. It then maps the queue address to the virtual machine address space via the PCIe BAR, allowing direct access to the CMB.
[0075] During virtual machine communication, the first virtual machine (the sending virtual machine) writes the message to be sent to the message storage area of the communication queue via the NVMe VF in a fixed format (message header: contains metadata such as the target virtual machine ID, message type, and message length; message body: the actual data content). After writing, the queue's write pointer is updated, and the doorbell register is updated to trigger the NVMe controller, notifying the receiver of the new message. The second virtual machine (the sending virtual machine) detects new messages through two methods: interrupts (the NVMe controller triggers an interrupt through the doorbell register to notify the receiver) and polling (the receiver periodically checks the queue's write and read pointers for discrepancies). The receiver reads data from the queue's message storage area based on the queue's read pointer. After reading, the receiver updates the read pointer and notifies the NVMe controller of the queue status change.
[0076] After the virtual machine communication is completed, the virtual machine sends a communication termination command to request the release of the communication queue. The NVMe controller reclaims the memory of the queue and updates the global metadata. The NVMe controller reclaims the communication queue and releases the PCIe BAR address mapping of the virtual machine to release the local address space.
[0077] During the entire communication process, multiple virtual machines can simultaneously transmit data through their respective communication queues. The NVMe controller triggers corresponding interrupts or notifications based on the doorbell register status to coordinate concurrent access to the queues.
[0078] In summary, this embodiment uses the NVMe controller's CMB as shared memory between virtual machines, divides communication, control, and cache areas, and designs an independent queue structure. This eliminates the need for virtual network interfaces for inter-VM communication, reduces paths and overhead, and reduces latency through zero-copy writes. Furthermore, the independent queue design eliminates resource contention, improving the system's concurrent processing capabilities and communication security.
[0079] refer to Figure 9 , the embodiment of the present application also correspondingly discloses a virtual machine communication device, including:
[0080] A command sending module 11 is configured to send a communication initialization command to the NVMe controller based on a preset virtual function;
[0081] An address acquisition module 12 is configured to acquire a target communication address sent by the NVMe controller based on a communication initialization command; the target communication address is an address of a target communication queue for communication between the first virtual machine and the second virtual machine;
[0082] The data sending module 13 is used to write the target message data into the target communication queue based on the target communication address, and update the data update identifier corresponding to the target communication queue so that the second virtual machine reads the target message data from the target communication queue based on the updated data update identifier.
[0083] It can be seen that in this embodiment, by creating a corresponding target communication queue in the NVMe controller, communication between virtual machines can be completed by directly accessing the NVMe controller, thereby reducing the delay in data transmission and improving the efficiency of virtual machine communication. In addition, virtual machine communication can be carried out only by relying on the NVMe controller without the need for additional device simulation or complex software management, thereby reducing the development and maintenance costs of virtual machine communication.
[0084] Furthermore, the embodiment of the present application also discloses an electronic device, Figure 10 This is a diagram of an electronic device structure according to an exemplary embodiment. The content in the diagram should not be considered as any limitation on the scope of use of this application. The electronic device may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the virtual machine communication method disclosed in any of the aforementioned embodiments. In addition, the electronic device in this embodiment may specifically be an electronic computer.
[0085] In this embodiment, the power supply 23 is used to provide operating voltage for various hardware devices on the electronic device; the communication interface 24 can create a data transmission channel between the electronic device and external devices. The communication protocol it follows is any communication protocol that can be applied to the technical solution of this application and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world. Its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0086] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or CD, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0087] The operating system 221 is used to manage and control the hardware devices on the electronic device and the computer program 222, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of implementing the virtual machine communication method performed by the electronic device disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program capable of implementing other specific tasks.
[0088] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned virtual machine communication method is implemented. The specific steps of this method can be referred to the corresponding contents disclosed in the aforementioned embodiments and will not be repeated here.
[0089] Furthermore, this application also discloses a computer program product, including a computer program / instructions; wherein, when executed by a processor, the computer program / instructions implement the aforementioned disclosed alarm aggregation method. The specific steps of this method can be referred to the corresponding contents disclosed in the aforementioned embodiments and will not be repeated here.
[0090] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from the other embodiments. Reference can be made to the descriptions of the identical or similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and the relevant parts can be referred to the descriptions of the methods.
[0091] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0092] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0093] Finally, it should be noted that, in this document, relational terms such as first and second, etc., 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 "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising 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 "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.
[0094] The above is a detailed introduction to the technical solution provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the ideas of the present application, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A virtual machine communication method, characterized in that: Applied to the first virtual machine, including: Send a communication initialization command to the NVMe controller based on the preset virtual function; Obtain a target communication address sent by the NVMe controller based on the communication initialization command; the target communication address is an address of a target communication queue for communication between the first virtual machine and the second virtual machine; The target message data is written into the target communication queue based on the target communication address, and the data update identifier corresponding to the target communication queue is updated so that the second virtual machine reads the target message data from the target communication queue based on the updated data update identifier.
2. The virtual machine communication method according to claim 1, wherein: The sending of a communication initialization command to the NVMe controller based on the preset virtual function includes: Generate a communication initialization command based on the local first virtual machine identifier, the second virtual machine identifier of the second virtual machine, and the target queue size of the target communication queue; The communication initialization command is sent to the NVMe controller so that the NVMe controller allocates a target communication queue for communication for the first virtual machine and the second virtual machine based on the communication initialization command.
3. The virtual machine communication method according to claim 2, wherein: The target communication queue is located in the memory controller of the NVMe controller; the target communication queue includes a message storage area and a read-write pointer, as well as a doorbell register.
4. The virtual machine communication method according to claim 2, wherein: After the NVMe controller allocates a target communication queue for communication to the first virtual machine and the second virtual machine based on the communication initialization command, the method further includes: The NVMe controller records the queue information of the target communication queue, and uses a preset address space mapping tool to map the communication address in the queue information to a preset virtual machine address space, so that the first virtual machine and the second virtual machine can access based on the communication address mapped to the preset virtual machine address space.
5. The virtual machine communication method according to claim 4, characterized in that: After writing the target message data into the target communication queue based on the target communication address and updating the data update identifier corresponding to the target communication queue so that the second virtual machine reads the target message data from the target communication queue based on the updated data update identifier, the method further includes: A communication termination command is sent to the NVMe controller so that the NVMe controller recycles the target communication queue based on the termination command, and uses the preset address space mapping tool to unmap the communication address corresponding to the target communication queue, and releases the preset virtual machine address space.
6. The virtual machine communication method according to any one of claims 1 to 5, characterized in that: The step of writing the target message data into the target communication queue based on the target communication address, and updating the data update identifier corresponding to the target communication queue so that the second virtual machine reads the target message data from the target communication queue based on the updated data update identifier, including: Processing the data to be communicated based on a preset data fixed format to obtain target message data corresponding to the data to be communicated; The preset data fixed format is a data transmission format in which a message header includes metadata of the data to be communicated and a message body includes actual data content of the data to be communicated; Based on the target communication address, and using the preset virtual function, the target message data is written into the message storage area of the target communication queue; performing a message update operation based on a data write pointer and a doorbell register corresponding to the target communication queue to obtain queue data update information, so that the second virtual machine reads the target message data from a message storage area of the target communication queue based on the queue data update information; The message update operation is to update the data write pointer corresponding to the target communication queue and control the doorbell register to trigger the notification operation; The queue data update information is update information of the data write pointer obtained by the second virtual machine through a polling operation, and / or notification information corresponding to the doorbell register triggering notification operation.
7. The virtual machine communication method according to claim 6, characterized in that: After the second virtual machine reads the target message data from the target communication queue based on the updated data update identifier, the method further includes: If the update information of the data write pointer is obtained through the polling operation, and / or the notification information corresponding to the doorbell register triggers the notification operation, the preset virtual function is used to read the corresponding feedback data written by the second virtual machine for the target message data from the message storage area of the target communication queue.
8. A virtual machine communication device, characterized in that: Applied to the first virtual machine, including: A command sending module, configured to send a communication initialization command to the NVMe controller based on a preset virtual function; An address acquisition module is configured to acquire a target communication address sent by the NVMe controller based on the communication initialization command; the target communication address is an address of a target communication queue for communication between the first virtual machine and the second virtual machine; The data sending module is used to write the target message data into the target communication queue based on the target communication address, and update the data update identifier corresponding to the target communication queue so that the second virtual machine reads the target message data from the target communication queue based on the updated data update identifier.
9. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to execute the computer program to implement the steps of the virtual machine communication method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the virtual machine communication method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Communication transmission method, product, electronic equipment and medium
CN120848811A
A communication transmission method, product, electronic device, and medium
CN120848811B