Communication method, electronic device, vehicle and storage medium

By using global routing tables and device virtualization network technology in virtual machine communication in the smart cockpit field, the problem of insufficient security in shared memory communication between virtual machines is solved, and safe and accurate communication between virtual machines is achieved.

CN118474027BActive Publication Date: 2024-10-29BYD CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410912636.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-09
Publication Date
2024-10-29
Estimated Expiration
2044-07-09

AI Technical Summary

Technical Problem

In the field of smart cockpit, when virtual machines communicate through shared memory, there is a problem of insufficient security, which may cause the virtual machine to have unauthorized access to memory data, leading to security issues.

Method used

By obtaining the communication data of virtual machines and performing isolation processing based on the preset global routing table, we ensure accurate routing of communication data between virtual machines and avoid multiple virtual machines accessing shared memory, using device virtualization network and Virtio technology framework. Implement communication between virtual machines to ensure security and isolation.

Benefits of technology

It improves the security and isolation of virtual machine communication, avoids malicious access and unauthorized access to virtual machines, and ensures the accuracy of communication data and the overall security of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118474027B_ABST
    Figure CN118474027B_ABST
Patent Text Reader

Abstract

The present application discloses a communication method, an electronic device, a vehicle and a storage medium for use in the field of software development technology. The method includes obtaining communication data of a first virtual machine, the communication data includes a second virtual machine as a receiving end, and the first virtual machine and the second virtual machine are isolated from each other; when the first virtual machine and the second virtual machine are different virtual machines, the communication data is sent to the second virtual machine based on a preset global routing table. Based on the preset global routing table, it can be ensured that the communication data can be correctly routed to the corresponding second virtual machine, avoiding the loss of communication data, communication data sending errors, etc., ensuring the accuracy of communication, and because it is not necessary to achieve communication through multiple virtual machines accessing shared memory, it can also avoid malicious access, unauthorized access, and malicious tampering of data in shared memory by virtual machines, thereby improving the security and isolation of the system and meeting the communication needs between different virtual machines.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of software development, and more specifically, to a communication method, an electronic device, a vehicle, and a non-volatile computer-readable storage medium. Background Art

[0002] With the continuous development of my country's automobile industry, the smart cockpit field carries more and more business scenarios. The current mainstream technical route is to build multiple virtual machines to deploy multiple operating systems. Different virtual machines interact by accessing the same shared memory.

[0003] However, when different virtual machines access the same shared memory, some virtual machines may access the memory data beyond their authority or without authorization, resulting in insufficient security during virtual machine communication. Summary of the invention

[0004] In view of this, embodiments of the present application provide a communication method, an electronic device, a vehicle, and a non-volatile computer-readable storage medium, which can improve the security of virtual machine communications.

[0005] The communication method of the present application includes: obtaining communication data of a first virtual machine, the communication data including a second virtual machine as a receiving end, and the first virtual machine and the second virtual machine are isolated from each other; when the first virtual machine and the second virtual machine are different virtual machines, sending the communication data to the second virtual machine based on a preset global routing table.

[0006] In some embodiments, the virtual machines are isolated from each other, and the global routing table includes global routing information between the main virtual machine and each child virtual machine in the virtual machines. The sending of the communication data to the second virtual machine based on a preset global routing table includes: when the first virtual machine and the second virtual machine are both child virtual machines, sending the communication data to the main virtual machine based on a preset global routing table, and forwarding the communication data to the second virtual machine through the main virtual machine; when the first virtual machine is the child virtual machine and the second virtual machine is the main virtual machine, sending the communication data to the second virtual machine based on a preset global routing table.

[0007] In some implementations, the first virtual machine and the second virtual machine communicate via the same preset process communication mechanism.

[0008] In some implementations, the process communication mechanism includes a Binder communication mechanism.

[0009] In some embodiments, the sending of the communication data to the primary virtual machine based on a preset global routing table, and forwarding of the communication data to the second virtual machine through the primary virtual machine, includes: establishing a first communication link between the first virtual machine and the primary virtual machine, and a second communication link between the second virtual machine and the primary virtual machine based on the global routing table, the address of the first virtual machine, the address of the second virtual machine, and the address of the primary virtual machine; based on the first communication link, controlling the first virtual machine to send the communication data to the primary virtual machine; based on the second communication link, controlling the primary virtual machine to forward the communication data to the second virtual machine.

[0010] In some embodiments, controlling the first virtual machine to send the communication data to the primary virtual machine based on the first communication link includes: registering a device virtualization network component in a remote call component corresponding to a preset process communication mechanism; and calling the device virtualization network component to send the communication data to the primary virtual machine through the first communication link.

[0011] In some implementations, the method further includes: when creating a virtual machine, allocating an address to the created virtual machine; and creating or updating the global routing table based on the address.

[0012] In some implementations, the method further includes: determining a target virtual machine among the virtual machines that does not include a preset process communication mechanism; and adding a component corresponding to the preset process communication mechanism in each of the target virtual machines to construct the preset process communication mechanism in each of the target virtual machines.

