A virtual machine communication method, system, device, equipment and storage medium based on RDMA
By using RDMA network cards and memory mapping tables in cloud computing to directly transmit messages between virtual machines, the problem of low virtual machine communication performance and high CPU usage is solved, and efficient and reliable data transmission is achieved.
Patent Information
- Application Number
- CN202410970696.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-19
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-07-19
AI Technical Summary
The communication performance between virtual machines in existing cloud computing is low, time-consuming and prone to packet loss, and the CPU usage is high, affecting system performance.
Adopt an RDMA-based virtual machine communication method to directly transmit messages between the virtual machine and the host through the RDMA network card, bypassing the kernel protocol stack, and using the memory mapping table to store the messages in the sending queue or receiving queue to achieve efficient data transmission.
It shortens the communication time between virtual machines, reduces CPU usage, improves system performance, avoids data packet loss, and improves data transmission efficiency between virtual machines.
Smart Images

Figure CN118509398B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of cloud computing, and in particular to a virtual machine communication method, system, device, equipment and storage medium based on Remote Direct Memory Access (RDMA). Background Art
[0002] In the context of large-scale application of cloud computing, the communication performance between virtual machines in cloud computing has always been a widely concerned issue in the industry. Among them, the communication performance can be reflected in the message reception or message sending between virtual machines.
[0003] There are usually dozens of virtual machines or containers on the existing cloud platform host, and all services are run on virtual machines or containers. Existing virtual machines usually receive or send messages through the communication method of the kernel protocol stack or through the communication method of the network driver component (Intel Data Plane Development Kit, DPDK) bypass. However, the communication method through the kernel protocol stack takes a long time, and there will be packet loss when the message data is large. Although the communication method through the network driver component DPDK bypass can bypass the kernel protocol stack and improve network performance, due to the implementation method of DPDK itself, the system's CPU is always in a polling state, resulting in a high CPU usage rate, which has certain requirements for the cloud platform host. Summary of the invention
[0004] In view of this, the present invention provides a virtual machine communication method, system, device, equipment and storage medium based on RDMA to solve the problem that data transmission between different virtual machines takes a long time or is prone to data loss or the system CPU usage is too high.
[0005] In a first aspect, the present invention provides a virtual machine communication method based on RDMA, which is applied to a first host machine, the first host machine corresponds to a first virtual machine, and the first host machine is configured with a first remote direct data access RDMA network card; the method includes: obtaining a first message from a shared memory resource pool of the first virtual machine, the first message being generated and stored by the first virtual machine; storing the first message in a sending queue of the first RDMA network card through a first memory mapping table, the first memory mapping table being used to indicate that the first message from the shared resource pool is stored in the sending queue; sending the first message to a second RDMA network card configured in a second host machine through the sending queue, the second RDMA network card being used to transmit the first message to a second virtual machine corresponding to the second host machine.
[0006] Based on the method provided in the first aspect above, a first message generated and stored by the first virtual machine can be obtained from the shared memory resource pool of the first virtual machine, and the first message can be stored in a sending queue of the first RDMA network card through a first memory mapping table. The first message can be sent to a second RDMA network card configured for a second host machine through the sending queue, so that the first message is transmitted to a second virtual machine corresponding to the second host machine.
[0007] Since the first host machine is equipped with the first RDMA network card and the second host machine is also equipped with the second RDMA network card, the first virtual machine can communicate with the second virtual machine through the first RDMA network card. Compared with the communication method through the kernel protocol stack or DPDK bypass, this communication method can bypass the kernel protocol stack, shorten the communication time, and avoid data loss during the communication process; it can also reduce the system CPU usage and improve the system performance.
[0008] In an optional implementation, storing the first message in the sending queue of the first RDMA network card through the first memory mapping table includes: determining the first memory address of the first message in the sending queue based on the first memory mapping table and the first shared memory address of the first message in the shared memory resource pool, the first memory mapping table being a correspondence table between the first shared memory address and the first memory address; based on the first memory address, storing the first message in the memory corresponding to the sending queue of the first RDMA network card.
[0009] Based on the above method, the shared memory resource pool (i.e., virtual memory) of the first virtual machine and the memory (i.e., physical memory) of the sending queue of the first RDMA network card can be mapped through the first memory mapping table, so that the first message is directly stored in the sending queue of the first RDMA network card, thereby realizing the transmission of the first message from the first virtual machine to the first RDMA network card.
[0010] In an optional implementation, the first host machine is connected to the physical switch via a first RDMA network card; the second host machine is connected to the physical switch via a second RDMA network card; and the first message is sent to the second RDMA network card configured in the second host machine via a sending queue, including: in response to the first RDMA network card, the first message is converted into a preset format message, and the preset format message is sent to the second RDMA network card via the physical switch via the sending queue.
[0011] Based on the above method, the preset format message can be sent to the second RDMA network card through the sending queue through the physical switch, so that the first message of the first virtual machine is transmitted to the second RDMA network card, which facilitates the subsequent second RDMA network card to send the first message to the second virtual machine.
[0012] In an optional implementation, the method further includes: receiving a response message returned by the first RDMA network card, and releasing a memory corresponding to the sending queue, wherein the response message is used to notify the first virtual machine that the sending of the first message is completed.
[0013] Based on the above method, after the sending queue of the first RDMA network card sends the first message, the response message returned by the first RDMA network card can be received in time, and the first virtual machine can be immediately notified that the sending of the first message is completed. The message can continue to be sent without waiting for the first message to be completely received, thereby improving the sending efficiency.
[0014] In a second aspect, the present invention provides an RDMA-based virtual machine communication method, which is applied to a second host machine, the second host machine corresponds to a second virtual machine; the second host machine is configured with a second remote direct data access RDMA network card; the method includes: receiving a first message from the first host machine through the second RDMA network card, and storing the first message in a receiving queue of the second RDMA network card, the first message being generated and stored by a first virtual machine corresponding to the first host machine; storing the first message in a shared memory resource pool of the second virtual machine through a second memory mapping table, the second memory mapping table being used to indicate that the first message from the receiving queue is stored in the shared memory resource pool of the second virtual machine.
[0015] Based on the method provided in the second aspect above, the first message from the first host machine can be received through the second RDMA network card, and the first message can be stored in the receiving queue of the second RDMA network card, and the first message can be stored in the shared memory resource pool of the second virtual machine through the second memory mapping table.
[0016] Since the first host machine is equipped with the first RDMA network card and the second host machine is also equipped with the second RDMA network card, the second virtual machine can receive the message sent by the first virtual machine through the second RDMA network card and communicate with the first virtual machine. Compared with the communication method through the kernel protocol stack or DPDK bypass, this communication method can bypass the kernel protocol stack, shorten the communication time, and avoid data loss during the communication process; it can also reduce the system CPU usage and improve the system performance.
[0017] In an optional implementation, the first message is stored in the shared memory resource pool of the second virtual machine through a second memory mapping table, including: determining the second shared memory address of the first message in the shared memory resource pool of the second virtual machine based on the second memory mapping table and the second memory address of the first message in the receiving queue, the second memory mapping table being a correspondence table between the second memory address and the second shared memory address; based on the second memory address, storing the first message in the shared memory resource pool of the second R virtual machine.
[0018] Based on the above method, the second memory mapping table can be used to map the shared memory resource pool (i.e., virtual memory) of the second virtual machine to the memory (i.e., physical memory) of the receiving queue of the second RDMA network card, so that the first message is directly stored in the shared memory resource pool of the second virtual machine, thereby realizing the transmission of the first message from the second RDMA network card to the second virtual machine.
[0019] In an optional implementation, after the receiving queue of the second RDMA network card completes receiving, a first message from the second RDMA network card is received, where the first message is used to notify the second virtual machine that the first message has been received.
[0020] Based on the above method, after the receiving queue of the second RDMA network card receives the first message, the first message of the second RDMA network card can be received in time to notify the second virtual machine that the first message is received, and the first message can be stored in the shared memory resource pool of the second virtual machine.
[0021] In a third aspect, the present invention provides a virtual machine communication system based on RDMA, the virtual machine communication system comprising a cloud management platform, at least two host machines, and at least two virtual machines;
[0022] The cloud management platform is used to generate and send a first memory mapping table and a second memory mapping table;
[0023] The at least two host machines include a first host machine; the first host machine is configured with a first remote direct data access (RDMA) network card; the first host machine corresponds to a first virtual machine of the at least two virtual machines;
[0024] The first memory mapping table is a correspondence table between a first shared memory address of a shared memory resource pool of the first virtual machine and a first memory address of a sending queue of the first RDMA network card, and the first memory mapping table is used to indicate that a first message from the shared resource pool is stored in the sending queue;
[0025] The first host machine is used to obtain a first message from a shared memory resource pool of the first virtual machine, where the first message is generated and stored by the first virtual machine; store the first message in a sending queue of the first RDMA network card through a first memory mapping table; and send the first message to the second RDMA network card through the sending queue;
[0026] The at least two hosts include a second host;
[0027] The second host machine is configured with a second RDMA network card; the second host machine corresponds to a second virtual machine of the at least two virtual machines;
[0028] The second memory mapping table is a correspondence table between the second memory address of the receiving queue of the second RDMA network card and the second shared memory address of the shared memory resource pool of the second virtual machine, and the second memory mapping table is used to indicate that the first message from the receiving queue is stored in the shared memory resource pool of the second virtual machine;
[0029] The second host machine is used to receive the first message through the second RDMA network card, and store the first message in the memory corresponding to the receiving queue of the second RDMA network card; through the second memory mapping table, the first message is stored in the shared memory resource pool of the second virtual machine.
[0030] Based on the system provided in the third aspect, the first host machine is configured with a first RDMA network card, and the second host machine is also configured with a second RDMA network card, and efficient data transmission can be performed between at least two virtual machines managed by the cloud management platform in the virtual machine communication system. Compared with the communication method through the kernel protocol stack or DPDK bypass, this communication method can bypass the kernel protocol stack, shorten the communication time, and avoid data loss during the communication process; it can also reduce the system CPU usage and improve the system performance.
[0031] In an optional implementation, the cloud management platform is also used to allocate a corresponding shared memory resource pool for the first virtual machine; send a first command to the first host machine, the first command is used to allocate corresponding memory for the sending queue of the first RDMA network card; establish a correspondence between the first shared memory address of the shared memory resource pool of the first virtual machine and the first memory address of the sending queue of the first RDMA network card, and obtain a first memory mapping table.
[0032] Based on the above system, the cloud management platform can establish a first memory mapping table to facilitate subsequent data transmission between the first virtual machine and the second virtual machine.
[0033] In an optional implementation, the cloud management platform is further used to send a second command, where the second command is used to shut down the first virtual machine and destroy the shared memory resource pool of the first virtual machine and the memory corresponding to the sending queue of the first RDMA network card.
[0034] Based on the above system, the cloud management platform can release or destroy the shared memory resource pool of the first virtual machine and the memory corresponding to the sending queue of the first RDMA network card when the first virtual machine does not need to perform data transmission or the first virtual machine is damaged, thereby avoiding the first virtual machine occupying shared memory resources and the sending queue of the first RDMA network card occupying physical memory.
[0035] In a fourth aspect, the present invention provides an RDMA-based virtual machine communication method device, which is applied to a first host machine, the first host machine corresponds to a first virtual machine, and the first host machine is configured with a first remote direct data access RDMA network card; the device includes: a transceiver module 1, which is used to obtain a first message from a shared memory resource pool of the first virtual machine, and the first message is generated and stored by the first virtual machine; a processing module 1, which is used to store the first message in a sending queue of the first RDMA network card through a first memory mapping table, and the first memory mapping table is used to indicate that the first message from the shared resource pool is stored in the sending queue; the transceiver module 1 is also used to send the first message to a second RDMA network card configured in a second host machine through a sending queue, and the second RDMA network card is used to transmit the first message to a second virtual machine corresponding to the second host machine.
[0036] In a fifth aspect, the present invention provides a virtual machine communication method and device based on RDMA, which is applied to a second host machine, and the second host machine corresponds to a second virtual machine; the second host machine is configured with a second remote direct data access RDMA network card; the device includes: a transceiver module 2, which is used to receive a first message from the first host machine through the second RDMA network card, and store the first message in a receiving queue of the second RDMA network card, and the first message is generated and stored by a first virtual machine corresponding to the first host machine; a processing module 2, which is used to store the first message in a shared memory resource pool of the second virtual machine through a second memory mapping table, and the second memory mapping table is used to indicate that the first message from the receiving queue is stored in the shared memory resource pool of the second virtual machine.
[0037] In a sixth aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer instructions to thereby execute the RDMA-based virtual machine communication method of the above-mentioned first aspect or any corresponding embodiment thereof, or execute the RDMA-based virtual machine communication method of the above-mentioned second aspect or any corresponding embodiment thereof.
[0038] In a seventh aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the RDMA-based virtual machine communication method of the above-mentioned first aspect or any corresponding embodiment thereof, or to execute the RDMA-based virtual machine communication method of the above-mentioned second aspect or any corresponding embodiment thereof.
[0039] In an eighth aspect, the present application also provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the methods described in the above aspects. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0041] Figure 1 is a schematic diagram of a virtualization framework based on virtio driver provided according to this embodiment;
[0042] Figure 2 is a simplified diagram of a DPDK bypass provided according to an embodiment of the present invention;
[0043] Figure 3 is an architecture diagram of a virtual machine communication system based on RDMA provided according to an embodiment of the present invention;
[0044] Figure 4 is a flow chart of a virtual machine communication method based on RDMA according to an embodiment of the present invention;
[0045] Figure 5 is a flowchart of another RDMA-based virtual machine communication method according to an embodiment of the present invention;
[0046] Figure 6 is a schematic diagram of another RDMA-based virtual machine communication method according to an embodiment of the present invention;
[0047] Figure 7 is a structural block diagram of a virtual machine communication device based on RDMA according to an embodiment of the present invention;
[0048] Figure 8 is a structural block diagram of another RDMA-based virtual machine communication device according to an embodiment of the present invention;
[0049] Fig. 9 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0051] As described in the background art, existing virtual machines usually receive or send messages through a communication method of a kernel protocol stack or a communication method of a network driver component bypass.
[0052] Among them, the communication method through the kernel protocol stack is represented by the virtio driver. Figure 1 As shown, Figure 1 It is a schematic diagram of a virtualization framework based on virtio driver provided according to the present embodiment. For virtio driver, it is a semi-virtualized driver. The virtualization framework based on virtio driver is divided into two parts, one part is the driver installed in the virtual machine, called the front-end driver; the other part is the driver installed on the host machine, called the back-end driver. The front-end driver and the back-end driver communicate through the virtio queue, and the virtio queue is the shared memory of the virtual machine and the host machine. The message of the virtual machine is sent to the kernel program through the virtio queue, then passes through the kernel protocol stack, and finally is sent out through the network card. This method takes a long time, and there will be packet loss when the network traffic is large.
[0053] In addition to the above-mentioned communication method through the kernel protocol stack, there is also a communication method through the DPDK bypass. Figure 2 As shown, Figure 2 This is a simplified diagram of the DPDK bypass provided according to an embodiment of the present invention. In this method, the virtual machine passes through the DPDK bypass and then transmits messages through the network card. Although in this method, the message bypasses the kernel protocol stack and improves network performance, due to the implementation method of the DPDK bypass itself, the system's CPU is always in a polling state, resulting in a high CPU usage rate.
[0054] In order to solve the above technical problems, the present invention provides a virtual machine communication method based on RDMA, which is applied to a first host machine, the first host machine corresponds to a first virtual machine, and the first host machine is configured with a first RDMA network card. The method includes: obtaining a first message from a shared memory resource pool of the first virtual machine, the first message is generated and stored by the first virtual machine; storing the first message in a sending queue of the first RDMA network card through a first memory mapping table, the first memory mapping table is used to indicate that the first message from the shared resource pool is stored in the sending queue; sending the first message to a second RDMA network card configured in a second host machine through the sending queue, the second RDMA network card is used to transmit the first message to a second virtual machine corresponding to the second host machine. In this way, the problem of long time consumption or easy data loss or excessive system CPU usage when data is transmitted between different virtual machines can be solved.
[0055] The method provided in the embodiment of the present application can be used in various virtual machine communication systems. Figure 3Taking the architecture diagram of the RDMA-based virtual machine communication system provided by the embodiment of the present invention as an example, the method provided by the embodiment of the present application is described. Figure 3 It is only a schematic diagram and does not constitute a limitation on the applicable scenarios of the technical solution provided in this application.
[0056] like Figure 3 As shown, Figure 3 4 is an architecture diagram of an RDMA-based virtual machine communication system provided according to an embodiment of the present invention. Figure 3 In the embodiment, the RDMA-based virtual machine communication system 300 may include a cloud management platform 301, a first host machine 302, a first virtual machine 303 corresponding to the first host machine 302, a second host machine 304, and a second virtual machine 305 corresponding to the second host machine 304. Optionally, the RDMA-based virtual machine communication system 300 further includes a physical switch 306.
[0057] The cloud management platform in the embodiment of the present invention, for example, the cloud management platform 301, can be any device with computing and communication functions. For example, the cloud management platform is a server, a cloud server, etc. The cloud management platform 301 manages the first host machine 302, the first virtual machine 303, the second host machine 304, and the second virtual machine 305.
[0058] The host machine in the embodiment of the present invention, for example, the first host machine 302 or the second host machine 304, can be any physical host with computing and communication functions. The first host machine 302 is configured with a first RDMA network card. The second host machine 304 is configured with a second RDMA network card.
[0059] Among them, the RDMA network card maintains a queue pair (Queue Pair, QP). QP includes a send queue (SQ) and a receive queue (RQ). The send queue is used to send messages; the receive queue is used to receive messages. Each virtual machine will have a corresponding QP. There is a one-to-one correspondence between QP and virtual machine.
[0060] The virtual machine in the embodiment of the present invention, for example, the first virtual machine 303 or the second virtual machine 305, may be any virtual machine having computing and communication functions.
[0061] The physical switch in the embodiment of the present invention, for example, the physical switch 306, can be used to transmit messages between the first RDMA network card and the second RDMA network card. It can be understood that the physical switch 306 is connected to the first RDMA network card and also connected to the second RDMA network card.
[0062] Figure 3The RDMA-based virtual machine communication system 300 shown is only used as an example and is not used to limit the technical solution of the present application. Those skilled in the art should understand that in the specific implementation process, the RDMA-based virtual machine communication system 300 can also include more virtual machines and host machines, and the number of virtual machines and host machines can also be determined according to specific needs without limitation.
[0063] According to an embodiment of the present invention, an embodiment of a virtual machine communication method based on RDMA is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0064] In this embodiment, a virtual machine communication method based on RDMA is provided, which can be used for the first host machine mentioned above. Figure 4 is a flow chart of a virtual machine communication method based on RDMA according to an embodiment of the present invention, such as Figure 4 As shown, the process includes the following steps:
[0065] S401: Acquire a first message from a shared memory resource pool of a first virtual machine.
[0066] The first message is generated and stored by the first virtual machine.
[0067] S402: Store the first message in a sending queue of the first RDMA network card through a first memory mapping table.
[0068] The first memory mapping table is a correspondence table between the first shared memory address and the first memory address. The first memory mapping table is used to indicate that the first message from the shared resource pool is stored in the sending queue of the first RDMA network card. The first mapping table is also called a mapping translation table (Memory Translate Table, MTT).
[0069] In some optional implementations, the first host machine determines a first memory address of the first message in a sending queue based on a first memory mapping table and a first shared memory address of the first message in a shared memory resource pool; and based on the first memory address, stores the first message in a memory corresponding to the sending queue of the first RDMA network card.
[0070] In one example, the kernel process of the first host machine converts a first message into a first message in a column format (work queue event, wqe), and based on a first memory mapping table and a first shared memory address of the first message in a shared memory resource pool, determines a first memory address of the first message in a sending queue, and sends the first message in a queue format to a memory corresponding to the sending queue.
[0071] S403: Send the first message to the second RDMA network card configured in the second host machine through the sending queue.
[0072] The second RDMA network card is used to transmit the first message to the second virtual machine corresponding to the second host machine.
[0073] In some optional implementations, the first host machine converts the first message into a message in a preset format in response to the first RDMA network card, and sends the message in the preset format to the second RDMA network card through a sending queue and a physical switch.
[0074] Exemplarily, the kernel process of the first host machine converts the first message in the sending queue into a message in the RoceV2 protocol format in response to the first RDMA network card, and sends the preset format message to the second RDMA network card through the sending queue via the physical switch.
[0075] Optionally, after the sending queue of the first RDMA network card completes sending the message in the preset format, the driver of the first RDMA network card returns a response message, the kernel process of the first host machine receives the response message returned by the first RDMA network card, and releases the memory corresponding to the sending queue.
[0076] The response message is used to notify the first virtual machine that the first message has been sent. The response message is a response message in a queue format (complete queue event, cqe).
[0077] Based on the above method S401-S403, the first host machine can obtain the first message generated and stored by the first virtual machine from the shared memory resource pool of the first virtual machine, store the first message in the sending queue of the first RDMA network card through the first memory mapping table, and send the first message to the second RDMA network card configured by the second host machine through the sending queue, so that the first message is transmitted to the second virtual machine corresponding to the second host machine. Since the first host machine is configured with the first RDMA network card and the second host machine is also configured with the second RDMA network card, the first virtual machine can communicate with the second virtual machine through the first RDMA network card. Compared with the communication method through the kernel protocol stack or DPDK bypass, this communication method can bypass the kernel protocol stack, shorten the communication time, and avoid data loss during the communication process; it can also reduce the system CPU usage and improve the system performance.
[0078] In this embodiment, a virtual machine communication method based on RDMA is provided, which can be used Figure 3 A second host machine, the second host machine corresponds to the second virtual machine; the second host machine is configured with a second remote direct data access RDMA network card; Figure 5 FIG. 4 is a flowchart of another RDMA-based virtual machine communication method according to an embodiment of the present invention. Figure 5 As shown, the process includes the following steps:
[0079] S501: Receive a first message from a first host machine through a second RDMA network card, and store the first message in a receiving queue of the second RDMA network card.
[0080] The first message is a message in a preset format.
[0081] In one example, the second host receives a preset format message from the first host through the second RDMA network card receiving queue, converts the preset format message into a first message in a queue format, and stores the first message in the queue format in the receiving queue of the second RDMA network card.
[0082] Optionally, after the receiving queue of the second RDMA network card completes receiving, a first message from the second RDMA network card is received.
[0083] The first message is used to notify the second virtual machine that the first message has been received.
[0084] S502: Store the first message in a shared memory resource pool of the second virtual machine through a second memory mapping table.
[0085] The second memory mapping table is used to indicate that the first message from the receiving queue is stored in the shared memory resource pool of the second virtual machine. The second memory mapping table is a correspondence table between the second memory address and the second shared memory address.
[0086] In some optional embodiments, the second host machine determines the second shared memory address of the first message in the shared memory resource pool of the second virtual machine based on the second memory mapping table and the second memory address of the first message in the receiving queue; and stores the first message in the shared memory resource pool of the second R virtual machine based on the second memory address.
[0087] In one example, the kernel process of the second host machine converts a first message in a queue format into an initial first message, determines a second shared memory address of the first message in a shared memory resource pool of the second virtual machine based on a second memory mapping table and a second memory address; and stores the first message in the shared memory resource pool of the second virtual machine based on the second memory address.
[0088] Based on S501-S502, the second host machine can receive the first message from the first host machine through the second RDMA network card, and store the first message in the receiving queue of the second RDMA network card, and store the first message in the shared memory resource pool of the second virtual machine through the second memory mapping table. Since the first host machine is configured with the first RDMA network card and the second host machine is also configured with the second RDMA network card, the second virtual machine can receive the message sent by the first virtual machine through the second RDMA network card and communicate with the first virtual machine. Compared with the communication method through the kernel protocol stack or DPDK bypass, this communication method can bypass the kernel protocol stack, shorten the communication time, and avoid data loss during the communication process; it can also reduce the system CPU usage and improve the system performance.
[0089] In this embodiment, a virtual machine communication system based on RDMA is provided. The virtual machine communication system includes a cloud management platform, at least two host machines, and at least two virtual machines.
[0090] The cloud management platform is used to generate and send the first memory mapping table and the second memory mapping table.
[0091] The cloud management platform is also used to allocate a corresponding shared memory resource pool for the first virtual machine; send a first command to the first host machine, the first command is used to allocate corresponding memory for the sending queue of the first RDMA network card; establish a correspondence between a first shared memory address of the shared memory resource pool of the first virtual machine and a first memory address of the sending queue of the first RDMA network card, and obtain a first memory mapping table.
[0092] The cloud management platform is also used to send a second command, where the second command is used to shut down the first virtual machine and destroy the shared memory resource pool of the first virtual machine and the memory corresponding to the sending queue of the first RDMA network card.
[0093] It can be understood that for the second virtual machine, the cloud management platform is also used to allocate a corresponding shared memory resource pool for the second virtual machine, allocate corresponding memory for the sending queue of the first RDMA network card, establish a correspondence between the second shared memory address of the shared memory resource pool of the second virtual machine and the second memory address of the receiving queue of the second RDMA network card, and obtain a second memory mapping table; it is also used to shut down the second virtual machine and destroy the memory corresponding to the shared memory resource pool of the second virtual machine and the receiving queue of the second RDMA network card.
[0094] Specifically, the cloud management platform deploys a software-defined network cluster. At least two hosts are required in the cluster. The cloud management platform creates a first virtual machine corresponding to the first host and a second virtual machine corresponding to the second host, and allocates corresponding shared memory resource pools to the first virtual machine and the second virtual machine; in response to the user starting the virtual machine, the cloud management platform sends a command to the first host or the second host, starts the kernel process, and performs relevant initialization on the first RDMA network card and the second RDMA network card. Afterwards, the first virtual machine and the second virtual machine send and receive the first message.
[0095] In an embodiment of the present invention, at least two host machines include a first host machine. The first host machine is used to obtain a first message from a shared memory resource pool of a first virtual machine, the first message is generated and stored by the first virtual machine; the first message is stored in a sending queue of a first RDMA network card through a first memory mapping table; and the first message is sent to a second RDMA network card through the sending queue.
[0096] In an embodiment of the present invention, at least two host machines include a second host machine. The second host machine is used to receive the first message through a second RDMA network card, and store the first message in a memory corresponding to a receiving queue of the second RDMA network card; and store the first message in a shared memory resource pool of the second virtual machine through a second memory mapping table.
[0097] like Figure 6 As shown, Figure 6 1 is a schematic diagram of another RDMA-based virtual machine communication method according to an embodiment of the present invention. The RDMA-based virtual machine communication method includes S601-S605.
[0098] S601: A first host machine obtains a first message from a shared memory resource pool of a first virtual machine, where the first message is generated and stored by the first virtual machine.
[0099] S602: The first host machine stores the first message in the sending queue of the first RDMA network card through the first memory mapping table.
[0100] S603: The first host machine sends the first message to the second RDMA network card configured in the second host machine through the sending queue;
[0101] S604: The second host machine receives the first message from the first host machine through the receiving queue of the second RDMA network card.
[0102] S605: The second host machine stores the first message in the shared memory resource pool of the second virtual machine through the second memory mapping table.
[0103] For details of S601 to S605 above, please refer to Figure 4Steps S401 to S403 of the illustrated embodiment and Figure 5 Steps S501 to S502 of the illustrated embodiment are not described in detail here.
[0104] In this embodiment, a virtual machine communication device based on RDMA is also provided, which is used to implement the above embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0105] This embodiment provides a virtual machine communication device based on RDMA, which is applied to a first host machine, the first host machine corresponds to a first virtual machine, and the first host machine is configured with a first remote direct data access RDMA network card; Figure 7 As shown, Figure 7 1 is a structural block diagram of a virtual machine communication device based on RDMA according to an embodiment of the present invention; the device includes:
[0106] The first transceiver module 701 is used to obtain a first message from a shared memory resource pool of a first virtual machine, where the first message is generated and stored by the first virtual machine.
[0107] A processing module 1 702 is used to store the first message in a sending queue of the first RDMA network card through a first memory mapping table, where the first memory mapping table is used to indicate that the first message from the shared resource pool is stored in the sending queue;
[0108] The transceiver module 1 701 is also used to send the first message to the second RDMA network card configured in the second host machine through the sending queue, and the second RDMA network card is used to transmit the first message to the second virtual machine corresponding to the second host machine.
[0109] In some optional implementations, processing module 1 702 is specifically used to determine the first memory address of the first message in the sending queue based on the first memory mapping table and the first shared memory address of the first message in the shared memory resource pool, wherein the first memory mapping table is a correspondence table between the first shared memory address and the first memory address; processing module 1 702 is also specifically used to store the first message in the memory corresponding to the sending queue of the first RDMA network card based on the first memory address.
[0110] In some optional implementations, the first host machine is connected to the physical switch via the first RDMA network card; the second host machine is connected to the physical switch via the second RDMA network card; the transceiver module 701 is further specifically used to convert the first message into a preset format message in response to the first RDMA network card, and send the preset format message to the second RDMA network card through the physical switch via the sending queue.
[0111] In some optional implementations, the transceiver module 701 is further used to receive a response message returned by the first RDMA network card and release the memory corresponding to the sending queue, and the response message is used to notify the first virtual machine that the sending of the first message is completed.
[0112] This embodiment provides another RDMA-based virtual machine communication device, which is applied to a second host machine, and the second host machine corresponds to a second virtual machine; the second host machine is configured with a second remote direct data access RDMA network card; Figure 8 As shown, Figure 8 1 is a structural block diagram of another RDMA-based virtual machine communication device according to an embodiment of the present invention; the device includes:
[0113] The second transceiver module 801 is used to receive a first message from the first host machine through the second RDMA network card and store the first message in a receiving queue of the second RDMA network card. The first message is generated and stored by a first virtual machine corresponding to the first host machine.
[0114] The second processing module 802 is used to store the first message in the shared memory resource pool of the second virtual machine through the second memory mapping table, and the second memory mapping table is used to indicate that the first message from the receiving queue is stored in the shared memory resource pool of the second virtual machine.
[0115] In some optional embodiments, processing module two 802 is specifically used to determine the second shared memory address of the first message in the shared memory resource pool of the second virtual machine based on the second memory mapping table and the second memory address of the first message in the receiving queue, and the second memory mapping table is a correspondence table between the second memory address and the second shared memory address; processing module two 802 is also specifically used to store the first message in the shared memory resource pool of the second R virtual machine based on the second memory address.
[0116] In some optional implementations, the second transceiver module 801 is further used to receive a first message from the second RDMA network card after the receiving queue of the second RDMA network card completes receiving, and the first message is used to notify the second virtual machine that the first message is received successfully.
[0117] The further functional description of each of the above modules is the same as that of the above corresponding embodiments and will not be repeated here.
[0118] The RDMA-based virtual machine communication device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0119] The embodiment of the present invention also provides a computer device having the above Figure 7 Or the RDMA-based virtual machine communication device shown in 8.
[0120] See also Fig. 9 , Fig. 9 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Fig. 9 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Fig. 9 A processor 10 is taken as an example.
[0121] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0122] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0123] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0124] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0125] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0126] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0127] Part of the present application may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present application through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes but is not limited to source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.
[0128] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A virtual machine communication method based on RDMA, characterized in that: Applied to a first host machine, the first host machine corresponds to a first virtual machine, the first virtual machine is created by a cloud management platform, and the first host machine is configured with a first remote direct data access RDMA network card; the method comprises: Acquire a first message from a shared memory resource pool of the first virtual machine, where the first message is generated and stored by the first virtual machine, and the shared memory resource pool of the first virtual machine is allocated by a cloud management platform; The first message is stored in the sending queue of the first RDMA network card through a first memory mapping table, wherein the first memory mapping table is used to indicate that the first message from the shared memory resource pool of the first virtual machine is stored in the sending queue, and the first memory mapping table is a correspondence table between a first shared memory address of the shared memory resource pool of the first virtual machine established by the cloud management platform and a first memory address of the sending queue of the first RDMA network card, and the memory corresponding to the sending queue is allocated by the cloud management platform; Sending the first message to a second RDMA network card configured in a second host machine through the sending queue, wherein the second RDMA network card is used to transmit the first message to a second virtual machine corresponding to the second host machine; The second host machine is used to receive the first message through the second RDMA network card, and store the first message in the memory corresponding to the receiving queue of the second RDMA network card; and store the first message in the shared memory resource pool of the second virtual machine through the second memory mapping table; The second memory mapping table is a correspondence table between the second memory address of the receiving queue of the second RDMA network card and the second shared memory address of the shared memory resource pool of the second virtual machine. The second memory mapping table is used to indicate that the first message from the receiving queue is stored in the shared memory resource pool of the second virtual machine.
2. The method according to claim 1, characterized in that The step of storing the first message in the sending queue of the first RDMA network card through the first memory mapping table includes: Determine a first memory address of the first message in the sending queue based on the first memory mapping table and a first shared memory address of the first message in the shared memory resource pool, wherein the first memory mapping table is a correspondence table between the first shared memory address and the first memory address; Based on the first memory address, the first message is stored in the memory corresponding to the sending queue of the first RDMA network card.
3. The method according to claim 2, characterized in that The first host machine is connected to the physical switch through the first RDMA network card; the second host machine is connected to the physical switch through the second RDMA network card; The sending of the first message to a second RDMA network card configured in a second host machine through the sending queue includes: In response to the first RDMA network card converting the first message into a message in a preset format, the message in the preset format is sent to the second RDMA network card through the sending queue and the physical switch.
4. The method according to claim 1, characterized in that: The method further comprises: A response message returned by the first RDMA network card is received, and a memory corresponding to the sending queue is released, wherein the response message is used to notify the first virtual machine that the sending of the first message is completed.
5. A virtual machine communication method based on RDMA, characterized in that: Applied to a second host machine, the second host machine corresponds to a second virtual machine; the second virtual machine is created by a cloud management platform; The second host machine is configured with a second remote direct data access (RDMA) network card; the method comprises: Receiving a first message from a first host machine through the second RDMA network card, and storing the first message in a receiving queue of the second RDMA network card, wherein the first message is generated and stored by a first virtual machine corresponding to the first host machine, and a memory corresponding to the receiving queue is allocated by the cloud management platform; The first message is stored in the shared memory resource pool of the second virtual machine through a second memory mapping table, wherein the second memory mapping table is used to indicate that the first message from the receiving queue is stored in the shared memory resource pool of the second virtual machine, and the second memory mapping table is a correspondence table between the second memory address of the receiving queue of the second RDMA network card and the second shared memory address of the shared memory resource pool of the second virtual machine, and the shared memory resource pool of the second virtual machine is allocated by the cloud management platform; Among them, the first host machine is used to obtain a first message from the shared memory resource pool of the first virtual machine; store the first message in the sending queue of the first RDMA network card through a first memory mapping table; send the first message to the second RDMA network card through the sending queue; the first memory mapping table is a correspondence table between the first shared memory address of the shared memory resource pool of the first virtual machine and the first memory address of the sending queue of the first RDMA network card established by the cloud management platform.
6. The method according to claim 5, characterized in that The storing the first message in the shared memory resource pool of the second virtual machine through the second memory mapping table includes: Determine a second shared memory address of the first message in the shared memory resource pool of the second virtual machine based on the second memory mapping table and the second memory address of the first message in the receiving queue, wherein the second memory mapping table is a correspondence table between the second memory address and the second shared memory address; Based on the second memory address, the first message is stored in a shared memory resource pool of the second R virtual machine.
7. The method according to claim 5, characterized in that The method further comprises: After the receiving queue of the second RDMA network card completes receiving, a first message from the second RDMA network card is received, where the first message is used to notify the second virtual machine that the first message has been received.
8. A virtual machine communication system based on RDMA, characterized in that: The virtual machine communication system includes a cloud management platform, at least two host machines, and at least two virtual machines; The cloud management platform is used to generate and send a first memory mapping table and a second memory mapping table; The at least two host machines include a first host machine; The first host machine is configured with a first remote direct data access RDMA network card; the first host machine corresponds to the first virtual machine of the at least two virtual machines; The first memory mapping table is a correspondence table between a first shared memory address of a shared memory resource pool of the first virtual machine and a first memory address of a sending queue of the first RDMA network card, and the first memory mapping table is used to indicate that a first message from the shared memory resource pool is stored in the sending queue; The first host machine is used to obtain a first message from a shared memory resource pool of the first virtual machine, where the first message is generated and stored by the first virtual machine; By using a first memory mapping table, storing the first message in the sending queue of the first RDMA network card; Sending the first message to the second RDMA network card through the sending queue; The at least two host machines include a second host machine; The second host machine is configured with a second RDMA network card; the second host machine corresponds to the second virtual machine of the at least two virtual machines; The second memory mapping table is a correspondence table between the second memory address of the receiving queue of the second RDMA network card and the second shared memory address of the shared memory resource pool of the second virtual machine, and the second memory mapping table is used to indicate that the first message from the receiving queue is stored in the shared memory resource pool of the second virtual machine; The second host machine is used to receive the first message through the second RDMA network card, and store the first message in a memory corresponding to a receiving queue of the second RDMA network card; The first message is stored in the shared memory resource pool of the second virtual machine through the second memory mapping table.
9. The virtual machine communication system according to claim 8, characterized in that: The cloud management platform is also used to allocate a corresponding shared memory resource pool for the first virtual machine; send a first command to the first host machine, the first command is used to allocate corresponding memory for the sending queue of the first RDMA network card; establish a correspondence between the first shared memory address of the shared memory resource pool of the first virtual machine and the first memory address of the sending queue of the first RDMA network card, and obtain the first memory mapping table.
10. The virtual machine communication system according to claim 9, characterized in that: The cloud management platform is also used to send a second command, where the second command is used to shut down the first virtual machine and destroy the shared memory resource pool of the first virtual machine and the memory corresponding to the sending queue of the first RDMA network card.
11. A virtual machine communication device based on RDMA, characterized in that: Applied to a first host machine, the first host machine corresponds to a first virtual machine, the first virtual machine is created by a cloud management platform, and the first host machine is configured with a first remote direct data access RDMA network card; the device comprises: The first transceiver module is used to obtain a first message from a shared memory resource pool of the first virtual machine, where the first message is generated and stored by the first virtual machine, and the shared memory resource pool of the first virtual machine is allocated by a cloud management platform; Processing module 1 is used to store the first message in the sending queue of the first RDMA network card through a first memory mapping table, the first memory mapping table is used to indicate that the first message from the shared memory resource pool of the first virtual machine is stored in the sending queue, the first memory mapping table is a correspondence table between a first shared memory address of the shared memory resource pool of the first virtual machine established by the cloud management platform and a first memory address of the sending queue of the first RDMA network card, and the memory corresponding to the sending queue is allocated by the cloud management platform; The transceiver module 1 is further used to send the first message to a second RDMA network card configured in the second host machine through the sending queue, and the second RDMA network card is used to transmit the first message to a second virtual machine corresponding to the second host machine; The second host machine is used to receive the first message through the second RDMA network card, and store the first message in the memory corresponding to the receiving queue of the second RDMA network card; and store the first message in the shared memory resource pool of the second virtual machine through the second memory mapping table; The second memory mapping table is a correspondence table between the second memory address of the receiving queue of the second RDMA network card and the second shared memory address of the shared memory resource pool of the second virtual machine. The second memory mapping table is used to indicate that the first message from the receiving queue is stored in the shared memory resource pool of the second virtual machine.
12. A virtual machine communication method and device based on RDMA, characterized in that: Applied to a second host machine, the second host machine corresponds to a second virtual machine; the second virtual machine is created by a cloud management platform; The second host machine is configured with a second remote direct data access RDMA network card; the device comprises: The second transceiver module is used to receive a first message from the first host machine through the second RDMA network card, and store the first message in a receiving queue of the second RDMA network card, wherein the first message is generated and stored by a first virtual machine corresponding to the first host machine, and the memory corresponding to the receiving queue is allocated by the cloud management platform; Processing module 2, used for storing the first message in the shared memory resource pool of the second virtual machine through a second memory mapping table, the second memory mapping table is used to indicate that the first message from the receiving queue is stored in the shared memory resource pool of the second virtual machine, the second memory mapping table is a correspondence table between the second memory address of the receiving queue of the second RDMA network card and the second shared memory address of the shared memory resource pool of the second virtual machine, and the shared memory resource pool of the second virtual machine is allocated by the cloud management platform; Among them, the first host machine is used to obtain a first message from the shared memory resource pool of the first virtual machine; store the first message in the sending queue of the first RDMA network card through a first memory mapping table; send the first message to the second RDMA network card through the sending queue; the first memory mapping table is a correspondence table between the first shared memory address of the shared memory resource pool of the first virtual machine and the first memory address of the sending queue of the first RDMA network card established by the cloud management platform.
13. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the RDMA-based virtual machine communication method according to any one of claims 1 to 7 by executing the computer instructions.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the RDMA-based virtual machine communication method according to any one of claims 1 to 7.
15. A computer program product, characterized in that The method comprises computer instructions, which, when executed on a computer, enable the computer to execute the RDMA-based virtual machine communication method as claimed in any one of claims 1 to 7.
