Communication method between virtual machines, electronic equipment, storage medium and computer program product
By introducing read and write verification policies and shared areas between virtual machines, the problems of low communication efficiency and poor real-time performance between traditional virtual machines are solved, and efficient and secure communication between virtual machines are achieved.
Patent Information
- Application Number
- CN202411665477.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-03-28
AI Technical Summary
Traditional communication methods between virtual machines lead to the concentration of communication load in the virtualization layer, resulting in low communication efficiency and poor real-time performance.
By introducing read and write verification policies between virtual machines, write verification and read verification are performed, and when passing the verification, data is written or read the shared area, efficient communication between virtual machines is achieved.
Improves the efficiency and real-time nature of communication between virtual machines, while enhancing the security of communication.
Smart Images

Figure CN119718538A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of virtualization technology, and in particular to a method, electronic device, storage medium and computer program product for communication between virtual machines. Background Art
[0002] Virtualization technology allows the creation and operation of multiple virtual machine instances on a single hardware platform. These virtual machines can share hardware resources while maintaining their independence and isolation. Therefore, virtualization technology can greatly improve the utilization of hardware. At the same time, in a virtualized scenario, communication between virtual machines is of great significance.
[0003] Traditional inter-VM communication methods are mostly based on virtual bridges to build an internal star network topology, aggregate data to the root operating system and then forward it to the target VM. Among them, user applications in each VM can use socket programming to transmit data through virtual network nodes. Therefore, this data communication method has good versatility and is easy to use for users, so it has a relatively wide range of applications.
[0004] However, the above communication method will cause the communication load to be concentrated in the virtualization layer, resulting in low communication efficiency and poor communication real-time performance. Summary of the invention
[0005] Based on the above technical status, the present application proposes a method, electronic device, storage medium and computer program product for communication between virtual machines, which can improve the efficiency and real-time performance of communication between virtual machines.
[0006] According to a first aspect of an embodiment of the present application, a method for communication between virtual machines is provided, which is applied to a first virtual machine, and the method includes: when the first virtual machine transmits target data to a second virtual machine, performing a write check based on a write check strategy in a read-write check strategy; wherein the read-write check strategy includes a check strategy determined for the read and write operations of the virtual machine; when the write check passes, writing the target data to a target shared area for reading by the second virtual machine, wherein the target shared area is a physical storage area shared by the first virtual machine and the second virtual machine in a target electronic device.
[0007] According to a second aspect of an embodiment of the present application, a method for communication between virtual machines is provided, which is applied to a second virtual machine, and the method includes: when the second virtual machine receives target data transmitted by the first virtual machine, performing a read check based on a read check strategy in a read-write check strategy; wherein the read-write check strategy includes a check strategy determined for the read and write operations of the virtual machine; when the read check passes, reading the target data from the target shared area, wherein the target shared area is a physical storage area shared by the first virtual machine and the second virtual machine in the target electronic device.
[0008] According to a third aspect of an embodiment of the present application, a device for communication between virtual machines is provided, which is applied to a first virtual machine, and the device includes: a write verification module, which is used to perform write verification based on a write verification strategy in a read-write verification strategy when the first virtual machine transmits target data to a second virtual machine; wherein the read-write verification strategy includes a verification strategy determined for the read and write operations of the virtual machine; and a write module, which is used to write the target data to a target shared area for reading by the second virtual machine when the write verification passes, wherein the target shared area is a physical storage area shared by the first virtual machine and the second virtual machine in a target electronic device.
[0009] According to a fourth aspect of an embodiment of the present application, a device for communication between virtual machines is provided, which is applied to a second virtual machine, and the device includes: a read verification module, which is used to perform a read verification based on a read verification strategy in a read-write verification strategy when the second virtual machine receives target data transmitted by the first virtual machine; wherein the read-write verification strategy includes a verification strategy determined for the read and write operations of the virtual machine; and a reading module, which is used to read the target data from the target shared area when the read verification passes, wherein the target shared area is a physical storage area shared by the first virtual machine and the second virtual machine in the target electronic device.
[0010] According to the fifth aspect of an embodiment of the present application, an electronic device is provided, comprising a memory and a processor; the memory is connected to the processor and is used to store programs; the processor is used to implement the method of inter-virtual machine communication as described in the first aspect or the second aspect by running the program in the memory.
[0011] According to a sixth aspect of an embodiment of the present application, a storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method for inter-virtual machine communication as described in the first aspect or the second aspect is implemented.
[0012] According to a seventh aspect of an embodiment of the present application, a computer program product is provided, comprising: a computer program, wherein when the computer program is executed by a processor, the method for inter-virtual machine communication as described in the first aspect or the second aspect is implemented.
[0013] In an embodiment of the present application, when the first virtual machine transmits target data to the second virtual machine, a write check is first performed based on a write check strategy in the read-write check strategy; wherein the read-write check strategy includes a check strategy determined for the read and write operations of the virtual machine. Then, in the case of write check, the target shared area shared by the two virtual machines is used to achieve the transmission of the target data. Compared with the method of transmitting data between virtual machines with the help of the traditional virtual network topology structure, the communication method provided by the present application is more efficient and more real-time. Furthermore, since a check link is performed before writing data, the security of communication between virtual machines can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, 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 embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0015] Figure 1 One of the flowcharts of a method for communication between virtual machines provided in an embodiment of the present application;
[0016] Figure 2 This is one of the schematic diagrams of the data writing process in the embodiment of the present application;
[0017] Figure 3 This is the second schematic diagram of the data writing process in the embodiment of the present application;
[0018] Figure 4 This is a schematic diagram of the organization of the target shared area in the embodiment of the present application;
[0019] Figure 5 This is the third schematic diagram of the data writing process in the embodiment of the present application;
[0020] Figure 6 This is a fourth schematic diagram of the data writing process in an embodiment of the present application;
[0021] Figure 7 This is a schematic diagram of the data writing process in the actual business in the embodiment of the present application;
[0022] Figure 8 A second flowchart of a method for communication between virtual machines provided in an embodiment of the present application;
[0023] Fig. 9 This is one of the schematic diagrams of the data reading process in the embodiment of the present application;
[0024] Fig.10 This is the second schematic diagram of the data reading process in the embodiment of the present application;
[0025] Fig.11 This is a schematic diagram of the data reading process in the actual business in the embodiment of the present application;
[0026] Fig.12 One of the structural schematic diagrams of a device for communication between virtual machines provided in an embodiment of the present application;
[0027] Fig.13 A second structural diagram of an apparatus for communication between virtual machines provided in an embodiment of the present application;
[0028] Fig.14 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0030] Overview
[0031] As described in the background technology, virtual machines mostly communicate with each other through an internally constructed virtual network topology. This method of communicating through a network structure topology inevitably results in low communication efficiency and poor real-time performance. In order to solve these problems, some technical solutions for implementing virtual machine communication using shared memory have gradually emerged.
[0032] However, the current technical solutions for implementing virtual machine communication through shared memory are mostly that the sender stores the data to be transmitted in the shared memory and then notifies the receiver. After receiving the notification, the receiver reads the data from the shared memory. It does not take measures to ensure the security of communication, so the communication security is poor.
[0033] In view of the above technical status, an embodiment of the present application proposes a method for communication between virtual machines. While using the target shared area to realize data transmission between virtual machines, a verification step is performed before writing data to the target shared area, thereby improving the security of communication between virtual machines.
[0034] Exemplary Methods
[0035] See also Figure 1 In an exemplary embodiment, a method for communication between virtual machines is provided, which is applied to a first virtual machine. The method for communication between virtual machines may include:
[0036] S101: When a first virtual machine transmits target data to a second virtual machine, write verification is performed based on a write verification strategy in a read-write verification strategy; wherein the read-write verification strategy includes a verification strategy determined for read and write operations of the virtual machine.
[0037] S102: When the write verification passes, write the target data into a target shared area for reading by the second virtual machine, wherein the target shared area is a physical storage area shared by the first virtual machine and the second virtual machine in the target electronic device.
[0038] It should be noted that the target electronic device can be a computer hardware device that can support virtualization technology. These devices divide physical hardware resources (such as CPU, memory, storage device, etc.) into multiple independent virtual environments through virtualization technology (such as virtualization software such as VMware and VirtualBox), and each environment can run different operating systems or applications. Among them, the target electronic device can generate multiple virtual machines through virtualization technology, and the first virtual machine and the second virtual machine can be any two of the aforementioned multiple virtual machines. For computer hardware devices, it includes but is not limited to servers, personal computers, laptops, workstations, and embedded systems. In some embodiments, the above-mentioned target shared area can be a shared memory allocated to the first virtual machine and the second virtual machine in the target electronic device, so that the first virtual machine and the second virtual machine can both access the target shared area. In some embodiments, based on the communication needs between different virtual machines, the same shared memory can be allocated to virtual machines with communication needs as the target shared area when they communicate. For example, virtual machine A and virtual machine B among 10 virtual machines have communication needs, and virtual machine C and virtual machine D have communication needs, then a piece of memory can be selected as a shared memory for virtual machine A and virtual machine B, and other memories can be selected as shared memory for virtual machine C and virtual machine D.
[0039] The target data is the object transmitted from the first virtual machine to the second virtual machine, which can be data of any data form and data content, and this application does not limit it. The read-write verification strategy may include a verification strategy determined for the read and write operations of the virtual machine to improve communication security. The read-write verification strategy may include a write verification strategy for implementing write verification and a read verification strategy for implementing read verification. In this embodiment, the first virtual machine needs to write data to the target shared area, so a write verification strategy will be used for write verification. Correspondingly, the second virtual machine needs to read the data in the target shared area, and then a read verification strategy needs to be used for read verification. It can be understood that through write verification, it can be regarded as having better security, and the first virtual machine is allowed to write data to the target shared area. Otherwise, the first virtual machine will be prohibited from writing data to the target shared area.
[0040] In an embodiment of the present application, when the first virtual machine transmits target data to the second virtual machine, a write check is first performed based on the write check strategy in the read-write check strategy; wherein the read-write check strategy includes a check strategy determined for the read and write operations of the virtual machine. Then, in the case of write check, the target shared area shared by the two virtual machines is used to achieve the transmission of the target data. Compared with the method of transmitting data between virtual machines with the help of the traditional virtual network topology structure, the communication method provided by the present application is more efficient and more real-time. Furthermore, since the check link is performed before writing the data, the security of communication between virtual machines can be improved.
[0041] In some embodiments of the present application, the write check includes: a write permission check;
[0042] Perform write verification based on the write verification strategy in the read-write verification strategy, including:
[0043] Determine a virtual machine that has write permission for the target shared area; perform a write permission check on the first virtual machine based on the virtual machine that has write permission, and determine that the write permission check has passed if the first virtual machine is a virtual machine that has write permission; and determine that the write permission check has not passed if the first virtual machine is not a virtual machine that has write permission.
[0044] It should be noted that the write permission check is to implement the check of the write operation permission. It is understandable that in order to ensure communication security, it is necessary to set the read and write permissions of the virtual machine for the target shared area. In this way, only virtual machines with write permissions can write data to the target shared area, avoiding those virtual machines without write permissions from arbitrarily writing data to the target shared area, thereby affecting communication security. In some embodiments, when different shared areas are allocated to multiple virtual machines, there can be only one write permission owner for each shared area, and there can be one or more read permission owners.
[0045] In some embodiments, read and write permissions may be allocated in advance to all participants who can access the target shared area, thereby setting up a virtual machine with write permissions for the target shared area. Further, a virtual machine with read permissions for the target shared area may also be set up.
[0046] In the embodiment of the present application, performing a write permission check on the first virtual machine can prevent virtual machines that do not have write permission from arbitrarily writing data to the target shared area, thereby affecting communication security.
[0047] In some embodiments of the present application, the target shared area stores a data area description table, wherein the data area description table records a virtual machine identifier of a write permission owner;
[0048] Identify the virtual machines that have write permissions to the target shared area, including:
[0049] The data area description table of the target shared area is searched to determine the virtual machine identifier of the write permission owner; and the virtual machine indicated by the virtual machine identifier of the write permission owner is determined as the virtual machine having the write permission.
[0050] It should be noted that the virtual machine identifier can be a unique identifier of the virtual machine in the above-mentioned target electronic device, so that the unique virtual machine can be distinguished and located through the virtual machine identifier. In this embodiment, by setting a data area description table in the target shared area, and using the data area description table to record the relevant virtual machine identifier, write permission verification is achieved. In some embodiments, a corresponding field can be set in the data area description table to record the virtual machine identifier of the write permission owner. In this way, when determining the virtual machine identifier of the write permission owner, it is only necessary to search the data area description table according to the field.
[0051] In some embodiments, the target shared area can be divided into two parts, one part is used to store the aforementioned data area description table, and the other part is used to wait for the writing of the target data. For example, the first part is used as the general table area, which contains multiple data area description tables. The second part is used as a sub-data area, and the number is multiple. And each sub-data area corresponds to a unique data area description table. A data area description table and its corresponding sub-data area are used as a shared area and are allocated to the virtual machine for use. In some embodiments, the offset address of its sub-data area can also be recorded in the data area description table. In this way, the starting address and offset address of the general table area can be used to determine the starting address of the corresponding sub-data area.
[0052] In the embodiment of the present application, by setting a data area description table in the target shared area, the write permission check can be completed quickly.
[0053] In some embodiments of the present application, the write operation verification includes: writing data size verification;
[0054] Perform write verification based on the write verification strategy in the read-write verification strategy, including:
[0055] Determine the valid data space that the target shared area can carry; perform data size verification on the target data based on the valid data space, and determine that the write data size verification has passed when the data size of the target data is less than or equal to the valid data space; and determine that the write data size verification has not passed when the data size of the target data is greater than the valid data space.
[0056] It should be noted that the data size check is to check the data size of the data object targeted by the write operation. It is understandable that in order to ensure communication security, the target shared area needs to be able to carry the transmitted data (i.e., target data). In this way, problems caused by insufficient space in the target shared area can be avoided.
[0057] In some embodiments, when allocating a shared area to a virtual machine, a corresponding space size may be set for it based on business needs. For example, when allocating a shared area to a virtual machine with a large data communication demand, a shared area with a larger space may be allocated. When allocating a shared area to a virtual machine with a small data communication demand, a shared area with a smaller space may be allocated.
[0058] In some embodiments, a corresponding field may be set in the aforementioned data area description table to record the effective data space that the target shared area can carry. Thus, when determining the effective data space that the target shared area can carry, it is only necessary to search the data area description table according to the field.
[0059] In some embodiments, the target shared area can be divided into two parts, one part is used to store the aforementioned data area description table, and the other part is used to wait for the writing of the target data. For example, the first part is used as the general table area, which contains multiple data area description tables. The second part is used as a sub-data area, and the number is multiple. And each sub-data area corresponds to a unique data area description table. A data area description table and its corresponding sub-data area are used as a shared area and are allocated to the virtual machine for use. At this time, the effective data space that the target shared area can carry can be regarded as the sub-data area corresponding to the data area description table.
[0060] In the embodiment of the present application, the data size check is performed on the target data, so as to avoid the problem caused by insufficient space in the target shared area.
[0061] In some embodiments of the present application, the target sharing area includes: a first area and a second area;
[0062] When the write verification passes, the target data is written to the target shared area, including:
[0063] When the write verification is passed, the business type corresponding to the write operation is determined; when the business type corresponding to the write operation is the first type, a first target area that is not occupied is determined; wherein the first target area includes the first area or the second area, and the data written by the first virtual machine to the target shared area under the first type is allowed to be read multiple times by the second virtual machine; the target data is written to the first target area, and the first target area is updated to an occupied state, and the areas in the first area and the second area except the first target area are updated to an unoccupied state.
[0064] It should be noted that the write operation of the first virtual machine is an operation when it executes a certain business. Therefore, the business type corresponding to the write operation is the business type of the business. In some embodiments, the first type can be an announcement type, and correspondingly, the target data is an announcement type of information. In this way, the announcement type message written to the target shared area allows the reader to read multiple times and can be read by multiple readers.
[0065] It is understandable that, in the case where the first virtual machine transmits data to the second virtual machine multiple times, the first virtual machine will use the newly transmitted data to update the old data in the target shared area so that the second virtual machine can read the newly transmitted data. However, in the case where the data in the target shared area has not been completely updated (there are both newly transmitted data and old data), the second virtual machine directly reads and uses these data, which is bound to cause problems because the read data is not accurate. To this end, this embodiment uses different areas in the target shared area to separate the data of two adjacent transmissions, and combines whether the area is occupied, so that when the first virtual machine writes the newly transmitted data, the second virtual machine no longer reads the area where the data is being updated. Among them, for the multiple areas divided out in the target shared area, for each area, after writing data to the area, it is updated to be occupied, and other areas are updated to be unoccupied.
[0066] For example, see Figure 2 As shown, if the write verification is passed and the business type corresponding to the current write operation is the first type, execute S201: determine whether the first area is occupied, if so, execute S202, if not, execute S203;
[0067] S202: using the first area, that is, taking the first area as the first target area;
[0068] S203: using the second area, that is, taking the second area as the first target area;
[0069] S204: Acquire information of the first target area;
[0070] S205: writing data into the first target area based on the information of the first target area;
[0071] S206: Update the occupied area mark, update the first target area to an occupied state, and update the other areas to an unoccupied state.
[0072] It is understandable that when the second virtual machine reads data in the target shared area, it can directly read data in the occupied area instead of reading data from the unoccupied area.
[0073] In some embodiments, a corresponding field may be set in the aforementioned data area description table to record the status (occupied status, unoccupied status) of each area in the target shared area. In this way, when determining whether the first area is occupied, it is only necessary to search the data area description table according to the field.
[0074] In the embodiments of the present application, possible data conflict problems can be resolved to ensure data consistency between the two parties transmitting data.
[0075] In some embodiments of the present application, writing the target data into the target shared area after the write verification passes includes:
[0076] If the write verification passes, determine the business type corresponding to the write operation; if the business type corresponding to the write operation is the second type, if the data written to the target shared area under the second type has been read by the second virtual machine, write the target data to the target shared area; wherein the data written to the target shared area by the first virtual machine under the second type is allowed to be read once by the second virtual machine.
[0077] It should be noted that the write operation of the first virtual machine is an operation when it executes a certain business. Therefore, the business type corresponding to the write operation is the business type of the business. In some embodiments, the second type can be a message type, and correspondingly, the target data is message-type information. In this way, the announcement-type message written to the target shared area is only allowed to be read once by the reader. In some embodiments, the number of readers is one, that is, point-to-point communication is realized.
[0078] It is understandable that, in the case where the first virtual machine transmits data to the second virtual machine multiple times, the first virtual machine can continue to write data to the target shared area only after the second virtual machine has finished reading the data transmitted last time, otherwise the second virtual machine will miss the data. For this reason, before writing data each time, this embodiment needs to determine whether the data written to the target shared area under the second type has been read by the second virtual machine. If so, continue to write data, otherwise keep waiting or directly end the process.
[0079] For example, if the write verification is passed and the service type corresponding to the current write operation is the second type, execute step A: determine whether the data written to the target shared area under the second type has been read by the second virtual machine, if so, execute step B, if not, execute step C; step B: write the data. Step C: end the process or wait for the target duration, and execute step A repeatedly within the target duration.
[0080] In the embodiment of the present application, the target data may be written into the target shared area only if the data written into the target shared area under the second type has been read by the second virtual machine, thereby solving the problem of missed reading of the second virtual machine.
[0081] In some embodiments of the present application, the target shared area stores a data area description table, wherein the data area description table records a first number of times that the first virtual machine writes data to the target shared area and a second number of times that the second virtual machine reads data from the target shared area under the second type;
[0082] When the service type corresponding to the current write operation is the second type, if the data written by the first virtual machine to the target shared area under the second type has been read by the second virtual machine, writing the target data to the target shared area includes:
[0083] When the business type corresponding to this write operation is the second type, determine the numerical relationship between the first number and the second number in the data area description table; when the first number is equal to the second number, write the target data into the target shared area and add one to the first number.
[0084] It should be noted that, for the data area description table, reference can be made to the data area description table in the above embodiment, which will not be repeated here. It can be understood that in this embodiment, the data area description table is used to record the first number and the second number. The first number can be the cumulative number of times the first virtual machine writes data to the target shared area under the second type. The second number can be the second number of times the second virtual machine reads data from the target shared area under the second type. For example, when the second type is a message type, and correspondingly, the target data is message-type information, the first number is the cumulative number of times the first virtual machine writes message-type information to the target shared area. The second number is the cumulative number of times the second virtual machine reads message-type information from the target shared area. It is worth noting that the values of the first number and the second number change dynamically according to actual conditions.
[0085] In view of this, through the numerical relationship between the first number and the second number, it is possible to quickly determine whether the data written by the first virtual machine to the target shared area under the second type has been read by the second virtual machine. Among them, if the first number is equal to the second number, it means that the data written by the first virtual machine to the target shared area under the second type has been read by the second virtual machine. If the first number is greater than the second number, it means that the data written by the first virtual machine to the target shared area under the second type has not been read by the second virtual machine.
[0086] For example, see Figure 3 As shown, when the write verification is passed and the business type corresponding to this write operation is the second type, execute S301: determine whether the read index (equivalent to the second number) and the write index (equivalent to the first number) are the same, if so, execute S302, if not, execute S303; S302: write data; S303: end the process.
[0087] In some embodiments, if the write verification is passed and the service type corresponding to the current write operation is the second type, data writing can also be implemented according to the blocking mechanism. For example, the process can be similar to Figure 3 The processes shown are basically the same, except for the specific processing method when the judgment is no during the execution of S301. When the judgment is no, it will wait for the target time and execute S301 in a loop within the target time.
[0088] In an embodiment of the present application, a data area description table can be set up, and the first number of times the first virtual machine under the second type writes data to the target shared area and the second number of times the second virtual machine reads data from the target shared area are recorded in the data area description table, and then with the help of the first number and the second number, it is possible to quickly determine whether the data written to the target shared area by the first virtual machine under the second type has been read by the second virtual machine.
[0089] In order to avoid data in the target shared area from being tampered with or causing security issues caused by bit jumps, in some embodiments of the present application, after writing the target data into the target shared area, the method further includes:
[0090] Determine the data length of the target data; generate length check information for checking the data length based on the target data; write the data length and the length check information corresponding to the target data into the target shared area, so that after the second virtual machine reads the target shared area, the data length is checked based on the length check information.
[0091] It should be noted that the length check information can be generated based on any check algorithm, for example, the length check information can be generated by a CRC (Cyclic Redundancy Check) algorithm. In this way, after reading the target shared area, the second virtual machine uses the data length, target data, and length check information recorded therein to perform a check.
[0092] In the embodiment of the present application, adding data length and length check information in the target shared area can avoid security issues caused by data tampering or bit jumps in the target shared area.
[0093] For ease of understanding, the method for inter-virtual machine communication provided by the present application is described below with a specific example. The method is applied to the target electronic device. For the target electronic device, please refer to the description in the above embodiment. Here, a section of physical memory can be reserved in the initialization stage of the virtualization environment as a shared area of the virtual machine to provide underlying device support for subsequent communication. For example, in the initialization stage of the virtualization environment, the e820 table information provided by the BIOS (Basic Input Output System) is scanned, and according to the configuration requirements of the user software, a section of available memory of appropriate length is selected and marked as a reserved state. The virtualization layer starts normally, because the aforementioned section of available memory is marked as a reserved state. Therefore, the reserved memory will not be automatically allocated or used by the system. When creating a virtual machine, the access rights of the above reserved memory are allocated to each virtual machine, and this section of physical memory is mapped to an agreed virtual address, so that this section of memory becomes a section of physical memory shared between each virtual machine.
[0094] like Figure 4 As shown, this reserved memory can store data in a fixed format. That is, the storage format of the shared memory area is divided into two parts: a fixed-length general header and a variable-length sub-data area. The general header has a fixed length and contains the description information of a fixed number of sub-data areas (i.e., the data area description table). The format length of each description information is fixed; the starting address, length, and content of the sub-data area are not fixed and are determined according to the corresponding description information in the general header. Each sub-data area contains a data header and a data payload. The data header can describe the dynamic information of the data being transmitted this time. According to the organization method, it is divided into an announcement type and a message type. For the announcement type shared memory, the formats of areas A and B are the same, both of which are data header + payload; for the message type, it only contains one piece of data header + payload.
[0095] Each data area description table can be pre-configured according to business needs. For example, virtual machine A needs to transmit data to virtual machine D via sub-data area 5, and the transmitted data is announcement-type information. Then it is necessary to configure relevant information in the data area description table corresponding to sub-data area 5. For example, the itm_b field of the data area description table is configured to 0, the itm_c field is configured to the virtual machine identifier of virtual machine A, and the itm_d field is configured to the virtual machine identifier of virtual machine D.
[0096] Combination Figure 5 The process of writing announcement-type information to the virtual machine is continued with examples. After the writing of the announcement begins, S501 is first executed to determine whether the parameters are legal. If so, S502 is executed, otherwise the writing of the announcement ends. The process of determining whether the parameters are legal is the same as the process of writing permission verification in the above embodiment. Here, the itm_c field in the data area description table is used to implement the write permission verification. S502: Calculate verification. This process is the same as the process of writing data size verification in the above embodiment. Here, the itm_f field in the data area description table is used to implement the write permission verification. After passing the data size verification, S503 to S507 are executed. Among them, the process of S503 to S507 is the same as Figure 2 The process of S201 to S205 is similar to that shown in the figure. The difference is that here, the area is divided into area A and area B instead of the first area and the second area to determine whether it is idle (unoccupied area is considered idle). The specific process is not repeated here. S508, write the actual length of the data written this time and the verification information to the field of the corresponding sub-data area. For example, you can write Figure 4 The actual length is written into the itm_len field, and the check information is written into the itm_chk field. S509, update the occupied mark (itm_g field). For example, when writing data to area A this time, it is necessary to update the itm_g field to the area A mark to indicate that area A is occupied and area B is idle.
[0097] Combination Figure 6 The process of writing message-type information to the virtual machine is described by way of example. After the message writing starts, S601 to S602 are first executed. This process is the same as S501 to S502 and will not be described here. Then S603 to S604 are executed. This process is the same as S501 to S502. Figure 3 S301 to S302 are the same and will not be described here. Figure 5 Same as S508. S606, Figure 4 The field value of the wr_g field in the data description table is increased by one.
[0098] In the embodiment of the present application, the virtual machines of both communicating parties are given the right to directly access the physical memory, which has extremely high communication efficiency, and the data producer / consumer directly completes the data access operation, and no additional data transfer load is generated. A data consistency mechanism is set up to ensure the stability of user applications in multiple virtual machines accessing data in the shared memory area. In addition, in a virtualized environment, the physical memory of the device is only for internal use and has no external exposure channels, which is more secure.
[0099] In some embodiments, a unified interface may be provided for service calls, without requiring service parties to share data types (service types). The process of inter-virtual machine communication through service calls may be as follows: Figure 7 As shown, after writing starts, execute S701 to determine whether the parameters are legal. If so, execute S702. If not, write and end directly. In the process of determining whether the parameters are legal, different judgment criteria can be set according to different services, which will not be described in detail here. S702, determine whether the current service has write permission. If so, execute S703. If not, write and end directly. S703, determine whether the current communication is of announcement type. If so, execute S704. If not, execute S705. S704, execute the announcement type write process (the specific process is the same as Figure 5 The process is the same as shown in the figure). S705, determine whether the current type is a message type, if so, execute S706, if not, directly write and end. S706, determine whether to select blocking mode, if so, execute S707, if not, execute S708. S707, execute the message type blocking write process. S708, execute the message type write process (the specific process is the same as Figure 6 The process is the same as shown).
[0100] Taking the application to the second virtual machine as an example, the present application also provides a method for communication between virtual machines, such as Figure 8 As shown, the method includes
[0101] S801: When the second virtual machine receives target data transmitted by the first virtual machine, perform a read check based on a read check strategy in the read-write check strategy; wherein the read-write check strategy includes a check strategy determined for the read and write operations of the virtual machine;
[0102] S802: When the read verification is passed, target data is read from a target shared area, where the target shared area is a physical storage area shared by a first virtual machine and a second virtual machine in a target electronic device.
[0103] It should be noted that in this embodiment, the second virtual machine, as the party reading data, performs a read check after the first virtual machine writes the target data, and reads the target data from the target shared area after passing the read check. Among them, the process of the first virtual machine writing data to the target shared area, the first virtual machine, the target electronic device, and the target shared area can be referred to the above embodiments, and will not be repeated here.
[0104] In the embodiment of the present application, compared with the method of transmitting data between virtual machines by means of the traditional virtual network topology structure, the communication method provided by the present application is more efficient and more real-time. Furthermore, since the verification link is performed before reading the data, the security of communication between virtual machines can be improved.
[0105] In some embodiments of the present application, the read check includes: a read permission check;
[0106] Performing a read check based on a read check policy in a read-write check policy includes: determining a virtual machine that has read permission for a target shared area; performing a read permission check on a second virtual machine based on the virtual machine that has read permission, and determining that the read permission check has passed if the second virtual machine is a virtual machine that has read permission, and determining that the read permission check has not passed if the second virtual machine does not belong to a virtual machine that has read permission.
[0107] It should be noted that the read permission check is to implement the check of the read operation permission. It is understandable that in order to ensure communication security, it is necessary to set the read and write permissions of the virtual machine for the target shared area. In this way, only virtual machines with read permissions can read data from the target shared area, preventing virtual machines without read permissions from arbitrarily reading data in the target shared area, thereby affecting communication security. In some embodiments, when different shared areas are allocated to multiple virtual machines, there can be only one write permission owner for each shared area, and there can be one or more read permission owners.
[0108] It is worth noting that the process of reading permission verification is similar to the process and setting of writing permission verification in the above embodiment, and will not be described in detail here.
[0109] In the embodiment of the present application, the read permission check is performed on the second virtual machine, which can prevent those virtual machines that do not have the read permission from arbitrarily reading the data in the target shared area, thereby affecting the communication security.
[0110] In some embodiments of the present application, the target shared area stores a data area description table, wherein the data area description table records a virtual machine identifier of a read permission owner;
[0111] Determining a virtual machine having read permission for the target shared area includes: searching a data area description table of the target shared area to determine a virtual machine identifier of a read permission owner; and determining a virtual machine indicated by the virtual machine identifier of the read permission owner as a virtual machine having read permission.
[0112] It should be noted that the process of using the data area description table to determine the virtual machine with read permission is similar to the process of using the data area description table to determine the virtual machine with write permission in the above embodiment, and will not be described in detail here.
[0113] In the embodiment of the present application, by setting a data area description table in the target shared area, the read permission check can be completed quickly.
[0114] In some embodiments of the present application, the target sharing area includes: a first area and a second area;
[0115] When the read verification is passed, the target data is read from the target shared area, including: when the read verification is passed, determining the business type corresponding to the current read operation; when the business type corresponding to the current write operation is the first type, determining the second target area that is occupied; wherein the second target area includes the first area or the second area, and the data written by the first virtual machine to the target shared area under the first type is allowed to be read multiple times by the second virtual machine; and reading the target data from the second target area.
[0116] In some embodiments of the present application, when a read check is passed, target data is read from a target shared area, including: when the read check is passed, determining the business type corresponding to the current read operation; when the business type corresponding to the current read operation is a second type, if the data written to the target shared area by the first virtual machine under the second type is not fully read by the second virtual machine, then reading the target data from the target shared area; wherein, the data written to the target shared area by the first virtual machine under the second type is allowed to be read once by the second virtual machine.
[0117] In some embodiments of the present application, the target shared area stores a data area description table, wherein the data area description table records a first number of times that the first virtual machine writes data to the target shared area and a second number of times that the second virtual machine reads data from the target shared area under the second type;
[0118] In a case where the business type corresponding to this read operation is the second type, if the data written by the first virtual machine to the target shared area under the second type is not fully read by the second virtual machine, the target data is read from the target shared area, including: in a case where the business type corresponding to the current read operation is the second type, determining the numerical relationship between the first number and the second number in the data area description table; in a case where the first number is greater than the second number, reading the target data from the target shared area and adding one to the second number.
[0119] It should be noted that, because the data written by the first virtual machine to the target shared area under the second type is allowed to be read once by the second virtual machine, each time the second virtual machine reads the data written by the first virtual machine, it uses a full read method to process it, rather than reading it multiple times. In some embodiments, when the second virtual machine reads the target data from the target shared area, it can read all the data content in the target shared area and use all the read data content as the target data.
[0120] In some embodiments of the present application, after reading the target data from the target shared area, the method further includes:
[0121] Determine the data length and length verification information of the target data; wherein the length verification information is verification information generated by the first virtual machine based on the target data for verifying the data length; verify the target data based on the length verification information.
[0122] It is understood that the process of the first virtual machine writing data to the first area or the second area and the first type of content can be referred to the above embodiments, and will not be repeated here. It is understood that after writing the data, the second virtual machine will read the data therein. For example, corresponding to Figure 5 The process of writing data as shown in FIG. 1 and the process of reading data therein by the second virtual machine can be as follows: Fig. 9 As shown, the process of S901 to S910 corresponds to the process of S501 to S509, S501 to S509 are used to implement data writing, and S901 to S910 are used to implement data reading after writing, and the similarities are not repeated here.
[0123] For example, corresponding to Figure 6 The process of writing data as shown in FIG. 1 and the process of reading data therein by the second virtual machine can be as follows: Fig.10 As shown, the process of S1001 to S1006 corresponds to the process of S601 to S606, S601 to S606 are used to implement data writing, and S1001 to S1006 are used to implement data reading after writing, and the similarities are not repeated here.
[0124] For example, corresponding to Figure 7 The process of writing data as shown in FIG. 1 and the process of reading data therein by the second virtual machine can be as follows: Fig.11 As shown, the process of S1101 to S1107 corresponds to the process of S701 to S708, S701 to S708 are used to implement data writing, and S1101 to S1107 are used to implement data reading after writing, and the similarities are not repeated here.
[0125] Exemplary Devices
[0126] Accordingly, the embodiment of the present application also provides a device for communication between virtual machines, which is applied to a first virtual machine, such as Fig.12 As shown, the device for communication between virtual machines includes:
[0127] A write verification module 1201 is used to perform write verification based on a write verification strategy in a read-write verification strategy when the first virtual machine transmits target data to the second virtual machine; wherein the read-write verification strategy includes a verification strategy determined for the read and write operations of the virtual machine; a write module 1202 is used to write the target data to a target shared area for reading by the second virtual machine when the write verification passes, wherein the target shared area is a physical storage area shared by the first virtual machine and the second virtual machine in the target electronic device.
[0128] In some embodiments, the write check includes: a write permission check; a write check module 1201, including: a write permission unit, used to determine a virtual machine that has write permission for a target shared area; a write check unit, used to perform a write permission check on a first virtual machine based on the virtual machine that has write permission, and if the first virtual machine is a virtual machine that has write permission, determine that the write permission check has passed, and if the first virtual machine is not a virtual machine that has write permission, determine that the write permission check has not passed.
[0129] In some embodiments, the target shared area stores a data area description table, wherein the data area description table records the virtual machine identifier of the write permission holder; the write permission unit is specifically used to search the data area description table of the target shared area to determine the virtual machine identifier of the write permission holder; and the virtual machine indicated by the virtual machine identifier of the write permission holder is determined as the virtual machine with write permission.
[0130] In some embodiments, the write operation verification includes: write data size verification; a write verification module 1201 is specifically used to determine the effective data space that the target shared area can carry; based on the effective data space, the data size verification of the target data is performed, and when the data size of the target data is less than or equal to the effective data space, it is determined that the write data size verification has passed; when the data size of the target data is larger than the effective data space, it is determined that the write data size verification has not passed.
[0131] In some embodiments, the target sharing area includes: a first area and a second area;
[0132] The write module 1202 is specifically used to determine the business type corresponding to the current write operation when the write verification passes; when the business type corresponding to the current write operation is the first type, determine the first target area that is not occupied; wherein the first target area includes the first area or the second area, and the data written by the first virtual machine to the target shared area under the first type is allowed to be read multiple times by the second virtual machine; write the target data to the first target area, and update the first target area to an occupied state, and update the areas in the first area and the second area except the first target area to an unoccupied state.
[0133] In some embodiments, when the write verification is passed, the write module 1202 is specifically used to determine the business type corresponding to the current write operation when the write verification is passed; when the business type corresponding to the current write operation is the second type, if the data written to the target shared area under the second type has been read by the second virtual machine, the target data is written to the target shared area; wherein the data written to the target shared area by the first virtual machine under the second type is allowed to be read once by the second virtual machine.
[0134] In some embodiments, the target shared area stores a data area description table, wherein the data area description table records a first number of times the first virtual machine writes data to the target shared area under the second type and a second number of times the second virtual machine reads data from the target shared area; when the business type corresponding to the current write operation is the second type, if the data written to the target shared area by the first virtual machine under the second type have been read by the second virtual machine, the target data is written to the target shared area, including: when the business type corresponding to the current write operation is the second type, determining the numerical relationship between the first number and the second number in the data area description table; when the first number is equal to the second number, writing the target data to the target shared area and adding one to the first number.
[0135] In some embodiments, the device also includes: a data internal verification module, used to determine the data length of the target data; generate length verification information for verifying the data length based on the target data; write the data length and the length verification information corresponding to the target data into the target shared area, so that after the second virtual machine reads the target shared area, the data length is verified based on the length verification information.
[0136] Accordingly, the embodiment of the present application also provides a device for communication between virtual machines, which is applied to a second virtual machine, such as Fig.13 As shown, the device for communication between virtual machines includes:
[0137] A read verification module 1301 is used to perform a read verification based on a read verification strategy in a read-write verification strategy when the second virtual machine receives target data transmitted by the first virtual machine; wherein the read-write verification strategy includes a verification strategy determined for the read and write operations of the virtual machine; a read module 1302 is used to read the target data from the target shared area when the read verification passes, wherein the target shared area is a physical storage area shared by the first virtual machine and the second virtual machine in the target electronic device.
[0138] In some embodiments, the read check includes: a read permission check; a read check module 1301, including: a read permission unit, used to determine a virtual machine that has read permission for a target shared area; a read check unit, used to perform a read permission check on a second virtual machine based on the virtual machine that has read permission, and if the second virtual machine is a virtual machine that has read permission, determine that the read permission check has passed, and if the second virtual machine is not a virtual machine that has read permission, determine that the read permission check has not passed.
[0139] In some embodiments, the target shared area stores a data area description table, wherein the data area description table records the virtual machine identifier of the read permission holder; the read permission unit is specifically used to search the data area description table of the target shared area to determine the virtual machine identifier of the read permission holder; and the virtual machine indicated by the virtual machine identifier of the read permission holder is determined as the virtual machine with read permission.
[0140] In some embodiments, the target sharing area includes: a first area and a second area;
[0141] The reading module 1302 is specifically used to determine the business type corresponding to the current read operation when the read verification is passed; when the business type corresponding to the current write operation is the first type, determine the second target area that is occupied; wherein the second target area includes the first area or the second area, and the data written by the first virtual machine to the target shared area under the first type is allowed to be read multiple times by the second virtual machine; and read the target data from the second target area.
[0142] In some embodiments, the reading module 1302 is specifically used to determine the business type corresponding to the current read operation when the read verification passes; when the business type corresponding to the current read operation is the second type, if the data written to the target shared area by the first virtual machine under the second type is not fully read by the second virtual machine, the target data is read from the target shared area; wherein, the data written to the target shared area by the first virtual machine under the second type is allowed to be read once by the second virtual machine.
[0143] In some embodiments, the target shared area stores a data area description table, wherein the data area description table records a first number of times the first virtual machine writes data to the target shared area and a second number of times the second virtual machine reads data from the target shared area under the second type;
[0144] In a case where the business type corresponding to this read operation is the second type, if the data written by the first virtual machine to the target shared area under the second type is not fully read by the second virtual machine, the target data is read from the target shared area, including: in a case where the business type corresponding to the current read operation is the second type, determining the numerical relationship between the first number and the second number in the data area description table; in a case where the first number is greater than the second number, reading the target data from the target shared area and adding one to the second number.
[0145] In some embodiments, the device also includes: a data internal verification module, used to determine the data length and length verification information of the target data; wherein the length verification information is verification information generated by the first virtual machine based on the target data for verifying the data length; and the target data is verified based on the length verification information.
[0146] The device for inter-virtual machine communication provided in this embodiment belongs to the same application concept as the method for inter-virtual machine communication provided in the above embodiments of this application, and can execute the method for inter-virtual machine communication provided in any of the above embodiments of this application, and has the corresponding functional modules and beneficial effects of the execution method. For technical details not fully described in this embodiment, please refer to the specific processing content of the method for inter-virtual machine communication provided in the above embodiments of this application, and will not be repeated here.
[0147] It should be understood that the modules in the above devices can be implemented in the form of a processor calling software. For example, the device includes a processor, the processor is connected to a memory, and instructions are stored in the memory. The processor calls the instructions stored in the memory to implement any of the above methods or realize the functions of each unit of the device, wherein the processor can be a general-purpose processor, such as a CPU or a microprocessor, etc., and the memory can be a memory in the device or a memory outside the device. Alternatively, the unit in the device can be implemented in the form of a hardware circuit, and the functions of some or all units can be realized by designing the hardware circuit. The hardware circuit can be understood as one or more processors; for example, in one implementation, the hardware circuit is an ASIC, and the functions of some or all of the above units are realized by designing the logical relationship of the components in the circuit; for another example, in another implementation, the hardware circuit can be implemented by PLD, taking FPGA as an example, which can include a large number of logic gate circuits, and the connection relationship between the logic gate circuits is configured by a configuration file, so as to realize the functions of some or all of the above units. All units of the above devices can be implemented in the form of a processor calling software, or in the form of a hardware circuit, or in part by a processor calling software, and the remaining part is implemented in the form of a hardware circuit.
[0148] In an embodiment of the present application, a processor is a circuit with the ability to process signals. In one implementation, the processor may be a circuit with the ability to read and run instructions, such as a CPU, a microprocessor, a GPU, or a DSP; in another implementation, the processor may implement certain functions through the logical relationship of a hardware circuit, and the logical relationship of the hardware circuit is fixed or reconfigurable, such as a hardware circuit implemented by an ASIC or PLD, such as an FPGA. In a reconfigurable hardware circuit, the process of the processor loading a configuration document to implement the hardware circuit configuration can be understood as the process of the processor loading instructions to implement the functions of some or all of the above units. In addition, it can also be a hardware circuit designed for artificial intelligence, which can be understood as an ASIC, such as an NPU, TPU, DPU, etc.
[0149] It can be seen that each unit in the above device can be one or more processors (or processing circuits) configured to implement the above method, such as: CPU, GPU, NPU, TPU, DPU, microprocessor, DSP, ASIC, FPGA, or a combination of at least two of these processor forms.
[0150] In addition, all or part of the units in the above device can be integrated together, or can be implemented independently. In one implementation, these units are integrated together and implemented in the form of a SOC. The SOC may include at least one processor for implementing any of the above methods or implementing the functions of each unit of the device. The type of the at least one processor may be different, for example, including a CPU and an FPGA, a CPU and an artificial intelligence processor, a CPU and a GPU, etc.
[0151] Exemplary Electronic Devices
[0152] The present application embodiment provides an electronic device, see Fig.14 As shown, the device includes:
[0153] Memory 1400 and processor 1410;
[0154] The memory 1400 is connected to the processor 1410 and is used to store programs;
[0155] The processor 1410 is configured to implement the method for communication between virtual machines disclosed in any of the above embodiments by running the program stored in the memory 1400 .
[0156] Specifically, the electronic device may further include: a bus, a communication interface 1420 , an input device 1430 and an output device 1440 .
[0157] The processor 1410, the memory 1400, the communication interface 1420, the input device 1430 and the output device 1440 are connected to each other via a bus.
[0158] A bus may include a pathway that transfers information between components of a computer system.
[0159] The processor 1410 may be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, etc., or an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the scheme of the present invention. It may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0160] The processor 1410 may include a main processor, and may also include a baseband chip, a modem, and the like.
[0161] The memory 1400 stores a program for executing the technical solution of the present invention, and may also store an operating system and other key services. Specifically, the program may include a program code, and the program code includes a computer operation instruction. More specifically, the memory 1400 may include a read-only memory (ROM), other types of static storage devices that can store static information and instructions, a random access memory (RAM), other types of dynamic storage devices that can store information and instructions, a disk storage, a flash, and the like.
[0162] The input device 1430 may include a device for receiving data and information input by a user, such as a keyboard, a mouse, a camera, a scanner, a light pen, a voice input device, a touch screen, a pedometer, or a gravity sensor.
[0163] Output device 1440 may include devices that allow information to be output to a user, such as a display screen, printer, speaker, etc.
[0164] The communication interface 1420 may include any transceiver or the like to communicate with other devices or communication networks, such as Ethernet, a radio access network (RAN), a wireless local area network (WLAN), etc.
[0165] The processor 1410 executes the program stored in the memory 1400 and calls other devices, which can be used to implement each step of any method for communication between virtual machines provided in the above embodiments of the present application.
[0166] Exemplary computer program products and storage media
[0167] In addition to the above-mentioned methods and devices, an embodiment of the present application may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the method for inter-virtual machine communication according to various embodiments of the present application described in any of the above embodiments of this specification.
[0168] The computer program product may be written in any combination of one or more programming languages to write program codes for performing the operations of the embodiments of the present application, including object-oriented programming languages, such as Java, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0169] In addition, an embodiment of the present application may also be a storage medium on which a computer program is stored, and the computer program is executed by a processor to execute the steps of the method for communication between virtual machines according to various embodiments of the present application described in any of the above embodiments of this specification.
[0170] For the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0171] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0172] The steps in the methods of each embodiment of the present application can be adjusted in order, combined and deleted according to actual needs, and the technical features recorded in each embodiment can be replaced or combined.
[0173] The modules and sub-modules in the devices and terminals of the various embodiments of the present application can be combined, divided and deleted according to actual needs.
[0174] In the several embodiments provided in the present application, it should be understood that the disclosed terminals, devices and methods can be implemented in other ways. For example, the terminal embodiments described above are only schematic, for example, the division of modules or submodules is only a logical function division, and there may be other division methods in actual implementation, for example, multiple submodules or modules can be combined or integrated into another module, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0175] The modules or submodules described as separate components may or may not be physically separated, and the components of the modules or submodules may or may not be physical modules or submodules, that is, they may be located in one place, or they may be distributed on multiple network modules or submodules. Some or all of the modules or submodules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0176] In addition, each functional module or submodule in each embodiment of the present application may be integrated into one processing module, or each module or submodule may exist physically separately, or two or more modules or submodules may be integrated into one module. The above-mentioned integrated modules or submodules may be implemented in the form of hardware or in the form of software functional modules or submodules.
[0177] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0178] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly by hardware, software units executed by a processor, or a combination of the two. The software units may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0179] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0180] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for communication between virtual machines, characterized in that: Applied to a first virtual machine, the method comprises: When the first virtual machine transmits target data to the second virtual machine, write verification is performed based on a write verification strategy in the read-write verification strategy; wherein the read-write verification strategy includes a verification strategy determined for the read and write operations of the virtual machine; When the write verification is passed, the target data is written into a target shared area for reading by the second virtual machine, wherein the target shared area is a physical storage area shared by the first virtual machine and the second virtual machine in the target electronic device.
2. The method according to claim 1, characterized in that The write verification includes: write permission verification; Perform write verification based on the write verification strategy in the read-write verification strategy, including: Determine a virtual machine that has write permission for the target shared area; A write permission check is performed on the first virtual machine based on a virtual machine with write permission. If the first virtual machine belongs to a virtual machine with write permission, it is determined that the write permission check has passed; if the first virtual machine does not belong to a virtual machine with write permission, it is determined that the write permission check has not passed.
3. The method according to claim 2, characterized in that The target shared area stores a data area description table, wherein the data area description table records a virtual machine identifier of a write permission owner; Determine a virtual machine that has write permission for the target shared area, including: Searching the data area description table of the target shared area to determine the virtual machine identifier of the write permission owner; The virtual machine indicated by the virtual machine identifier of the write permission owner is determined as the virtual machine having the write permission.
4. The method according to claim 1, characterized in that: The write operation verification includes: writing data size verification; Perform write verification based on the write verification strategy in the read-write verification strategy, including: Determine the effective data space that the target shared area can carry; A data size check is performed on the target data based on the valid data space. When the data size of the target data is less than or equal to the valid data space, it is determined that the write data size check has passed; when the data size of the target data is greater than the valid data space, it is determined that the write data size check has not passed.
5. The method according to any one of claims 1 to 4, characterized in that: The target sharing area includes: a first area and a second area; When the write verification is passed, writing the target data into the target shared area includes: If the write verification is passed, determine the service type corresponding to the write operation; In the case where the business type corresponding to the current write operation is the first type, determining a first target area that is not occupied; wherein the first target area includes the first area or the second area, and data written by the first virtual machine to the target shared area under the first type is allowed to be read multiple times by the second virtual machine; The target data is written into the first target area, and the first target area is updated to be in an occupied state, and areas other than the first target area in the first area and the second area are updated to be in an unoccupied state.
6. The method according to any one of claims 1 to 4, characterized in that: When the write verification is passed, writing the target data into the target shared area includes: If the write verification is passed, determine the service type corresponding to the write operation; When the business type corresponding to this write operation is the second type, if the data written to the target shared area under the second type has been read by the second virtual machine, the target data is written to the target shared area; wherein, the data written to the target shared area by the first virtual machine under the second type is allowed to be read once by the second virtual machine.
7. The method according to claim 6, characterized in that The target shared area stores a data area description table, wherein the data area description table records a first number of times that the first virtual machine writes data to the target shared area and a second number of times that the second virtual machine reads data from the target shared area under the second type; When the service type corresponding to the current write operation is the second type, if the data written by the first virtual machine to the target shared area under the second type has been read by the second virtual machine, writing the target data to the target shared area includes: When the service type corresponding to the current write operation is the second type, determining a numerical relationship between the first number and the second number in the data area description table; When the first number is equal to the second number, the target data is written into the target shared area, and the first number is incremented by one.
8. The method according to claim 1, characterized in that After writing the target data into the target shared area, the method further includes: Determining the data length of the target data; Generating length verification information for verifying the length of the data based on the target data; The data length and the length check information are written into the target shared area corresponding to the target data, so that after the second virtual machine reads the target shared area, the data length is checked based on the length check information.
9. A method for communication between virtual machines, characterized in that: Applied to a second virtual machine, the method comprises When the second virtual machine receives the target data transmitted by the first virtual machine, a read check is performed based on a read check strategy in the read-write check strategy; wherein the read-write check strategy includes a check strategy determined for the read and write operations of the virtual machine; In a case where the read verification passes, the target data is read from the target shared area, wherein the target shared area is a physical storage area shared by the first virtual machine and the second virtual machine in the target electronic device.
10. The method according to claim 9, characterized in that The read verification includes: read permission verification; Perform read verification based on the read verification strategy in the read-write verification strategy, including: Determine a virtual machine that has read permission for the target shared area; A read permission check is performed on the second virtual machine based on the virtual machine with read permission. If the second virtual machine belongs to the virtual machine with read permission, it is determined that the read permission check has passed; if the second virtual machine does not belong to the virtual machine with read permission, it is determined that the read permission check has not passed.
11. The method according to claim 10, characterized in that The target shared area stores a data area description table, wherein the data area description table records a virtual machine identifier of a read permission owner; Determining a virtual machine that has read permission for the target shared area includes: Searching the data area description table of the target shared area to determine the virtual machine identifier of the read permission owner; The virtual machine indicated by the virtual machine identifier of the read permission holder is determined as the virtual machine having the read permission.
12. The method according to any one of claims 9 to 11, characterized in that: The target sharing area includes: a first area and a second area; In the case where the read verification is passed, reading the target data from the target shared area includes: If the read check is passed, determine the service type corresponding to the read operation; In the case where the business type corresponding to the current write operation is the first type, determining that the second target area is occupied; wherein the second target area includes the first area or the second area, and the data written by the first virtual machine to the target shared area under the first type is allowed to be read multiple times by the second virtual machine; The target data is read from the second target area.
13. The method according to any one of claims 9 to 11, characterized in that: In the case where the read verification is passed, reading the target data from the target shared area includes: If the read check is passed, determine the service type corresponding to the read operation; When the business type corresponding to this read operation is the second type, if the data written to the target shared area by the first virtual machine under the second type is not fully read by the second virtual machine, the target data is read from the target shared area; wherein, the data written to the target shared area by the first virtual machine under the second type is allowed to be read once by the second virtual machine.
14. The method according to claim 13, characterized in that The target shared area stores a data area description table, wherein the data area description table records a first number of times that the first virtual machine writes data to the target shared area and a second number of times that the second virtual machine reads data from the target shared area under the second type; In a case where the service type corresponding to the current read operation is the second type, if the data written by the first virtual machine to the target shared area under the second type is not all read by the second virtual machine, reading the target data from the target shared area includes: When the service type corresponding to the current read operation is the second type, determining a numerical relationship between the first number and the second number in the data area description table; When the first number is greater than the second number, the target data is read from the target shared area, and the second number is incremented by one.
15. The method according to claim 9, characterized in that After reading the target data from the target shared area, the method further includes: Determine the data length and length check information of the target data; wherein the length check information is check information generated by the first virtual machine based on the target data and used to check the data length; The target data is verified based on the length verification information.
16. An electronic device, characterized in that: including memory and processor; The memory is connected to the processor and is used to store programs; The processor is used to implement the method for communication between virtual machines as described in any one of claims 1 to 8 or any one of claims 9 to 15 by running the program in the memory.
17. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the method for communication between virtual machines as claimed in any one of claims 1 to 8 or any one of claims 9 to 15 is implemented.
18. A computer program product, characterized in that include: A computer program, wherein when the computer program is executed by a processor, the method for inter-virtual machine communication as claimed in any one of claims 1 to 8 or any one of claims 9 to 15 is implemented.
Citation Information
Cited By
Distributed transaction consistency processing method, system, equipment and medium
CN120872977A