[0013] In some implementations, each virtual machine communicates with each other via a device virtualization network, and the device virtualization network is implemented based on the Virtio technology framework.

[0014] In some embodiments, the method further includes: when the first virtual machine and the second virtual machine are the same virtual machine, determining a target process within the same virtual machine; and transmitting the communication data to the target process based on a driver component of a preset process communication mechanism.

[0015] The electronic device of the embodiment of the present application includes a processor, which is connected to a memory; the memory stores a computer program, and the processor executes the computer program to implement instructions of the communication method described in any of the above embodiments.

[0016] The vehicle according to the embodiment of the present application includes the electronic device described in any of the above embodiments.

[0017] The non-volatile computer-readable storage medium of the embodiment of the present application includes a computer program. When the computer program is executed by a processor, the processor executes the communication method described in any of the above embodiments.

[0018] The communication method, electronic device, vehicle and non-volatile computer-readable storage medium of the embodiment of the present application obtain the communication data of the first virtual machine, the communication data includes the second virtual machine as the receiving end, the first virtual machine and the second virtual machine are isolated from each other, and the security and independence of each virtual machine are ensured; when the first virtual machine and the second virtual machine are different virtual machines, the communication data is sent to the second virtual machine based on the preset global routing table. In the communication between the first virtual machine and the second virtual machine, based on the preset global routing table, it can be ensured that the communication data can be correctly routed to the corresponding second virtual machine, avoiding the loss of communication data, communication data sending errors, etc., and ensuring the accuracy of communication. Since there is no need to achieve communication through multiple virtual machines accessing shared memory, it can also avoid malicious access, unauthorized access, and malicious tampering of data in shared memory by virtual machines, thereby improving the security and isolation of the system and meeting the communication needs between different virtual machines.

[0019] Additional aspects and advantages of the embodiments of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:

[0021] Figure 1 is a schematic diagram of the prior art of the communication method of certain embodiments of the present application;

[0022] Figure 2 It is a schematic diagram of a scenario of a communication method in some embodiments of the present application;

[0023] Figure 3 is a flow chart of a communication method according to some embodiments of the present application;

[0024] Figure 4 is a flow chart of a communication method according to some embodiments of the present application;

[0025] Figure 5 is a flow chart of a communication method according to some embodiments of the present application;

[0026] Figure 6 is a flow chart of a communication method according to some embodiments of the present application;

[0027] Figure 7It is a schematic diagram of a scenario of a communication method in some embodiments of the present application;

[0028] Figure 8 is a flow chart of a communication method according to some embodiments of the present application;

[0029] Fig. 9 It is a schematic diagram of a scenario of a communication method in some embodiments of the present application;

[0030] Fig.10 is a flow chart of a communication method according to some embodiments of the present application;

[0031] Fig.11 is a flow chart of a communication method according to some embodiments of the present application;

[0032] Fig.12 is a schematic diagram of a module of a communication device according to some embodiments of the present application;

[0033] Fig.13 is a schematic diagram of the structure of a vehicle according to some embodiments of the present application;

[0034] Fig.14 It is a schematic diagram of the connection status of a non-volatile computer-readable storage medium and a processor in certain embodiments of the present application. DETAILED DESCRIPTION

[0035] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals represent the same or similar elements or elements having the same or similar functions from beginning to end. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the embodiments of the present application, and cannot be understood as limiting the embodiments of the present application.

[0036] To facilitate understanding of this application, the terms appearing in this application are explained below:

[0037] 1. Cloud server: is an Internet Technology (IT) product that provides cloud computing services. The characteristics of cloud servers are simple and efficient, safe and reliable, elastically scalable processing capabilities, reduced difficulty in development and operation and overall IT costs, and a comprehensive business service platform for all types of Internet users. It integrates the three core elements of Internet applications: computing, storage, and network, and provides public Internet infrastructure services. The communication method of this application can be implemented based on a cloud server.

[0038] 2. Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources in a wide area network or local area network to achieve data computing, storage, processing and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool and be used on demand, which is flexible and convenient. Cloud computing technology will become an important support. The background services of technical network systems require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the high development and application of the Internet industry, each item may have its own identification mark in the future, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately. All kinds of industry data need strong system backing support, which can only be achieved through cloud computing.

[0039] Cloud computing is a computing model that distributes computing tasks on a resource pool composed of a large number of computers, allowing various application systems to obtain computing power, storage space and information services as needed. The network that provides resources is called a "cloud". From the user's perspective, the resources in the "cloud" are infinitely scalable and can be obtained at any time, used on demand, expanded at any time, and paid for by use.

[0040] As a provider of basic cloud computing capabilities, a cloud computing resource pool (referred to as a cloud platform, generally referred to as an Infrastructure as a Service (IaaS) platform) will be established, and various types of virtual resources will be deployed in the resource pool for external customers to choose to use. The cloud computing resource pool mainly includes: computing devices (virtualized machines, including operating systems), storage devices, and network devices.

