A virtual machine data transmission method, device, electronic device and storage medium
By using the control channel of shared memory in the virtual machine system to transmit application data between virtual machines, the problem of inefficient data transmission between virtual machines in the prior art is solved, and more efficient, real-time and reliable data transmission is achieved.
Patent Information
- Application Number
- CN202411789684.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-04-01
AI Technical Summary
In the prior art, applications between virtual machines transmit data through the separation of front and back ends, resulting in low data transmission efficiency and unable to meet the requirements of industrial control systems for real-time and high reliability.
Receive resource requests sent by the application through the control channel in shared memory, determine the target data block resources based on the resource request, generate response information, and transmit data through shared memory, realizing direct data transmission of applications between different virtual machines.
It improves the data transmission efficiency of applications between virtual machines, improves the real-time and high reliability of transmission, and avoids performance bottlenecks and maintenance costs under the front-end and back-end separation architecture.
Smart Images

Figure CN119739459A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a virtual machine data transmission method, device, electronic device and storage medium. Background Art
[0002] When an industrial control system with virtualization function is running, multiple virtual machines are usually deployed inside, and one or more applications are running on each of these virtual machines. During the operation of the industrial control system, applications on different virtual machines need to interact with each other efficiently to share resource information or access resources on each other's virtual machines.
[0003] In the related technology, industrial control system products that support virtualization on the market usually use the front-end-back-end program method to realize data interaction between virtual machines. However, this method has the following problems: since the front-end program needs to forward data through the back-end program, it not only increases the complexity of data transmission, but also introduces additional delays, resulting in low data interaction efficiency. At the same time, the front-end and back-end separation architecture design is prone to performance bottlenecks in high-concurrency scenarios and cannot meet the strict requirements of industrial control systems for real-time and high reliability. In addition, the interface definition between the front-end and back-end programs is complex, the maintenance cost is high, and the system scalability is also subject to certain restrictions. Summary of the invention
[0004] In view of this, the embodiments of the present application provide a virtual machine data transmission method, device, electronic device and storage medium to solve the problem in the prior art that applications between different virtual machines can only transmit data in the form of front-end and back-end separation, resulting in low data transmission efficiency.
[0005] According to a first aspect of an embodiment of the present application, a method for data transmission in a virtual machine is provided, the method comprising: receiving a resource request sent by a first application through a control channel in a shared memory; determining a target data block resource from the shared memory according to the resource request, generating a first response message based on the target data block resource, and sending the first response message to the first application; receiving a resource request sent by a second application through a control channel in the shared memory, and generating a second response message based on the target data block resource, the first application and the second application being applications on different virtual machines; and sending the second response message to the second application, so that the first application and the second application perform data transmission through the target data block resource.
[0006] According to a second aspect of an embodiment of the present application, a virtual machine data transmission device is provided, which includes: a receiving module, which is used to receive a resource request sent by a first application through a control channel in a shared memory; a resource module, which is used to determine a target data block resource from the shared memory according to the resource request, generate a first response message based on the target data block resource, and send the first response message to the first application; the receiving module is also used to receive a resource request sent by a second application through a control channel in the shared memory, and generate a second response message based on the target data block resource, the first application and the second application are applications on different virtual machines; the resource module is also used to send the second response message to the second application, so that the first application and the second application can perform data transmission through the target data block resource.
[0007] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0008] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0009] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the method of the embodiments of the present application receives a resource request sent by a first application through a control channel in a shared memory; determines a target data block resource from the shared memory according to the resource request, generates a first response message based on the target data block resource, and sends the first response message to the first application; receives a resource request sent by a second application through a control channel in the shared memory, and generates a second response message based on the target data block resource, wherein the first application and the second application are applications on different virtual machines; sends the second response message to the second application, so that the first application and the second application perform data transmission through the target data block resource. The present application realizes data transmission between the first application and the second application in different virtual machines by means of a shared memory, thereby improving the transmission efficiency of applications between different virtual machines, which improves the real-time and high reliability of transmission of applications between different virtual machines, and avoids the problem in the related art that applications between different virtual machines can only perform data transmission in the form of front-end and back-end separation, resulting in low data transmission efficiency and failure to meet real-time and reliability requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0011] Figure 1 It is a flowchart of a virtual machine data transmission method provided in an embodiment of the present application;
[0012] Figure 2 It is a basic schematic diagram of a virtual machine system provided in an embodiment of the present application;
[0013] Figure 3 This is a basic schematic diagram of the relationship between a virtual machine, a shared memory, and a VMM provided in an embodiment of the present application;
[0014] Figure 4 This is a basic schematic diagram of an application program of each virtual machine provided in an embodiment of the present application;
[0015] Figure 5 This is a basic schematic diagram of a shared memory provided by an embodiment of the present application;
[0016] Figure 6 This is another basic schematic diagram of a shared memory provided in an embodiment of the present application;
[0017] Figure 7 This is a basic schematic diagram of a virtual machine system startup process provided by an embodiment of the present application;
[0018] Figure 8 This is a basic flow chart of a virtual machine data transmission method provided in an embodiment of the present application;
[0019] Fig. 9 It is a flowchart of another virtual machine data transmission method provided in an embodiment of the present application;
[0020] Fig.10 It is a flowchart of another virtual machine data transmission method provided in an embodiment of the present application;
[0021] Fig.11 This is a basic flow diagram of a first target application releasing target data block resources provided by an embodiment of the present application;
[0022] Fig.12 It is a flowchart of another virtual machine data transmission method provided in an embodiment of the present application;
[0023] Fig.13This is a basic flow diagram of a daemon process releasing target data block resources provided by an embodiment of the present application;
[0024] Fig.14 It is a flowchart of another virtual machine data transmission method provided in an embodiment of the present application;
[0025] Fig.15 It is a basic schematic diagram of dividing a data block into a communication channel and a byte stream channel provided by an embodiment of the present application;
[0026] Fig.16 It is a basic schematic diagram of dividing a data block into a communication channel and a data block channel provided by an embodiment of the present application;
[0027] Fig.17 It is a flowchart of another optional virtual machine data transmission method provided in an embodiment of the present application;
[0028] Fig.18 It is a flowchart of another optional virtual machine data transmission method provided in an embodiment of the present application;
[0029] Fig.19 It is a structural schematic diagram of a virtual machine data transmission device provided in an embodiment of the present application;
[0030] Fig. 20 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0031] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0032] A method and device for virtual machine data transmission according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0033] Figure 1 A virtual machine data transmission method provided in an embodiment of the present application is as follows: Figure 1 As shown, the method includes:
[0034] S101, receiving a resource request sent by a first application through a control channel in a shared memory;
[0035] S102, determining a target data block resource from a shared memory according to a resource request, generating first response information based on the target data block resource, and sending the first response information to a first application;
[0036] S103, receiving a resource request sent by a second application through a control channel in the shared memory, and generating second response information according to the target data block resource, wherein the first application and the second application are applications on different virtual machines;
[0037] S104: Send the second response information to the second application, so that the first application and the second application perform data transmission through the target data block resources.
[0038] It can be understood that the virtual machine data transmission method provided in the present application is applied to a daemon process, the daemon process is set on a master virtual machine of a virtual machine system, and a plurality of virtual machines are set in the virtual machine system, the virtual machine system is an industrial control system, and the virtual machine system is exemplarily Figure 2 As shown, the virtual machine system is provided with hardware, on which the virtual machine management VMMM (virtual machine manager) software runs. VMM manages several virtual machines (virtual machine 0, virtual machine 1, ...). The first virtual machine 0 is also called the root operating system (Root OS); virtual machines 1 to virtual machines n are also called client operating systems (Guest OS). Virtual machine 0 (also called Root OS) is the first virtual machine started after VMM is started, and VMM is responsible for starting it. After virtual machine 0 is ready to start, virtual machine 0 loads and starts other Guest OS virtual machines (virtual machine 1 to virtual machine n). It can be understood that all virtual machines have a unique identifier, called osID, which is represented by a string or a number.
[0039] It can be understood that a shared memory is provided in the virtual machine system, and the shared memory can be accessed by virtual machines 0 to n. The relationship between each virtual machine, the shared memory and the VMM is as follows: Figure 3 As shown in the figure, virtual machine 0 (Roos OS) and virtual machines 1…n (virtual machine 1 to virtual machine n, Guest OS) can access shared memory; VMM has the highest authority over shared memory and can assign permissions. Events are transmitted between virtual machines through the event channel of VMM, that is, notification events are sent and received. The processing process of this event in the virtual machine is the same as that of external interrupts.
[0040] It can be understood that after each virtual machine (virtual machine 0 to virtual machine n) is started and ready, the relationship between the application programs of each virtual machine is as follows: Figure 4As shown, after virtual machine 0 is ready, a daemon process runs in the background, which is responsible for processing messages sent by applications on each virtual machine (virtual machine 0 to virtual machine n) and managing and allocating shared memory resources. Applications are running on each virtual machine, and interact with the daemon process running on virtual machine 0 through shared memory, including applying for shared memory resources and releasing memory resources. Subsequently, through the solution of this application, applications of different virtual machines communicate and transmit data through the applied shared memory resources.
[0041] In some examples, before receiving the resource request sent by the first application through the control channel in the shared memory, the method further includes allocating a control channel memory in the shared memory, where the control channel memory is a channel memory provided for communication between virtual machines. The application running on each virtual machine can send and receive control messages to the daemon process running on virtual machine 0 through this memory, such as Figure 5 shown.
[0042] It is understandable that if Figure 5 As shown in the figure, the control channel memory consists of a number of control channels, named control channels 0, 1 to n. The size of each control channel is 4K or a multiple of 4K, and the total number is the same as the maximum number of virtual machines supported by the system. Each control channel is represented by a unique identifier, called channelID, which is represented by a string or a number. Each control channel consists of two circular consumer queues, called queue 0 and queue 1. Queue 0 is the upstream queue, and messages are sent from the application to the daemon. Queue 1 is the downstream queue, and messages are sent from the daemon to the application. In queues 0 and 1, messages enter sequentially in a first-in-first-out manner. After the last message, the first message follows, forming a circular message queue. The maximum number of messages that can be stored in a circular queue is the length of the circular queue. For the upstream queue, messages are sent from the application to the daemon. The application writes the message to the end of the circular queue and updates the position of the end. The daemon always takes the message from the head of the circular queue and updates the position of the head. For the downstream queue, it is just the opposite. Messages are sent from the daemon to the application. The daemon writes the message to the end of the ring queue and updates the position of the end. The application always takes the message from the head of the ring queue and updates the position of the head. It can be understood that the ring buffer is an efficient data structure, which is often used in scenarios such as logging and event communication. It is used here as a communication mechanism between two virtual machines. The specific implementation mechanism of the ring queue is omitted.
[0043] In some examples, such as Figure 6 As shown, the present application refers to the remaining memory in the shared memory as data block resources. These data block resources are divided into several data blocks, such as Figure 6As shown, data block 0, data block 1, ... The size of the data block is divided into 4K or 8K or 16K or 64K bytes. The specific size used is the page size of the operating system or a multiple of the page size. The data blocks are numbered starting from 0 until they are used up. For example, 1M bytes, the page size is 4K bytes, and the allocation is as follows: a total of 256 data channels, numbered 0, 1, ..., 255. Each data block has a unique identifier, called blockID, which can be represented by a number, or a number or string that corresponds to the number.
[0044] In some examples, such as Figure 7 As shown in the figure, after the virtual machine system is started, VMM first loads virtual machine 0, i.e., Root OS. Virtual machine 0 loads virtual machines 1, 2, ..., n in turn. Virtual machine 0 allocates permissions to virtual machines 1, 2, ..., n to access the shared memory control channel. The permissions of shared memory are allocated as follows: Control channel 0 is allocated to virtual machine 0 itself, with read and write permissions. Control channel 1 is allocated to virtual machine 1, with read and write permissions. And so on. Control channel n is allocated to virtual machine n, with read and write permissions. Virtual machine 0 has read and write permissions for all control channels. After virtual machine 0 is started, it runs the daemon process. The daemon process applies to VMM for permissions to all shared memories. The daemon process initializes the shared memory, listens to request messages through the control channel and processes the request messages, allocates resources, and finally sends a response message to the requester. The application (which may run on virtual machine 0 or virtual machine 1 or 2, ..., n) applies to virtual machine 0 for resources through the control channel.
[0045] In some examples, such as Figure 8 As shown, in the present application, the daemon process receives a resource request sent by a first application through a control channel in a shared memory. The first application is any virtual machine in the virtual machine system (any one of virtual machines 0 to n). It can be understood that the resource request is used by the virtual machine to apply to the daemon process for data block resources for data transmission.
[0046] It can be understood that the above resource request carries parameters such as msgType, name, type, blocks, osId, etc., where MsgType is the message type, and the message types include: application, application response, notification, notification response, release request, release request response, release notification, release notification response and other types; name is the name of the request, name is the system's globally unique identifier, and two applications that need to communicate need to use the same name; Type is the requested resource type, which is divided into two types: byte stream resources and data block stream resources, which will be explained later; Block is the number of requested data blocks, and the two applications that need to communicate need to agree on this parameter in advance and request the same data blocks; OsID is the unique identifier of this virtual machine.
[0047] It can be understood that after receiving the resource request, the daemon process will allocate shared memory based on the resource request, use the allocated data block in the shared memory as the target data block resource (blockIDs), generate a first response message based on the target data block resource, and send the first response message to the first application, wherein the first response message includes parameters such as MsgType, name, result, blockIDs, bFirst, etc. It can be understood that bFirst is used to indicate whether it is the first time to receive the request corresponding to the name, and the value is true for the first time and false for the second time.
[0048] In some examples, in order to improve the allocation efficiency and management efficiency of shared memory, a table for storing shared memory resource application status is set in the daemon process (it can also be in the form of hash storage, database storage, or key-value pair storage). When any application applies for resources and the daemon process allocates shared memory based on the resource request, the table will be updated to record the allocated target data block resources. The specific record content includes: MsgType, name, blockIDs, events, state and other parameters.
[0049] In some examples, the daemon process of the present application receives a resource request sent by a second application through a control channel in shared memory (it can be understood that the resource request sent by the second application has the same name parameter as the resource request sent by the first application), and generates a second response message based on the target data block resource. The first application and the second application are applications on different virtual machines.
[0050] It can be understood that since events are transmitted between virtual machines in the virtual machine system through the event channel of the VMM, the daemon process will also assign events to the second application, record the event assigned to the second application as eventy, and generate a second response information based on the assigned event and the above-mentioned resource request, and send the second response information to the second application, so that the first application and the second application can transmit data through the target data block resources, wherein the second response information includes msgType, name, result, blockIDs, eventY, bFirst.
[0051] Based on the above reasons, the daemon process of the present application will also assign event eventX to the first application. In some examples, when sending the second response information to the second application, the daemon process will also generate a notification (the notification contains the above event eventX) to the first application, so that the first application can send a message through eventX, such as Figure 8 As shown, after receiving the above notification, the first application will update the local state, record eventX, and send a notification response (msgType, name) to the daemon process, so that the daemon process can know the state of the first application. Finally, the daemon process updates the table set in the daemon process for storing the shared memory resource application status according to the notification response.
[0052] It is understandable that if Figure 8 As shown, the first application is in a half-ready state after step 3; the second application is in a ready state after step 7; the first application is in a ready state after step 10; the first application and the second application can communicate after both are in the ready state.
[0053] According to the technical solution provided in the embodiment of the present application, a resource request sent by a first application is received through a control channel in a shared memory; a target data block resource is determined from the shared memory according to the resource request, a first response message is generated based on the target data block resource, and the first response message is sent to the first application; a resource request sent by a second application is received through a control channel in the shared memory, and a second response message is generated based on the target data block resource, wherein the first application and the second application are applications on different virtual machines; the second response message is sent to the second application, so that the first application and the second application perform data transmission through the target data block resource. The present application realizes data transmission between the first application and the second application in different virtual machines by means of a shared memory, thereby improving the transmission efficiency of applications between different virtual machines, which improves the real-time and high reliability of transmission of applications between different virtual machines, and avoids the problem in the related art that applications between different virtual machines can only perform data transmission in the form of front-end and back-end separation, resulting in low data transmission efficiency and failure to meet real-time and reliability requirements.
[0054] In some embodiments, Fig. 9 As shown, determining the target data block resource from the shared memory according to the resource request includes:
[0055] S901, parsing the resource request, and obtaining the requested number of data block resources carried in the resource request;
[0056] S902: Acquire the data block resources to be allocated in the shared memory, and determine the target data block resources according to the data block resources to be allocated and the requested number of data block resources.
[0057] Specifically, the daemon process of the present application parses the resource request, determines the number of data block resource requests requested by the first application, then obtains the data block resources to be allocated in the shared memory, and determines the target data block resources based on the data block resources to be allocated and the number of data block resource requests.
[0058] Exemplarily, the resource request sent by the first application is for a requested data block resource quantity of 5, and the daemon process obtains the data block resources to be allocated in the shared memory, and then takes out 5 data block resources from the data block resources to be allocated as target data block resources.
[0059] According to the technical solution provided in the embodiment of the present application, the resource request is parsed to obtain the number of data block resource requests carried by the resource request; the data block resources to be allocated in the shared memory are obtained, and the target data block resources are determined based on the data block resources to be allocated and the number of data block resource requests, thereby accurately allocating the target data block resources for data transmission to the first application.
[0060] In some embodiments, Fig.10 As shown, after sending the second response information to the second application program so that the first application program and the second application program perform data transmission through the target data block resource, the method further includes:
[0061] S1001, receiving a data block resource release request sent by a first target application, where the first target application is one of a first application and a second application;
[0062] S1002, generating a data block resource release notification in response to the data block resource release request, and sending the data block resource release notification to a second target application, so that the second target application releases the target data block resource, the second target application being the other of the first application and the second application;
[0063] S1003, receiving a data block resource release notification response returned by the second target application based on the data block resource release notification, generating a release request response based on the data block resource release notification response and sending it to the first target application, so that the first target application releases the target data block resources.
[0064] Specifically, after completing data transmission through the target data block, the first application and / or the second application can actively initiate a request to release the target data block resources to avoid resource waste caused by occupying the target data block resources for a long time after they are no longer needed.
[0065] Continuing with the above example, Fig.11 As shown, after the daemon process of the present application receives a data block resource release request sent by the first target application, it will generate a data block resource release notification in response to the data block resource release request, and send the data block resource release notification to the second target application. It can be understood that the first target application is one of the first application and the second application, and the second target application is the other of the first application and the second application.
[0066] In some examples, after receiving the data block resource release notification, the second target application releases local resources (releases the target data block resources). After the release is completed, it returns a data block resource release notification response to the daemon process. After the daemon process receives the data block resource release notification response returned by the second target application based on the data block resource release notification, it generates a release request response based on the data block resource release notification response and sends it to the first target application, so that the first target application releases local resources (releases the target data block resources). At this time, the daemon process releases the target data block resources, deletes the events corresponding to the first target application and the second target application (eventX and eventY), and deletes the record from the table.
[0067] According to the technical solution provided in the embodiment of the present application, a data block resource release request sent by a first target application is received, and the first target application is one of the first application and the second application; a data block resource release notification is generated in response to the data block resource release request, and the data block resource release notification is sent to the second target application, so that the second target application releases the target data block resources, and the second target application is the other of the first application and the second application; a data block resource release notification response returned by the second target application based on the data block resource release notification is received, and a release request response is generated based on the data block resource release notification response to the first target application, so that the first target application releases the target data block resources. The above method realizes the release of the target data block resources and avoids the problem of resource waste caused by the first application and the second application occupying the target data block resources for a long time after they no longer need to use the target data block resources.
[0068] In some embodiments, Fig.12 As shown, after sending the second response information to the second application program so that the first application program and the second application program perform data transmission through the target data block resource, the method further includes:
[0069] S1201. Send a data block resource release notification to a first application and a second application, so that the first application and the second application release target data block resources.
[0070] Specifically, the daemon process can actively initiate a data block resource release notification to the first application and the second application to release the target data block resources, thereby avoiding the problem of resource waste caused by occupying the target data block resources for a long time after they are no longer needed.
[0071] like Fig.13 As shown, the daemon process sends a data block resource release notification to the first application and the second application. The first application and the second application will release local resources respectively. After the first application and the second application complete the release, they will return a data block resource release notification response to the daemon process respectively. At this time, the daemon process will release the target data block resources, delete the events (eventX and eventY) corresponding to the first target application and the second target application, and delete the record from the table.
[0072] According to the technical solution provided in the embodiment of the present application, a data block resource release notification is sent to the first application and the second application, so that the first application and the second application release the target data block resources. The present application actively initiates a data block resource release notification to the first application and the second application through a daemon process, thereby releasing the target data block resources and avoiding the problem of resource waste caused by occupying the target data block resources for a long time after they are no longer needed.
[0073] In some embodiments, Fig.14 As shown, after determining the target data block resource from the shared memory according to the resource request, the method further includes:
[0074] S1401, determining the memory resource type carried in the resource request, and determining a data block resource division method based on the memory resource type;
[0075] S1402: Divide the target data block resources according to the data block resource division method, so that the first application and the second application perform data transmission through the divided target data block resources.
[0076] It can be understood that different memory resource types correspond to different data block resource division methods. In the present application, the daemon process will determine the memory resource type carried in the resource request, determine the data block resource division method based on the memory resource type, and then divide the target data block resources according to the data block resource division method, so that the first application and the second application can transmit data through the divided target data block resources.
[0077] For example, taking the memory resource type including the byte stream type and the data block type as an example, when the memory resource type carried in the resource request is the sub-throttling type, such as Fig.15 As shown, the daemon divides the data block into a communication channel and a byte stream channel (the data block division method corresponding to the sub-throttling type is to divide the target data block resources into a communication channel and a byte stream channel). The communication channel is further divided into queue 0 and queue 1. They are used to send messages respectively. All messages form a circular message queue. The two parties in communication are called the master end and the slave end respectively. When bFirst is true, the end is defined as the master end. When bFirst is false, the end is defined as the slave end. The data transmission direction of the queue is defined as follows: Queue 0 is called the upstream queue, that is, the direction of data transmission is: slave end->master end; Queue 1 is called the downstream queue, that is, the direction of data transmission is: master end->slave end. The byte stream channel is divided into an upstream byte stream channel and a downstream byte stream channel. Corresponding to the definition of the data transmission direction of the above queues 0 and 1, the definition of the upstream byte stream channel and the downstream byte stream channel is as follows: the data transmission direction of the upstream byte stream channel is: slave end->master end. The data transmission direction of the downstream byte stream channel is: master end->slave end.
[0078] When the memory resource type carried in the resource request is a data block type, such as Fig.16 As shown, the daemon divides the data blocks applied for by the data block type into: communication channels and data block channels (the data block division method corresponding to the data block type is to divide the target data block resources into communication channels and data block channels). The communication channel is further divided into queue 0 and queue 1. They are used to send messages respectively. All messages form a circular message queue. The two parties in communication are called the master end and the slave end respectively. When bFirst is true, the end is defined as the master end. When bFirst is false, the end is defined as the slave end. Definition of the data transmission direction of the queue: Queue 0 is called the uplink queue, that is, the direction of data transmission is: slave end->master end; Queue 1 is called the downlink queue, that is, the direction of data transmission is: master end->slave end. The data block channel is divided into the uplink data block channel and the downlink data block channel. Both the uplink data block channel and the downlink data block channel are composed of several data blocks. Corresponding to the definition of the data transmission direction of the above queues 0 and 1, the definition of the uplink data block channel and the downlink data block channel: the data transmission direction of the uplink data block channel is: slave end->master end. The data transmission direction of the downlink data block channel is: master end->slave end.
[0079] According to the technical solution provided in the embodiment of the present application, the memory resource type carried in the resource request is determined, and the data block resource division method is determined based on the memory resource type; the target data block resources are divided according to the data block resource division method, so that the first application and the second application perform data transmission through the divided target data block resources. The present application realizes accurate division of the target data block resources through the memory resource type carried in the resource request, so that the divided target data block resources can meet the data transmission requirements of the first application and the second application.
[0080] In some embodiments, Fig.17 As shown, the target data block resources are divided according to the data block resource division method, including:
[0081] S1701. Divide the target data block according to the data block resource division method to obtain the target data channel corresponding to the communication channel data block resource division method, so that after the first application completes data transmission to the target data channel, the first application transmits a message of data transmission completion to the second application through the communication channel, and the second application reads the data transmitted by the first application from the target data channel; after the second application completes data transmission to the target data channel, the two applications transmit a message of data transmission completion to the first application through the communication channel, and the first application reads the data transmitted by the second application from the target data channel.
[0082] Specifically, taking the memory resource type carried in the resource request as a byte stream type, and the data block division method corresponding to the sub-throttling type as dividing the target data block resource into a communication channel and a byte stream channel as an example, the sub-throttling channel is the target data channel at this time, wherein the byte stream type shares the memory communication method. During data transmission, one end (the first application or one of the second applications) writes data in the byte stream channel, and then writes a message in the communication channel, and notifies the other party (the other one of the first application or the second application) through an event. After receiving the notification, the other party reads the data and then replies with a confirmation message in the communication channel.
[0083] The communication channel write message and confirmation are defined as follows:
[0084]
[0085] Among them, Int indicates that the data type is integer data. MsgType: indicates the message type, 0-indicates a write data message; 1-indicates a confirmation message; other values-indicate non-data messages, which are used to extend messages for users, such as sending control messages between two parties. write_position: indicates the starting position of the message, which is the address offset of the data in the upstream byte stream channel or the upstream byte stream channel. data_length: indicates the length of the write data.
[0086] Specifically, taking the memory resource type carried in the resource request as a data block type, and the data block division method corresponding to the sub-throttling type as dividing the target data block resource into a communication channel and a data block channel as an example, the data block type shares the memory communication method. During data transmission, one end (the first application or one of the second applications) writes data in the data block channel, and then writes a message in the communication channel, and notifies the other party (the other in the first application or the second application) through an event. After receiving the notification, the other party reads the data and then replies with a confirmation message in the communication channel.
[0087] The communication channel write message and confirmation are defined as follows:
[0088]
[0089] Among them, Int indicates that the data type is integer data. MsgType: indicates the message type, 0-indicates a write data message; 1-indicates a confirmation message; other values-indicate non-data messages, which are used to extend messages for users, such as sending control messages between two parties. write_block_start: indicates the starting position of the message, which is the offset of the data in the uplink data block channel or the downlink data block channel, that is, the position of the first data block. data_length: indicates the length of the write data. The number of data blocks used for this write data can be calculated by the data length.
[0090] According to the technical solution provided in the embodiment of the present application, the target data block is divided according to the data block resource division method, and the target data channel corresponding to the communication channel data block resource division method is obtained, so that after the first application completes transmitting data to the target data channel, the first application transmits a message of data transmission completion to the second application through the communication channel, and the second application reads the data transmitted by the first application from the target data channel; after the second application completes transmitting data to the target data channel, the two applications transmit a message of data transmission completion to the first application through the communication channel, and the first application reads the data transmitted by the second application from the target data channel, thereby realizing data transmission between the first application and the second application.
[0091] In some embodiments, Fig.18 As shown, before receiving the resource request sent by the first application through the control channel in the shared memory, the method also includes:
[0092] S1801. A control channel memory is divided in a shared memory, where the control channel memory is used for communication between each virtual machine in the virtual machine system and a daemon process.
[0093] Specifically, before receiving the resource request sent by the first application through the control channel in the shared memory, the method further includes allocating a control channel memory in the shared memory, where the control channel memory is a channel memory provided for communication between virtual machines. The application running on each virtual machine can send and receive control messages to the daemon process running on virtual machine 0 through this memory.
[0094] According to the technical solution provided in the embodiment of the present application, a control channel memory is divided in the shared memory, and the control channel memory is used for communication between each virtual machine in the virtual machine system and the daemon process, so that each virtual machine in the virtual machine system can communicate with the daemon process.
[0095] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0096] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0097] This embodiment also provides a virtual machine data transmission device, such as Fig.19 As shown, the device comprises:
[0098] The receiving module 1901 is used to receive a resource request sent by the first application through a control channel in the shared memory;
[0099] The resource module 1902 is used to determine the target data block resource from the shared memory according to the resource request, generate first response information based on the target data block resource, and send the first response information to the first application;
[0100] The receiving module 1901 is further used to receive a resource request sent by a second application through a control channel in the shared memory, and generate a second response message according to the target data block resource, wherein the first application and the second application are applications on different virtual machines;
[0101] The resource module 1902 is further configured to send the second response information to the second application program, so that the first application program and the second application program perform data transmission through the target data block resource.
[0102] In some examples, resource module 1902 is also used to parse resource requests to obtain the number of data block resource requests carried in the resource requests; obtain the data block resources to be allocated in the shared memory, and determine the target data block resources based on the data block resources to be allocated and the number of data block resource requests.
[0103] In some examples, the resource module 1902 is also used to receive a data block resource release request sent by a first target application, where the first target application is one of the first application and the second application; generate a data block resource release notification in response to the data block resource release request, and send the data block resource release notification to the second target application, so that the second target application releases the target data block resources, where the second target application is the other of the first application and the second application; receive a data block resource release notification response returned by the second target application based on the data block resource release notification, and generate a release request response to the first target application based on the data block resource release notification response, so that the first target application releases the target data block resources.
[0104] In some examples, the resource module 1902 is further used to send a data block resource release notification to the first application and the second application, so that the first application and the second application release the target data block resources.
[0105] In some examples, resource module 1902 is also used to determine the memory resource type carried in the resource request, and determine the data block resource division method based on the memory resource type; divide the target data block resources according to the data block resource division method, so that the first application and the second application perform data transmission through the divided target data block resources.
[0106] In some examples, resource module 1902 is also used to divide the target data block according to the data block resource division method to obtain the target data channel corresponding to the communication channel data block resource division method, so that after the first application completes transmitting data to the target data channel, the first application transmits a message of data transmission completion to the second application through the communication channel, and the second application reads the data transmitted by the first application from the target data channel; after the second application completes transmitting data to the target data channel, the two applications transmit a message of data transmission completion to the first application through the communication channel, and the first application reads the data transmitted by the second application from the target data channel.
[0107] In some examples, the resource module 1902 is further used to divide the control channel memory in the shared memory, and the control channel memory is used for communication between each virtual machine in the virtual machine system and the daemon process.
[0108] According to the technical solution provided by the embodiment of the present application, the virtual machine data transmission device provided by the present embodiment receives a resource request sent by a first application through a control channel in a shared memory; determines a target data block resource from the shared memory according to the resource request, generates a first response message based on the target data block resource, and sends the first response message to the first application; receives a resource request sent by a second application through the control channel in the shared memory, and generates a second response message based on the target data block resource, the first application and the second application are applications on different virtual machines; sends the second response message to the second application, so that the first application and the second application perform data transmission through the target data block resource. The present application realizes data transmission between the first application and the second application in different virtual machines by means of shared memory, thereby improving the transmission efficiency of applications between different virtual machines, which improves the real-time and high reliability of transmission of applications between different virtual machines, and avoids the problem that in the related art, applications between different virtual machines can only perform data transmission in the form of front-end and back-end separation, resulting in low data transmission efficiency and inability to meet real-time and reliability requirements.
[0109] Fig. 20 Schematic diagram of an electronic device 20 provided in an embodiment of the present application. Fig. 20 As shown, the electronic device 20 of this embodiment includes: a processor 2001, a memory 2002, and a computer program 2003 stored in the memory 2002 and executable on the processor 2001. When the processor 2001 executes the computer program 2003, the steps in the above-mentioned various method embodiments are implemented. Alternatively, when the processor 2001 executes the computer program 2003, the functions of the modules / units in the above-mentioned various device embodiments are implemented.
[0110] The electronic device 20 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 20 may include, but is not limited to, a processor 2001 and a memory 2002. Those skilled in the art will appreciate that Fig. 20 The electronic device 20 is merely an example and does not limit the electronic device 20 . The electronic device 20 may include more or fewer components than those shown in the figure, or different components.
[0111] Processor 2001 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0112] The memory 2002 may be an internal storage unit of the electronic device 20, for example, a hard disk or memory of the electronic device 20. The memory 2002 may also be an external storage device of the electronic device 20, for example, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. equipped on the electronic device 20. The memory 2002 may also include both an internal storage unit of the electronic device 20 and an external storage device. The memory 2002 is used to store computer programs and other programs and data required by the electronic device.
[0113] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0114] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, and the computer program code may be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of regional requirements and patent practice. For example, in some areas, according to regional requirements and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.
[0115] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A virtual machine data transmission method, characterized in that: The virtual machine communication method is applied to a daemon process, the daemon process is set on a master virtual machine of a virtual machine system, and a plurality of virtual machines are set in the virtual machine system, and the method includes: receiving a resource request sent by the first application through a control channel in the shared memory; determining a target data block resource from the shared memory according to the resource request, generating first response information based on the target data block resource, and sending the first response information to the first application; receiving a resource request sent by a second application through a control channel in the shared memory, and generating second response information according to the target data block resource, wherein the first application and the second application are applications on different virtual machines; The second response information is sent to the second application, so that the first application and the second application perform data transmission through the target data block resource.
2. The method according to claim 1, characterized in that Determining a target data block resource from the shared memory according to the resource request includes: Parse the resource request and obtain the number of data block resource requests carried in the resource request; The data block resources to be allocated in the shared memory are obtained, and the target data block resources are determined according to the data block resources to be allocated and the requested number of data block resources.
3. The method according to claim 1, characterized in that After sending the second response information to the second application so that the first application and the second application perform data transmission through the target data block resource, the method further includes: receiving a data block resource release request sent by a first target application, where the first target application is one of the first application and the second application; generating a data block resource release notification in response to the data block resource release request, and sending the data block resource release notification to a second target application, so that the second target application releases the target data block resource, the second target application being the other of the first application and the second application; Receive a data block resource release notification response returned by the second target application based on the data block resource release notification, and generate a release request response to the first target application based on the data block resource release notification response, so that the first target application releases the target data block resource.
4. The method according to claim 1, characterized in that After sending the second response information to the second application so that the first application and the second application perform data transmission through the target data block resource, the method further includes: A data block resource release notification is sent to the first application and the second application, so that the first application and the second application release the target data block resource.
5. The method according to claim 1, characterized in that After determining the target data block resource from the shared memory according to the resource request, the method further includes: Determine the memory resource type carried in the resource request, and determine the data block resource division method based on the memory resource type; The target data block resources are divided according to the data block resource division method, so that the first application and the second application perform data transmission through the divided target data block resources.
6. The method according to claim 1, characterized in that Dividing the target data block resources according to the data block resource division method includes: The target data block is divided according to the data block resource division method to obtain a target data channel corresponding to the data block resource division method of the communication channel, so that after the first application completes transmitting data to the target data channel, the first application transmits a message of data transmission completion to the second application through the communication channel, and the second application reads the data transmitted by the first application from the target data channel; after the second application completes transmitting data to the target data channel, the two applications transmit a message of data transmission completion to the first application through the communication channel, and the first application reads the data transmitted by the second application from the target data channel.
7. The method according to claim 1, characterized in that Before receiving the resource request sent by the first application through the control channel in the shared memory, the method further includes: A control channel memory is divided in the shared memory, and the control channel memory is used for communication between each virtual machine in the virtual machine system and the daemon process.
8. A virtual machine data transmission device, characterized in that: The device comprises: A receiving module, used for receiving a resource request sent by a first application through a control channel in a shared memory; a resource module, configured to determine a target data block resource from the shared memory according to a resource request, generate first response information based on the target data block resource, and send the first response information to the first application; The receiving module is further used to receive a resource request sent by a second application through the control channel in the shared memory, and generate a second response message according to the target data block resource, wherein the first application and the second application are applications on different virtual machines; The resource module is also used to send the second response information to the second application, so that the first application and the second application perform data transmission through the target data block resource.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.