[0041] According to the logical functional division, the Platform as a Service (PaaS) layer can be deployed on the IaaS layer, and the Software as a Service (SaaS) layer can be deployed on the PaaS layer, or SaaS can be deployed directly on the IaaS. PaaS is a platform for software operation, such as databases, web containers, etc. SaaS is a variety of business software, such as web portals, SMS mass senders, etc. Generally speaking, SaaS and PaaS are upper layers relative to IaaS. In an embodiment of the present application, the communication method is implemented based on a cloud server, and the operator of the cloud platform provides services for creating a cloud server.

[0042] 3. Virtual Machine Monitor (VMM): It is the software, firmware or hardware used to create and execute virtual machines.

[0043] 4. A virtual machine is a complete computer system that is simulated by software and has complete hardware system functions and runs in a completely isolated environment. Any work that can be done in a physical computer can be done in a virtual machine. When creating a virtual machine in a computer, part of the hard disk and memory capacity of the physical machine needs to be used as the hard disk and memory capacity of the virtual machine. Each virtual machine has an independent CMOS, hard disk and operating system, and can be operated like a physical machine.

[0044] 5. The Binder communication mechanism is an inter-process communication (IPC) mechanism based on the client-server architecture in the Android system (Android), which has the advantages of high efficiency and security in data transmission and data exchange.

[0045] With the continuous development of my country's automobile industry, the smart cockpit field carries more and more business scenarios. The current mainstream technical route is to build multiple virtual machines on the virtual machine monitor Hypervisor (Virtual Machine Monitor, VMM) to deploy multiple operating systems, and isolate multiple operating systems from each other.

[0046] These virtual machines can be divided into the host virtual machine (host virtual machine) that assumes the control role and the guest virtual machine (guest virtual machine) that assumes functional tasks. Generally, the host virtual machine has the highest authority, can manage each guest virtual machine, and can access the data of the guest virtual machine through shared memory. In order to ensure the security of the hypervisor, each guest virtual machine is isolated from each other. Therefore, how to achieve communication between multiple different virtual machines is an urgent problem to be solved in this field.

[0047] See also Figure 1 Currently, it is usually provided by Hypervisor (i.e. Figure 1 The virtual machine monitor in the virtual machine allocates shared memory to each guest virtual machine according to the request message of each guest virtual machine. For example, see Figure 1 In the guest virtual machine 1 (i.e. Figure 1 The guest virtual machine 1 is used as the sender (Client), and the guest virtual machine 2 (i.e. Figure 1Taking Guest virtual machine 2 as the receiving end (Server) as an example, Guest virtual machine 1 and Guest virtual machine 2 access the same shared memory to achieve communication between Guest virtual machine 1 and Guest virtual machine 2.

[0048] Although this method can achieve communication between guest virtual machines, since the same shared memory area is directly accessed by multiple guest virtual machines, if the access control of shared memory is not strictly managed, security issues such as malicious access and data leakage (for example, malicious guest virtual machines unauthorized access, or unauthorized access to the memory of other guest virtual machines, etc.) may occur; and malicious attackers can directly tamper with the data in the shared memory, thereby destroying the communication and collaboration between virtual machines. In addition, for guest virtual machines running on different operating systems, since different operating systems have different management of memory management, thread scheduling, etc., the management and synchronization of shared memory becomes complicated and difficult to be compatible on different systems.

[0049] In order to solve the above technical problems, an embodiment of the present application provides a communication method.

[0050] The following first introduces an application scenario of the technical solution of this application. Figure 2 As shown, the communication method provided by the present application can be applied to Figure 2 The communication method is applied in a communication system 1000, which includes a child virtual machine 100 (ie, a Guest virtual machine) and a main virtual machine 200 (ie, a Host virtual machine).

[0051] Optionally, the child virtual machines 100 are used to execute various tasks, and the primary virtual machine 200 is used to manage the child virtual machines 100 .

[0052] Optionally, the child virtual machine 100 is based on the main virtual machine 200 and the Hypervisor (ie Figure 2 The virtual machine monitor in .

[0053] It should be noted that Figure 2 The figure is only an example. In fact, the number of child virtual machines 100 and primary virtual machines 200 is not limited and is not specifically limited in the embodiments of the present application.

[0054] The communication method of this application will be described in detail below:

[0055] See also Figure 2 and Figure 3 , an embodiment of the present application provides a communication method, the communication method comprising:

[0056] Step 011: Acquire communication data of the first virtual machine, where the communication data includes a second virtual machine as a receiving end, and the first virtual machine and the second virtual machine are isolated from each other.

[0057] The first virtual machine may be a master virtual machine (i.e., a host virtual machine) or a child virtual machine (i.e., a guest virtual machine); the second virtual machine may also be a host virtual machine or a guest virtual machine. The communication data may be data in the form of text, images, audio, video, etc. When the first virtual machine performs a task that requires interaction with a virtual machine or process, communication data is generated. The communication data includes information of the second virtual machine as the receiving end (such as address information (Internet Protocol Address, IP), etc.).

[0058] Specifically, one or more Guest virtual machines can be created based on the Host virtual machine and the Hypervisor. The Guest virtual machine is a virtualized instance running on the Host virtual machine. To ensure system security, each virtual machine created on the Hypervisor will be isolated from each other. The communication data of the first virtual machine as the sender can be obtained. The communication data includes the information of the second virtual machine as the receiver, such as the IP information of the second virtual machine, so as to determine the receiving end (Server) and the sending end (Client) of the communication, and the content of the communication.

[0059] Step 012: When the first virtual machine and the second virtual machine are different virtual machines, the communication data is sent to the second virtual machine based on a preset global routing table.

[0060] The global routing table may be a table for recording routing information of each virtual machine (such as IP information and routing identifier of each virtual machine). Based on the global routing table, communication data may be routed to corresponding virtual machines.

[0061] Specifically, it is possible to determine whether the first virtual machine and the second virtual machine are the same virtual machine through the IP address in the global routing table. In the case where the first virtual machine and the second virtual machine are different virtual machines, the communication data is routed from the first virtual machine to the second virtual machine based on the global routing table. For example, in the case where the first virtual machine and the second virtual machine are different Guest virtual machines, since both Guest virtual machines have a global routing table, that is, both Guest virtual machines can determine the IP and routing of each virtual machine, based on the global routing table, the communication data can be transmitted from the first virtual machine (i.e., the first Guest virtual machine) to the second virtual machine (i.e., the second Guest virtual machine), thereby completing the transmission of the communication data while ensuring the security of the communication of the system.

[0062] In this way, by acquiring the communication data of the first virtual machine, the communication data includes the second virtual machine as the receiving end (such as the IP information of the second virtual machine), the first virtual machine and the second virtual machine are isolated from each other to ensure the security and independence of each virtual machine; when the first virtual machine and the second virtual machine are different virtual machines, the communication data is sent to the second virtual machine based on the preset global routing table. In the communication between the first virtual machine and the second virtual machine, based on the preset global routing table, it can be ensured that the communication data can be correctly routed to the corresponding second virtual machine, avoiding the loss of communication data, communication data sending errors, etc., ensuring the accuracy of communication, and because it is not necessary to achieve communication through multiple virtual machines accessing shared memory, it can also avoid malicious access, unauthorized access, and malicious tampering of data in the shared memory by virtual machines, thereby improving the security and isolation of the system and meeting the communication needs between different virtual machines.

[0063] See also Figure 4 Optionally, the communication method further includes:

[0064] Step 013: When creating a virtual machine, assign an address to the created virtual machine;

[0065] Step 014: Create or update the global routing table based on the address.

[0066] The address may be an IP address.

[0067] Specifically, when multiple virtual machines are created on the Hypervisor, IP addresses can be assigned to each virtual machine through manual configuration or Dynamic Host Configuration Protocol (DHCP), and a global routing table is created based on each IP address. When a virtual machine that does not have an IP address is detected (such as a newly created virtual machine), an IP address is assigned to the newly created virtual machine, and the global routing table is updated based on the newly assigned IP address.

[0068] For example, taking the example of creating a new Guest virtual machine based on the Hypervisor, assigning an IP address to the Guest virtual machine, and initiating an update request for the global routing table, the Host virtual machine can obtain the IP address of the Guest virtual machine through the virtualized I / O interface, and update the global routing table based on the IP address to obtain an updated global routing table.

[0069] That is to say, when creating multiple virtual machines, a global routing table can be generated according to the IP address of each virtual machine, and when a new virtual machine is created, the IP address corresponding to the new virtual machine is added to the global routing table to update the global routing table; or, when creating the first virtual machine, a global routing table can be generated according to the IP address of the first virtual machine, and then the global routing table can be continuously updated according to the IP addresses of the second and subsequent virtual machines to generate a preset global routing table.

[0070] See also Figure 5 In some implementations, each virtual machine is isolated from each other, and the global routing table includes global routing information between the primary virtual machine and each child virtual machine in each virtual machine. Step 012: When the first virtual machine and the second virtual machine are different virtual machines, based on the preset global routing table, the communication data is sent to the second virtual machine, including:

[0071] Step 0121: When both the first virtual machine and the second virtual machine are child virtual machines, based on a preset global routing table, the communication data is sent to the primary virtual machine, and the communication data is forwarded to the second virtual machine through the primary virtual machine;

[0072] Step 0122: When the first virtual machine is a child virtual machine and the second virtual machine is a master virtual machine, the communication data is sent to the second virtual machine based on a preset global routing table.

[0073] The global routing table includes global routing information between the main virtual machine and each child virtual machine in each virtual machine. Based on the global routing information in the global routing table, routing can be performed to complete communication between virtual machines.

[0074] Specifically, when both the first virtual machine and the second virtual machine are guest virtual machines, the IP and routing path of the second virtual machine receiving the communication data are determined based on a preset global routing table, and the communication data is sent to the host virtual machine through a virtual network, and then the host virtual machine forwards the communication data to the second virtual machine as the receiving end through the virtual network to maintain the isolation between the guest virtual machines, thereby ensuring the security of the system; when the first virtual machine is a guest virtual machine and the second virtual machine is a host virtual machine, routing is performed for the first virtual machine based on a preset global routing table to send the communication data to the host virtual machine through a virtual network, thereby completing the communication. Forwarding through the host virtual machine can ensure that the isolation between virtual machines is not affected, thereby improving the security of the system.

[0075] Optionally, the first virtual machine and the second virtual machine communicate through the same preset process communication mechanism.

[0076] Among them, the process communication mechanism includes the Binder communication mechanism.

[0077] Linux and Android are both operating systems, and virtual machines can run on them. Since the communication mechanisms of Linux and Android are different, in order to improve the compatibility of Linux and Android, and to achieve cross-system communication between virtual machines running on Linux and on Android, virtual machines running on Linux need to be equipped with components that can also implement the Binder mechanism.

[0078] See also Figure 6 In some embodiments, the communication method further comprises:

[0079] Step 015: Determine, among the virtual machines, a target virtual machine that does not include a preset process communication mechanism;

[0080] Step 016: Add components corresponding to the preset process communication mechanism in each target virtual machine to build the preset process communication mechanism in each target virtual machine.

[0081] Specifically, in order to be compatible with the Binder communication mechanism of the Android system, the target virtual machine (such as a virtual machine running on a Linux system, etc.) that does not contain the Binder communication mechanism can be determined in each virtual machine, and the target virtual machine lacks the communication components required to implement Binder communication. Therefore, the Binder framework of the target virtual machine can be reconstructed, that is, by adding components corresponding to the Binder communication mechanism (such as Binder driver components, etc.) in each target virtual machine, so as to build a Binder communication mechanism in each target virtual machine, so that each virtual machine can achieve efficient and secure communication based on the Binder communication mechanism when sending communication data.

[0082] For example, see Figure 7, taking the target virtual machine as an example, adding the first component 10, the second component 20, the third component 30, the fourth component 40 and the fifth component 50, wherein the first component 10 is the ServiceManager component 10, the second component 20 is the BinderProxy component 20, the third component 30 is the BBinder component 30, the fourth component 40 is the BpBinder component 40, and the fifth component 50 is the Binder driver component 50, wherein the ServiceManager component 10 is used to start and manage system processes, register and search for services, etc., the BinderProxy component 20 is used for the client to call data, the BBinder component 30 is used to represent the Binder local object inter-process communication interface, the BpBinder component 40 is used to represent the Binder proxy object inter-process communication interface, and the Binder driver component 50 is used to drive the communication. By adding the components corresponding to each Binder communication mechanism, the target virtual machine can realize Binder communication.

[0083] After building the same preset process communication mechanism (i.e., Binder communication mechanism) for the virtual machines running in each system, it is also necessary to consider how to implement virtual network services between different systems.

[0084] Take the widely used Vsock (a socket type for virtualization environments that can establish a network connection between the Host virtual machine and the Guest virtual machine) communication method as an example. In Vsock, the Host virtual machine has the authority to access the memory address of the Guest virtual machine. Therefore, the communication convenience of Vsock is more reflected in the transmission efficiency between the Host virtual machine and the Guest virtual machine.

[0085] However, when two Guest virtual machines communicate with each other, since the two Guest virtual machines are isolated from each other, a Guest virtual machine cannot locate the memory address of another Guest virtual machine, and data transmission cannot be achieved through Vsock.

[0086] Optionally, each virtual machine communicates with each other through a device virtualization network, and the device virtualization network is implemented based on a Virtio technology framework.

[0087] Among them, the transmission protocol defined based on the Virtio technology framework is the device virtualization network. Virtio is a technical means used to provide a unified communication framework and programming interface between virtual machines and hypervisor devices to reduce cross-platform compatibility issues and improve program development efficiency. That is, Virtio is a technology based on virtualization technology to establish a communication channel between the host virtual machine and the guest virtual machine.

[0088] Optionally, the virtualized network implemented in the Host virtual machine is defined as Vhost, and the virtual machine network implemented in the Guest virtual machine is defined as Virtio-net.

[0089] Specifically, you can use virtualization management tools such as libvirt (an open source background program and management tool for managing virtualization platforms) to configure the corresponding Virtio-net network interface and network parameters for each Guest virtual machine, that is, configure the corresponding device virtualization network component for each Guest virtual machine, and then implement Virtio network communication between each virtual machine based on the Virtio driver and each device virtualization network component.

[0090] It can be understood that Virtio creates and updates a preset global routing table, and based on the global routing table, realizes sending communication data from the first virtual machine to the second virtual machine. During the data transmission process, the construction of the communication network can be completed more conveniently without considering whether the object of data transmission is the Host virtual machine. The applicability of communication can be improved, and compared with communication methods such as Vsock, Virtio also has the advantages of higher flexibility and universality.

[0091] See also Figure 8 In some embodiments, step 0121: when the first virtual machine and the second virtual machine are both child virtual machines, based on a preset global routing table, sending communication data to the primary virtual machine, and forwarding the communication data to the second virtual machine through the primary virtual machine, includes:

[0092] Step 01211: establishing a first communication link between the first virtual machine and the primary virtual machine, and a second communication link between the second virtual machine and the primary virtual machine based on the global routing table, the address of the first virtual machine, the address of the second virtual machine, and the address of the primary virtual machine;

[0093] Step 01212: Based on the first communication link, control the first virtual machine to send communication data to the master virtual machine;

[0094] Step 01213: Based on the second communication link, control the primary virtual machine to forward the communication data to the second virtual machine.

[0095] Specifically, a first communication link can be established between the first virtual machine and the primary virtual machine according to the address of the first virtual machine and the address of the primary virtual machine included in the global routing table, and a second communication link can be established between the second virtual machine and the primary virtual machine according to the address of the second virtual machine and the address of the primary virtual machine. When the first virtual machine and the second virtual machine are both sub-virtual machines, based on the first communication link, the first virtual machine is controlled to send communication data to the primary virtual machine. After the primary virtual machine receives the communication data, the primary virtual machine is controlled to forward the communication data to the second virtual machine.

[0096] For example, see Fig. 9 , taking the first virtual machine as the child virtual machine 103 (i.e., Guest virtual machine 103) and the second virtual machine as the child virtual machine 104 (i.e., Guest virtual machine 104) as an example for explanation, by respectively establishing the corresponding first network 11 (i.e., Virtio-net11) in the Guest virtual machine 103 and the corresponding second network 12 (i.e., Virtio-net12) in the Guest virtual machine 104, establishing the third network 21 (i.e., Vhost21) in the host virtual machine 201 (i.e., Host virtual machine 201), establishing the first communication link between the Guest virtual machine 103 and the Host virtual machine 201 according to the address of the Guest virtual machine 103 and the address of the Host virtual machine 201, and establishing the second communication link between the Guest virtual machine 104 and the Host virtual machine 201 according to the address of the Guest virtual machine 104 and the address of the Host virtual machine 201. The communication data is transmitted from the Guest virtual machine 103 to the Host virtual machine 201 through the first communication link, and then forwarded from the Host virtual machine 201 to the Guest virtual machine 104 through the second communication link.

[0097] See also Fig.10 Optionally, step 01212: based on the first communication link, controlling the first virtual machine to send communication data to the primary virtual machine includes:

[0098] Step 01214: registering the device virtualization network component in the remote call component corresponding to the preset process communication mechanism;

[0099] Step 01215: Call the device virtualization network component to send the communication data to the primary virtual machine through the first communication link.

[0100] The remote call component (RpcSession) may be a communication component for forwarding communication data.

[0101] Specifically, when the first virtual machine and the second virtual machine are different virtual machines, the device virtualization network component required by Virtio-net is registered in RpcSession, and then the device virtualization network component is called to transmit the communication data to the Host virtual machine through Virtio-net.

[0102] For example, see Figure 7 and Fig. 9 , taking the first virtual machine as Guest virtual machine 103 and the second virtual machine as Guest virtual machine 104 as an example for explanation, when Guest virtual machine 103 initiates a communication request, by obtaining the communication data of Guest virtual machine 103, the communication data includes the IP of Guest virtual machine 104, Guest virtual machine 103 calls the BinderProxy component of the sending end 13 (i.e., Client end 13) (for example, by calling the Proxy Class (i.e., the replacement class) in the BinderProxy component and calling the writeParcelable() method in the Parcel class (i.e., the container), and transferring the data to the BpBinder component through the transact() method in the base class IBinder (i.e., the interface)), so as to transfer the communication data from the Client end to the BpBinder component; the BpBinder component transfers the data to the RpcSession through the transact() method, and since the device virtualization network component required by Virtio-net has been registered in the RpcSession, the communication data can be transferred to the Host virtual machine 201 based on Virtio-net11 by calling the device virtualization network component. Among them, the writeParcelable() method is a method used to serialize an object into a byte stream for transmission or persistent storage between different components, and the transact() method is a method used to perform a set of related operations in the database system and maintain data consistency in these operations.

[0103] The Host virtual machine 201 establishes communication with the Guest virtual machine 104 through Vhost21 to transmit the communication data to the Guest virtual machine 104. For the Guest virtual machine 104, the communication data enters the receiving end 14 (i.e., the Server end 14) of the Guest virtual machine 104 from the device virtualization network component required by Virtio-net12, and the RpcSession of the Guest virtual machine 104 transmits the communication data to the BBinder component of the Guest virtual machine 104. The BBinder component of the Guest virtual machine 104 receives the communication data transmitted by the RpcSession through the onTransact() method and forwards it to IBinder. The Guest virtual machine 104 obtains the communication data through the onTransact() method in IBinder and the readParcelable() method in the Parcel class. In this way, cross-system and cross-domain communication between the first virtual machine and the second virtual machine can be achieved when the first virtual machine and the second virtual machine are different. Among them, the onTransact() method is a method for processing communication requests between processes, and the readParcelable() method is a method for reading data.

[0104] See also Fig.11 In some embodiments, the communication method further comprises:

[0105] Step 017: When the first virtual machine and the second virtual machine are the same virtual machine, determine a target process in the same virtual machine;

[0106] Step 018: The driver component based on the preset process communication mechanism transmits the communication data to the target process.

[0107] Specifically, when the first virtual machine and the second virtual machine are the same virtual machine, that is, the transmission of communication data occurs in the same virtual machine, the communication data can be transmitted to the target process by calling the Binder driver component based on the IPC in the Binder communication mechanism by determining the target process.

[0108] For example, when the first virtual machine and the second virtual machine are the same virtual machine, the transact() method in the ThreadState class (a class that describes the state of a thread or manages the state transition of a thread) based on the IPC mechanism transmits the communication data of the Client to the Binder driver component corresponding to the Binder communication mechanism; then the Binder driver component is called to open up a shared memory space vm_area through the mmap function, and establish a mapping between the shared memory space vm_area and the binder_buffer. At the Sever end of the first virtual machine, the communication data sent by the Client is received through IPC communication, and the communication data is passed to BBinder, thereby completing the intra-domain communication of the first virtual machine.

[0109] In this way, regardless of whether the first virtual machine and the second virtual machine are the same virtual machine, based on the Binder mechanism, virtual machines running in different systems can achieve cross-system communication while being compatible with their own inter-process communication, and then achieve network interconnection between virtual machines through Virtio, with high communication efficiency, security and portability.

[0110] See also Fig.12 In order to better implement the communication method of the embodiment of the present application, the embodiment of the present application also provides a communication device 300. The communication device 300 may include an acquisition module 301 and a sending module 302, the acquisition module 301 is used to acquire the communication data of the first virtual machine, the communication data includes the second virtual machine as the receiving end, and the first virtual machine and the second virtual machine are isolated from each other; the sending module 302 is used to send the communication data to the second virtual machine based on a preset global routing table when the first virtual machine and the second virtual machine are different virtual machines.

[0111] In one embodiment, each virtual machine is isolated from each other, and the global routing table includes global routing information between the main virtual machine and each child virtual machine in each virtual machine. The sending module 302 is also specifically used to send communication data to the main virtual machine based on a preset global routing table when the first virtual machine and the second virtual machine are both child virtual machines, and forward the communication data to the second virtual machine through the main virtual machine; when the first virtual machine is a child virtual machine and the second virtual machine is the main virtual machine, the communication data is sent to the second virtual machine based on the preset global routing table.

[0112] In one embodiment, the sending module 302 is specifically used to establish a first communication link between the first virtual machine and the primary virtual machine, and a second communication link between the second virtual machine and the primary virtual machine based on the global routing table, the address of the first virtual machine, the address of the second virtual machine and the address of the primary virtual machine; based on the first communication link, control the first virtual machine to send communication data to the primary virtual machine; based on the second communication link, control the primary virtual machine to forward communication data to the second virtual machine.

[0113] In one embodiment, the sending module 302 is further specifically used to register the device virtualization network component in the remote calling component corresponding to the preset process communication mechanism; and call the device virtualization network component to send the communication data to the primary virtual machine through the first communication link.

[0114] In one embodiment, the communication device 300 further includes a creation module 303, and the creation module 303 is used to allocate an address to the created virtual machine when creating the virtual machine; and to create or update a global routing table based on the address.

[0115] In one embodiment, the communication device 300 also includes a construction module 304, which is used to determine the target virtual machine among each virtual machine that does not contain the preset process communication mechanism; add components corresponding to the preset process communication mechanism in each target virtual machine to construct the preset process communication mechanism in each target virtual machine.

[0116] In one embodiment, the communication device 300 also includes a transmission module 305, which is used to determine the target process in the same virtual machine when the first virtual machine and the second virtual machine are the same virtual machine; based on a driving component of a preset process communication mechanism, transmit communication data to the target process.

[0117] The communication device 300 is described above from the perspective of a functional module in conjunction with the accompanying drawings. The functional module can be implemented in hardware form, can be implemented in software form, or can be implemented in combination with hardware and software modules. Specifically, each step of the method embodiment in the embodiment of the present application can be completed by an integrated logic circuit of hardware in the processor and / or an instruction in software form, and the steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware encoding processor to be executed, or a combination of hardware and software modules in the encoding processor to be executed. Optionally, the software module can be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory, and completes the steps in the above method embodiment in conjunction with its hardware.

[0118] The electronic device of the embodiment of the present application includes a processor, the processor is connected to a memory, a computer program is stored in the memory, and the processor executes the computer program to implement any one of the communication methods described above, which will not be described in detail here for the sake of brevity.

[0119] See also Fig.13 , wherein the electronic device can be used as a processor of the vehicle, and the electronic device can be installed in the vehicle so that the vehicle can implement the communication method of any of the above-mentioned embodiments through the electronic device.

[0120] The vehicle of the embodiment of the present application includes the communication device or electronic device of the above embodiment, such as the communication device or electronic device is a processor of the vehicle. The vehicle implements any one of the above communication methods through the communication device or electronic device.

[0121] In one embodiment, the internal structure diagram of the vehicle can be as follows: Fig.13 As shown, it includes a processor 402, a memory 403, a network interface 404, a display screen 401 and an input device 405 connected through a system bus.

[0122] Among them, the vehicle's processor 402 is used to provide computing and control capabilities. The vehicle's memory 403 includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The vehicle's network interface 404 is used to communicate with external devices through a network connection. When the computer program is executed by the processor, the communication method of any of the above-mentioned embodiments is implemented. The vehicle's display screen 401 can be a liquid crystal display screen or an electronic ink display screen, and the vehicle's input device 405 can be a touch layer covering the display screen 401, or a button, trackball or touchpad provided on the vehicle, or an external keyboard, touchpad or mouse, etc.

[0123] Those skilled in the art will understand that Fig.13 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0124] See also Fig.14 The embodiment of the present application also provides a computer-readable storage medium 600 on which a computer program 610 is stored. When the computer program 610 is executed by a processor 620, the steps of the communication method of any of the above-mentioned embodiments are implemented. For the sake of brevity, they are not repeated here.

[0125] In the description of this specification, the descriptions with reference to the terms "certain embodiments", "in an example", "exemplarily", etc., mean that the specific features, structures, materials or characteristics described in conjunction with the embodiments or examples are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.

[0126] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.

[0127] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.

Claims

1. A communication method, characterized in that: include: Acquire communication data of a first virtual machine, where the communication data includes a second virtual machine as a receiving end, where the first virtual machine and the second virtual machine are isolated from each other; the first virtual machine and the second virtual machine communicate through the same preset process communication mechanism, where the process communication mechanism includes a Binder communication mechanism; In the case where the first virtual machine and the second virtual machine are different virtual machines, and in the case where the first virtual machine and the second virtual machine are both child virtual machines, based on a preset global routing table, sending the communication data to a primary virtual machine, and forwarding the communication data to the second virtual machine through the primary virtual machine; When the first virtual machine is the child virtual machine and the second virtual machine is the master virtual machine, sending the communication data to the second virtual machine based on a preset global routing table; The virtual machines are isolated from each other, and the global routing table includes global routing information between the master virtual machine and each child virtual machine in the virtual machines; Each virtual machine communicates with each other through a device virtualization network, which is implemented based on the Virtio technology framework.

2. The communication method according to claim 1, characterized in that: The method of sending the communication data to the primary virtual machine based on a preset global routing table, and forwarding the communication data to the second virtual machine through the primary virtual machine, includes: Based on the global routing table, the address of the first virtual machine, the address of the second virtual machine, and the address of the primary virtual machine, establish a first communication link between the first virtual machine and the primary virtual machine, and a second communication link between the second virtual machine and the primary virtual machine; Based on the first communication link, controlling the first virtual machine to send the communication data to the primary virtual machine; Based on the second communication link, the primary virtual machine is controlled to forward the communication data to the second virtual machine.

3. The communication method according to claim 2, characterized in that: The controlling the first virtual machine to send the communication data to the primary virtual machine based on the first communication link includes: Registering the device virtualization network component in the remote call component corresponding to the preset process communication mechanism; The device virtualization network component is called to send the communication data to the primary virtual machine through the first communication link.

4. The communication method according to claim 1, characterized in that: Also includes: When creating a virtual machine, an address is assigned to the created virtual machine; Based on the address, the global routing table is created or updated.

5. The communication method according to claim 1, characterized in that: Also includes: Determine, among the virtual machines, a target virtual machine that does not include a preset process communication mechanism; A component corresponding to the preset process communication mechanism is added in each of the target virtual machines to construct the preset process communication mechanism in each of the target virtual machines.

6. The communication method according to claim 1, characterized in that: Also includes: In a case where the first virtual machine and the second virtual machine are the same virtual machine, determining a target process in the same virtual machine; The driving component based on the preset process communication mechanism transmits the communication data to the target process.

7. An electronic device, characterized in that: include: A processor, the processor is connected to a memory; a computer program is stored in the memory, and the processor executes the computer program to implement the instructions of the communication method according to any one of claims 1 to 6.

8. A vehicle, characterized in that: include: The electronic device according to claim 7.

9. A non-volatile computer-readable storage medium containing a computer program, characterized in that: When the computer program is executed by a processor, the processor executes the communication method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Data transmission method and device, electronic equipment and storage medium

    CN117014390A