CN117880221A - Method and device for sharing hardware network card in multi-virtual machine system and electronic equipment - Google Patents

Method and device for sharing hardware network card in multi-virtual machine system and electronic equipment Download PDF

Info

Publication number
CN117880221A
CN117880221A CN202311826410.7A CN202311826410A CN117880221A CN 117880221 A CN117880221 A CN 117880221A CN 202311826410 A CN202311826410 A CN 202311826410A CN 117880221 A CN117880221 A CN 117880221A
Authority
CN
China
Prior art keywords
virtual machine
virtual
network card
data frame
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311826410.7A
Other languages
Chinese (zh)
Inventor
丁磊
王建峰
杨伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guoke Chushi Chongqing Software Co ltd
Original Assignee
Guoke Chushi Chongqing Software Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guoke Chushi Chongqing Software Co ltd filed Critical Guoke Chushi Chongqing Software Co ltd
Priority to CN202311826410.7A priority Critical patent/CN117880221A/en
Publication of CN117880221A publication Critical patent/CN117880221A/en
Pending legal-status Critical Current

Links

Landscapes

  • Computer And Data Communications (AREA)

Abstract

The disclosure relates to a method, a device and electronic equipment for sharing a hardware network card in a multi-virtual machine system. The method for sharing the hardware network card in the multi-virtual machine system comprises the following steps: the virtual network data forwarding device is arranged on the virtual machine manager, responds to the first data frame received from the hardware network card and sent to any one of the virtual machines, and acquires the identification of the target virtual machine waiting for receiving the first data frame according to the destination mac address of the first data frame by utilizing the mapping relation between the mac address of the established virtual network card and the identification of the virtual machine; according to the identification of the target virtual machine, storing the first data frame in a shared memory between the virtual machine manager and the target virtual machine; sending a request receiving data notification to a virtual network card of the target virtual machine by using the identification of the target virtual machine; and the virtual network card of the target virtual machine responds to the received request receiving data notification, and acquires the first data frame from the shared memory.

Description

Method and device for sharing hardware network card in multi-virtual machine system and electronic equipment
Technical Field
The disclosure relates to the technical field of virtual machines, and in particular relates to a method, a device and electronic equipment for sharing a hardware network card in a multi-virtual machine system.
Background
The network virtualization technology plays a role in the virtual machine manager, and an efficient and reliable network virtualization scheme can remarkably improve the network performance of the virtual machine and improve the usability of the virtual machine manager.
In the related art, network virtualization is generally implemented using virtio-net. The virtio-net is a standard for network virtualization support by the virtio protocol, which promotes versatility at the expense of performance. For example, in the virtio-net standard, a virtio-net back-end needs to be provided to respond to virtio-net front-end requests, while in practice, type I virtual machines do not require these requests, and these redundant requests can degrade the performance of the network transport. As another example, the virtio-net data frame transmission needs to be encapsulated into virtqueue, and the process needs to adhere to the virtio-net protocol, adding some necessary control plane data, resulting in an increase in the amount of data to be transmitted as a whole. For another example, when the virtio-net acquires the control plane such as the network card information, the data format is required to be in conformity with the virqueue, and a certain data redundancy is generated.
Therefore, how to efficiently share the hardware network card in the multi-virtual machine system and improve the network data processing efficiency of the multi-virtual machine system is a technical problem to be solved.
Disclosure of Invention
In order to overcome the problems in the related art, the present disclosure provides a method, an apparatus and an electronic device for sharing a hardware network card in a multi-virtual machine system.
According to a first aspect of an embodiment of the present disclosure, there is provided a method for sharing a hardware network card in a multi-virtual machine system, including: the virtual network data forwarding device is arranged on the virtual machine manager, responds to the first data frame received from the hardware network card and sent to any one of the plurality of virtual machines, and acquires the identification of the target virtual machine waiting for receiving the first data frame according to the destination mac address of the first data frame by utilizing the mapping relation between the mac address of the established virtual network card and the identification of the virtual machine; according to the identification of the target virtual machine, storing the first data frame in a shared memory between the virtual machine manager and the target virtual machine; wherein a shared memory between the virtual machine manager and the target virtual machine is associated with an identity of the target virtual machine; sending a request receiving data notification to a virtual network card of the target virtual machine by using the identification of the target virtual machine; and the virtual network card of the target virtual machine responds to the received data notification request and acquires the first data frame from the shared memory.
In some embodiments, the method further comprises: the virtual network card is arranged in any virtual machine, and responds to receiving a second data frame from an application program running in the virtual machine, and the second data frame is stored in a shared memory between the virtual machine manager and the virtual machine; sending a request to send data notification to the virtual machine manager by using a hypercall interface; the virtual machine manager responds to the received request to send a data notification, and the second data frame is acquired from a shared memory between the virtual machine manager and the virtual machine; and transmitting the second data frame to the hardware network card by using the virtual network data forwarding device, so that the hardware network card forwards the second data frame to a physical network connected with the hardware network card.
In some embodiments, the method further comprises: when any virtual machine is initialized, a virtual network card initialization request is sent to the virtual machine manager; the virtual machine manager responds to the received virtual network card initialization request and establishes a mapping relation between a mac address allocated for the virtual network card of the virtual machine and the identifier of the virtual machine; and distributing a shared memory for the virtual machine, and establishing a mapping relation between the shared memory and the identifier of the virtual machine.
In some embodiments, the virtual network data forwarding device includes a multi-port first virtual bridge associated with the hardware network card, and a back-end virtual network card corresponding to a virtual network card of each virtual machine, where the back-end virtual network card has the same mac address as the corresponding virtual network card, and all back-end virtual network cards are connected to the first virtual bridge through different ports of the first virtual bridge; the virtual network data forwarding device receives the first data frame by: the first virtual network bridge receives the first data frame from the hardware network card; forwarding the first data frame to a target port of the first virtual bridge corresponding to the destination mac address according to the destination mac address of the first data frame; a back-end virtual network card connected with the target port, which receives the first data frame from the target port; storing the first data frame in a shared memory between the virtual machine manager and the target virtual machine according to the identifier of the target virtual machine, including: and the back-end virtual network card stores the first data frame in a shared memory between the virtual machine manager and the target virtual machine according to the identification of the target virtual machine.
In some embodiments, the virtual network data forwarding device is a second virtual bridge associated with the hardware network card; the virtual network data forwarding device receives the first data frame by: the second virtual network bridge receives the first data frame from the hardware network card; storing the first data frame in a shared memory between the virtual machine manager and the target virtual machine according to the identifier of the target virtual machine, including: and the second virtual network bridge stores the first data frame in a shared memory between the virtual machine manager and the target virtual machine according to the identification of the target virtual machine.
In some embodiments, the shared memory between the virtual machine manager and any virtual machine is established by: and taking the receiving buffer zone of the second virtual network bridge as the shared memory.
In some embodiments, the sending, with the identification of the target virtual machine, a request to receive data notification to a virtual network card of the target virtual machine includes: injecting network interruption carrying the request receiving data notification into a virtual network card of the target virtual machine by using the identification of the target virtual machine; or sending a request to receive data notification to the target virtual machine by using the hypercall interface by utilizing the identification of the target virtual machine.
According to a second aspect of embodiments of the present disclosure, there is provided an apparatus for sharing a hardware network card in a multi-virtual machine system, including a first obtaining module configured to enable a virtual network data forwarding device disposed in the virtual machine manager to obtain, in response to receiving a first data frame from the hardware network card and sent to any one of the plurality of virtual machines, an identification of a target virtual machine waiting to receive the first data frame according to a destination mac address of the first data frame, using a mapping relationship between a mac address of the established virtual network card and an identification of the virtual machine; the first storage module is used for storing the first data frame in a shared memory between the virtual machine manager and the target virtual machine according to the identification of the target virtual machine; wherein a shared memory between the virtual machine manager and the target virtual machine is associated with an identity of the target virtual machine; the first sending module is used for sending a request receiving data notification to a virtual network card of the target virtual machine by utilizing the identification of the target virtual machine; and the second acquisition module is used for enabling the virtual network card of the target virtual machine to respond to the received data notification request and acquire the first data frame from the shared memory.
According to a third aspect of embodiments of the present disclosure, there is provided a vehicle storing a set of instructions to be executed by the vehicle to implement the method for sharing a hardware network card in a multiple virtual machine system provided by the first aspect of the present disclosure.
According to a fourth aspect of embodiments of the present disclosure, there is provided an electronic device, comprising: a processor; a memory for storing the processor-executable instructions; the processor is configured to read the executable instructions from the memory and execute the instructions to implement the method for sharing a hardware network card in a multiple virtual machine system provided in the first aspect of the present disclosure.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement the steps of the method for sharing a hardware network card in a multi-virtual machine system provided by the first aspect of the present disclosure.
The technical scheme provided by the embodiment of the disclosure can comprise the following beneficial effects:
in the embodiment provided by the disclosure, a virtual network data forwarding device arranged in a virtual machine manager responds to a first data frame received from a hardware network card and sent to any one of a plurality of virtual machines, and acquires an identifier of a target virtual machine waiting for receiving the first data frame by using a mapping relationship between a mac address of an established virtual network card and an identifier of the virtual machine according to a destination mac address of the first data frame; according to the identification of the target virtual machine, storing the first data frame in a shared memory between the virtual machine manager and the target virtual machine; sending a request receiving data notification to a virtual network card of the target virtual machine by using the identification of the target virtual machine; and the virtual network card of the target virtual machine responds to the received request receiving data notification, and acquires the first data frame from the shared memory. Therefore, the hardware network card can be shared in the multi-virtual machine system efficiently, and the network data processing efficiency of the multi-virtual machine system is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure.
Fig. 1 is a flow chart illustrating a method of sharing a hardware network card in a multi-virtual machine system, according to an example embodiment.
Fig. 2 is a flow chart illustrating yet another method of sharing a hardware network card in a multi-virtual machine system, according to an example embodiment.
Fig. 3 is a flowchart illustrating a method of receiving a data frame with a virtual network data forwarding device, according to one exemplary embodiment.
Fig. 4 is a flow chart illustrating yet another method of receiving a data frame with a virtual network data forwarding device, according to one exemplary embodiment.
Fig. 5 is a schematic diagram showing the structure of a multi-virtual machine system according to an exemplary embodiment.
Fig. 6 is a schematic diagram showing a structure of a virtual network data forwarding apparatus according to an exemplary embodiment.
Fig. 7 is a schematic diagram showing the structure of yet another virtual network data forwarding apparatus according to an exemplary embodiment.
Fig. 8 is a block diagram illustrating an apparatus for sharing a hardware network card in a multi-virtual machine system according to an exemplary embodiment.
Fig. 9 is a block diagram of a vehicle, according to an exemplary embodiment.
Fig. 10 is a block diagram of an electronic device, according to an example embodiment.
Detailed Description
Exemplary embodiments will be described in detail below with reference to the accompanying drawings.
It should be noted that the related embodiments and the drawings are only for the purpose of describing exemplary embodiments provided by the present disclosure, and not all embodiments of the present disclosure, nor should the present disclosure be construed to be limited by the related exemplary embodiments.
It should be noted that the terms "first," "second," and the like, as used in this disclosure, are used merely to distinguish between different steps, devices, or modules, and the like. Relational terms are used not to indicate any particular technical meaning nor sequence or interdependence between them.
It should be noted that the modifications of the terms "one", "a plurality", "at least one" as used in this disclosure are intended to be illustrative rather than limiting. Unless the context clearly indicates otherwise, it should be understood as "one or more".
It should be noted that the term "and/or" is used in this disclosure to describe an association between associated objects, and generally indicates that there are at least three associations. For example, a and/or B may at least represent: a exists independently, A and B exist simultaneously, and B exists independently.
It should be noted that the various steps recited in the method embodiments of the present disclosure may be performed in a different order and/or performed in parallel. The scope of the present disclosure is not limited by the order of description of the steps in the related embodiments unless specifically stated.
It should be noted that, all actions for acquiring signals, information or data in the present disclosure are performed under the condition of conforming to the corresponding data protection rule policy of the country of the location and obtaining the authorization given by the owner of the corresponding device.
Exemplary method
Fig. 1 is a flow chart illustrating a method of sharing a hardware network card in a multi-virtual machine system, according to an example embodiment.
The method for sharing a hardware network card in a multi-virtual machine system is used for the multi-virtual machine system, as shown in fig. 5, in which a plurality of virtual machines share a system on chip including the hardware network card through a virtual machine manager, as shown in fig. 1, and includes the following steps.
In step S110, the virtual network data forwarding device provided in the virtual machine manager, in response to receiving the first data frame from the hardware network card and sent to any one of the plurality of virtual machines, obtains, according to the destination mac address of the first data frame, the identifier of the target virtual machine waiting for receiving the first data frame by using the mapping relationship between the mac address of the established virtual network card and the identifier of the virtual machine.
The virtual network data forwarding device is a virtual device provided by the virtual machine manager itself and used for realizing network connection and data forwarding between the virtual machine and the hardware network card. In an implementation, the virtual network data forwarding device may include, but is not limited to, a virtual network card, a virtual switch, and the like.
The details of the virtual network data forwarding apparatus are referred to in fig. 3 and fig. 4, and will not be described herein.
In a specific implementation process, the first data frame is data transmitted based on a two-layer network forwarding protocol. The two-layer network forwarding protocol is a forwarding protocol on the data link layer (second layer) that performs data frame forwarding based on mac addresses. The data structure of the first data frame may comprise the following parts: a target mac address and a source mac address; a source IP address, a destination IP address; transport layer protocols, etc.
The identity of the virtual machine is a unique identifier for each virtual machine in the multi-virtual machine system, and may be assigned to each virtual machine by the virtual machine manager.
In a specific implementation process, the mapping relationship between the mac address of the established virtual network card and the identifier of the virtual machine can be expressed in various forms. By way of example only, a mapping table stored in memory may be used to record, in the form of key-value pairs, a mapping relationship between the mac address of the virtual network card and the identity of the virtual machine; the virtual network data forwarding device may obtain, by querying a mapping table, an identification of a target virtual machine waiting to receive the first data frame according to the destination mac address of the first data frame.
In some embodiments, the mapping relationship between the mac address of the virtual network card and the identity of the virtual machine may be established by:
when any virtual machine is initialized, a virtual network card initialization request is sent to a virtual machine manager; the virtual machine manager, in response to receiving the virtual network card initialization request, establishes a mapping relationship between the mac address allocated to the virtual network card of the virtual machine and the identifier of the virtual machine, and may record the mapping relationship in the mapping table, for example.
In step S120, according to the identifier of the target virtual machine, the first data frame is stored in the shared memory between the virtual machine manager and the target virtual machine; wherein the shared memory between the virtual machine manager and the target virtual machine is associated with an identity of the target virtual machine.
In some embodiments, the shared memory between the virtual machine manager and the target virtual machine may be allocated and associated with the identity of the target virtual machine by:
when any virtual machine is initialized, a virtual network card initialization request is sent to a virtual machine manager; and the virtual machine manager is used for distributing the shared memory for the virtual machine in response to receiving the virtual network card initialization request and establishing a mapping relation between the shared memory and the identifier of the virtual machine.
By way of example only, the mapping table in the memory may record a mapping relationship between the shared memory and the identity of the virtual machine in the form of a key-value pair, e.g., the identity of the virtual machine may be used as a key, and the starting address of the shared memory may be used as a value.
By way of example only, the virtual network data forwarding device may obtain, from the mapping table in the above example, an address of a shared memory between the virtual network data forwarding device and the virtual machine manager according to the identification of the target virtual machine; and writing the first data frame into the shared memory according to the address of the shared memory.
In the implementation process, the virtual machine manager may allocate a storage space with a different address for each virtual machine as a shared memory, or may allocate the same storage space for all virtual machines as a shared memory (for example, a virtual machine identifier may be added to a first data frame and then stored in the shared memory), which is not limited by the expression of the present specification.
In step S130, a request-to-receive data notification is transmitted to the virtual network card of the target virtual machine using the identifier of the target virtual machine.
In the implementation process, the virtual network data forwarding device may send a request to receive a data notification to the virtual network card of the target virtual machine by using the identifier of the target virtual machine in various manners.
For example, the virtual network data forwarding device may inject a network interrupt carrying a request to receive a data notification to the virtual network card of the target virtual machine using the identification of the target virtual machine. For another example, the virtual network data forwarding device may send a request to receive data notification to the target virtual machine using the hypercall interface using the identity of the target virtual machine.
In step S140, the virtual network card of the target virtual machine, in response to receiving the request to receive the data notification, acquires the first data frame from the shared memory.
In the implementation process, the virtual network card of the target virtual machine, in response to receiving the request to receive the data notification, may read the first data frame from the shared memory allocated to the virtual machine manager by using the interface function.
In the embodiment provided by the disclosure, a virtual network data forwarding device arranged in a virtual machine manager responds to a first data frame received from a hardware network card and sent to any one of a plurality of virtual machines, and acquires an identifier of a target virtual machine waiting for receiving the first data frame by using a mapping relationship between a mac address of the established virtual network card and an identifier of the virtual machine according to a destination mac address of the first data frame; according to the identification of the target virtual machine, storing the first data frame in a shared memory between the virtual machine manager and the target virtual machine; sending a request receiving data notification to a virtual network card of the target virtual machine by using the identification of the target virtual machine; and the virtual network card of the target virtual machine responds to the received request receiving data notification, and acquires the first data frame from the shared memory. The data forwarding process of the data frame received by the hardware network card from the network to the target virtual machine can be efficiently realized by utilizing the association relationship between the identification of the target virtual machine and the destination Mac address of the first data frame and the association relationship between the identification of the target virtual machine and the shared memory.
Fig. 2 is a flow chart illustrating yet another method of sharing a hardware network card in a multi-virtual machine system, according to an example embodiment.
The method for sharing a hardware network card in a multi-virtual machine system is used for the multi-virtual machine system, as shown in fig. 5, in which a plurality of virtual machines share a system on chip including the hardware network card through a virtual machine manager, as shown in fig. 2, and includes the steps of:
in step S210, the virtual network card disposed in any one of the virtual machines stores the second data frame in the shared memory between the virtual machine manager and the virtual machine in response to receiving the second data frame from the application running in the virtual machine.
The second data frame is data that needs to be sent into the physical network and is transmitted based on a two-layer network forwarding protocol. The data structure of the second data frame may comprise the following parts: a target mac address and a source mac address; a source IP address, a destination IP address; transport layer protocols, etc.
For a detailed description of the shared memory between the virtual machine manager and the virtual machine, refer to the relevant content in fig. 1, and will not be repeated here.
In step S220, a request to send data notification is sent to the virtual machine manager using the hypercall interface.
Hypercall is a mechanism for inter-process communication in a virtualized environment that allows direct communication between a virtual machine monitor (e.g., hypervisor) and a virtual machine. Through the Hypercall interface, the virtual network data forwarding device may send a specific request to the target virtual machine informing it of the receipt of the data frame.
In step S230, the virtual machine manager, in response to receiving the request transmission data notification, acquires a second data frame from the shared memory between the virtual machine manager and the virtual machine.
In the implementation process, the identifier of the virtual machine can be carried in the request-to-send data notification, and after the virtual machine manager receives the request-to-send data notification, the address of the shared memory between the virtual machine manager and the virtual machine can be determined by utilizing the identifier of the virtual machine; the second data frame is read from the address.
In step S240, the second data frame is sent to the hardware network card by using the virtual network data forwarding device, so that the hardware network card forwards the second data frame to the physical network to which the hardware network card is connected.
In the specific implementation process, the virtual machine manager can send the second data frame to the hardware network card by using the virtual network data forwarding device; and the hardware network card forwards the second data frame to a physical network connected with the hardware network card according to the two-layer network forwarding protocol.
In the embodiment provided by the disclosure, a virtual network card arranged in any virtual machine responds to receiving a second data frame from an application program running in the virtual machine, and the second data frame is transmitted to a virtual machine manager by utilizing a shared memory between the virtual machine manager and the virtual machine; sending a request to send data notification to a virtual machine manager by using a hypercall interface; the virtual machine manager sends the second data frame to the hardware network card by using the virtual network data forwarding equipment; the hardware network card forwards the second data frame to a physical network to which the hardware network card is connected. Therefore, the process of transmitting the data frames on the virtual machine to the physical network through the shared hardware network card is efficiently realized.
Fig. 3 is a flowchart illustrating a method of receiving a data frame with a virtual network data forwarding device, according to one exemplary embodiment.
In this embodiment, as shown in fig. 6, the virtual network data forwarding device includes a multi-port first virtual bridge bridged with a hardware network card, and a back-end virtual network card corresponding to the virtual network card of each virtual machine, where the back-end virtual network card has the same mac address as the corresponding virtual network card, and all the back-end virtual network cards are connected to the first virtual bridge through different ports of the first virtual bridge.
As shown in fig. 3, the virtual network data forwarding device receives the first data frame and writes it into the shared memory by:
in step S310, the first virtual bridge receives a first data frame from the hardware network card.
In a specific implementation process, a first virtual bridge receives a first data frame from a hardware network card according to a two-layer network forwarding protocol. For a detailed description of the first data frame, refer to the relevant content in fig. 1, and will not be repeated here.
In a specific implementation process, the number of ports of the first virtual bridge may be determined according to the number of virtual machines included in the multi-virtual machine system, and in order to accurately implement the present embodiment, the number of ports of the first virtual bridge should be equal to or greater than the number of virtual machines.
The method of creating the first virtual bridge by different operating systems is different, and this application is not limited in this regard. For example only, the first virtual bridge may be established by:
installing a bridge-units tool, and creating a first virtual network bridge by using a brctl command line tool or a configuration network card file; configuring an IP address for the first virtual network bridge, or if the IP address needs to be automatically allocated to the virtual machine, configuring a DHCP for the first virtual network bridge; the first virtual bridge is started using a command line tool or a configuration network card file.
In step S320, the first data frame is forwarded to the destination port of the first virtual bridge corresponding to the destination mac address according to the destination mac address of the first data frame.
In the implementation process, each port of the first virtual bridge may be configured to correspond to a mac address of a virtual network card of one virtual machine, and the first virtual network card may forward the first data frame to a target port of the first virtual bridge corresponding to the destination mac address according to the destination mac address of the first data frame.
In step S330, the back-end virtual network card connected to the destination port receives the first data frame from the destination port.
In a specific implementation process, the back-end virtual network card receives a first data frame from the target port according to a two-layer data forwarding protocol.
In step S340, the back-end virtual network card stores the first data frame in the shared memory between the virtual machine manager and the target virtual machine according to the identifier of the target virtual machine.
In the implementation process, the back-end virtual network card can acquire a mapping table for recording the mapping relation between the mac address of the established virtual network card and the identifier of the virtual machine from the virtual machine manager, and according to the destination mac address, the identifier of the virtual machine waiting for receiving data is inquired from the mapping table.
For a detailed description of storing the first data frame in the shared memory between the virtual machine manager and the target virtual machine according to the identifier of the target virtual machine, refer to the relevant content in fig. 1, which is not repeated herein.
In the embodiment provided by the disclosure, a virtual network data forwarding device is formed by a multi-port first virtual network bridge associated with a hardware network card and a back-end virtual network card corresponding to the virtual network card of each virtual machine, so that the first virtual network bridge can be utilized to receive data from the hardware network card; and writing the received data into the shared memory by using the back-end virtual network card, and efficiently realizing the forwarding process of the first data frame from the hardware network card to the shared memory.
Fig. 4 is a flow chart illustrating yet another method of receiving a data frame with a virtual network data forwarding device, according to one exemplary embodiment.
In this embodiment, as shown in fig. 7, the virtual network data forwarding device is a second virtual bridge bridging with the hardware network card. As shown in fig. 4, the virtual network data forwarding device receives the first data frame and writes it into the shared memory by:
in step S410, the second virtual bridge receives the first data frame from the hardware network card.
In this embodiment, since the second virtual bridge does not need to forward the received first data frame to the destination port, the number of ports for the second virtual bridge is not limited. For the creation process of the second virtual bridge, refer to the creation process of the first virtual bridge in fig. 3, which is not described herein.
In a specific implementation process, the second virtual bridge receives the first data frame from the hardware network card according to a two-layer network forwarding protocol. For a detailed description of the first data frame, refer to the relevant content in fig. 1, and will not be repeated here.
In step S420, the second virtual bridge stores the first data frame in the shared memory between the virtual machine manager and the target virtual machine according to the identifier of the target virtual machine.
In the implementation process, the second virtual bridge may acquire, from the virtual machine manager, a mapping table that records a mapping relationship between the mac address of the established virtual network card and the identifier of the virtual machine, and query, from the mapping table, the identifier of the virtual machine waiting for receiving data according to the destination mac address.
For a detailed description of storing the first data frame in the shared memory between the virtual machine manager and the target virtual machine according to the identifier of the target virtual machine, refer to the relevant content in fig. 1, which is not repeated herein.
In some embodiments, in order to save storage space and increase the data processing speed, the receiving buffer of the second virtual bridge may be used as a shared memory. The second virtual bridge may add the identity of the target virtual machine to the starting location or the ending location of the first data frame such that the target virtual machine retrieves the first data frame from the receive buffer of the second virtual bridge according to its identity.
In the embodiment provided by the disclosure, the second virtual network bridge is used as a virtual network data forwarding device, and the process of receiving the first data frame from the hardware network card is realized by using the second virtual network bridge; and the second virtual network bridge stores the first data frame in the shared memory between the virtual machine manager and the target virtual machine according to the identification of the target virtual machine, and the forwarding process of the first data frame from the hardware network card to the shared memory is completed by using the second virtual network bridge, so that the transmission efficiency of network data is effectively improved.
Exemplary apparatus
Fig. 8 is a block diagram illustrating an apparatus for sharing a hardware network card in a multi-virtual machine system according to an exemplary embodiment. Referring to fig. 8, the apparatus 800 includes a first acquisition module 810, a first storage module 820, a first transmission module 830, and a second acquisition module 840.
The first obtaining module 810 is configured to enable a virtual network data forwarding device provided in the virtual machine manager to obtain, in response to receiving a first data frame from the hardware network card and sent to any one of the plurality of virtual machines, an identifier of a target virtual machine waiting to receive the first data frame according to a destination mac address of the first data frame by using a mapping relationship between a mac address of the established virtual network card and an identifier of the virtual machine.
A first storage module 820, configured to store the first data frame in a shared memory between the virtual machine manager and the target virtual machine according to the identifier of the target virtual machine; wherein the shared memory between the virtual machine manager and the target virtual machine is associated with an identity of the target virtual machine.
And the first sending module 830 is configured to send a request to receive a data notification to a virtual network card of the target virtual machine by using the identifier of the target virtual machine.
And a second obtaining module 840, configured to enable the virtual network card of the target virtual machine to obtain the first data frame from the shared memory in response to receiving the request to receive the data notification.
In some embodiments, the apparatus further comprises: the second storage module is used for enabling the virtual network card arranged in any virtual machine to respond to receiving a second data frame from an application program running in the virtual machine and storing the second data frame in a shared memory between the virtual machine manager and the virtual machine; the second sending module is used for sending a request to send a data notification to the virtual machine manager by utilizing a hypercall interface; a third obtaining module, configured to enable the virtual machine manager to send a data notification in response to receiving the request, and obtain the second data frame from a shared memory between the virtual machine manager and the virtual machine; and the third sending module is used for sending the second data frame to the hardware network card by utilizing the virtual network data forwarding equipment so as to enable the hardware network card to forward the second data frame to a physical network connected with the hardware network card.
In some embodiments, the apparatus further comprises: the initialization module is used for enabling the virtual machine manager to establish a mapping relation between a mac address allocated to a virtual network card of the virtual machine and an identifier of the virtual machine in response to receiving the virtual network card initialization request when any virtual machine sends the virtual network card initialization request to the virtual machine manager; and distributing a shared memory for the virtual machine, and establishing a mapping relation between the shared memory and the identifier of the virtual machine.
In some embodiments, the virtual network data forwarding device includes a multi-port first virtual bridge associated with the hardware network card, and a back-end virtual network card corresponding to a virtual network card of each virtual machine, where the back-end virtual network card has the same mac address as the corresponding virtual network card, and all back-end virtual network cards are connected to the first virtual bridge through different ports of the first virtual bridge; the virtual network data forwarding device receives the first data frame by: the first virtual network bridge receives the first data frame from the hardware network card; forwarding the first data frame to a target port of the first virtual bridge corresponding to the destination mac address according to the destination mac address of the first data frame; a back-end virtual network card connected with the target port, which receives the first data frame from the target port; storing the first data frame in a shared memory between the virtual machine manager and the target virtual machine according to the identifier of the target virtual machine, including: and the back-end virtual network card stores the first data frame in a shared memory between the virtual machine manager and the target virtual machine according to the identification of the target virtual machine.
In some embodiments, the virtual network data forwarding device is a second virtual bridge associated with the hardware network card; the virtual network data forwarding device receives the first data frame by: the second virtual network bridge receives the first data frame from the hardware network card; storing the first data frame in a shared memory between the virtual machine manager and the target virtual machine according to the identifier of the target virtual machine, including: and the second virtual network bridge stores the first data frame in a shared memory between the virtual machine manager and the target virtual machine according to the identification of the target virtual machine.
In some embodiments, the shared memory between the virtual machine manager and any virtual machine is established by: and taking the receiving buffer zone of the second virtual network bridge as the shared memory.
In some embodiments, the sending, with the identification of the target virtual machine, a request to receive data notification to a virtual network card of the target virtual machine includes: injecting network interruption carrying the request receiving data notification into a virtual network card of the target virtual machine by using the identification of the target virtual machine; or sending a request to receive data notification to the target virtual machine by using the hypercall interface by utilizing the identification of the target virtual machine.
In the above embodiment of the device for sharing a hardware network card in a multiple virtual machine system, the specific processing of each module and the technical effects brought by the processing may refer to the related descriptions in the corresponding method embodiments respectively, which are not described herein again.
Exemplary vehicle
Fig. 9 is a block diagram of a vehicle 900, according to an exemplary embodiment. The vehicle 900 may be a fuel-powered vehicle, a hybrid vehicle, an electric vehicle, a fuel cell vehicle, or other type of vehicle.
Referring to fig. 9, a vehicle 900 may include a plurality of subsystems, such as a drive system 910, a control system 920, a perception system 930, a communication system 940, an information display system 950, and a computing processing system 960. Vehicle 900 may also include more or fewer subsystems, and each subsystem may also include multiple components, which are not described in detail herein.
The drive system 910 includes components that provide powered movement of the vehicle 900. Such as an engine, energy source, transmission, etc.
The control system 920 includes components that provide control for the vehicle 900. Such as vehicle control, cabin equipment control, driving assistance control, etc.
The perception system 930 includes components that provide ambient environment perception for the vehicle 900. For example, a vehicle positioning system, a laser sensor, a voice sensor, an ultrasonic sensor, an image pickup apparatus, and the like.
The communication system 940 includes components that provide communication connections for the vehicle 900. For example, mobile communication networks (e.g., 3G, 4G, 5G networks, etc.), wiFi, bluetooth, internet of vehicles, etc.
The information display system 950 includes components that provide various information displays for the vehicle 900. For example, vehicle information display, navigation information display, entertainment information display, and the like.
The computing processing system 960 includes components that provide data computing and processing capabilities for the vehicle 900. The computing processing system 960 can include at least one processor 961 and memory 962. Processor 961 may execute instructions stored in memory 962.
The processor 961 may be any conventional processor, such as a commercially available CPU. The processor may also include, for example, an image processor (Graphic Process Unit, GPU), a field programmable gate array (Field Programmable Gate Array, FPGA), a System On Chip (SOC), an application specific integrated Chip (Application Specific Integrated Circuit, ASIC), or a combination thereof.
The memory 962 may be implemented by any type of volatile or non-volatile memory device or combination thereof, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
In the disclosed embodiment, the memory 962 has stored therein a set of instructions that the processor 961 may execute to implement all or part of the steps of the method for sharing a hardware network card in a multi-virtual machine system described in any of the above exemplary embodiments.
Exemplary electronicsApparatus and method for controlling the operation of a device
Fig. 10 is a block diagram of an electronic device 1000, shown in accordance with an exemplary embodiment. The electronic device 1000 may be a vehicle controller, an in-vehicle terminal, an in-vehicle computer, or other type of electronic device.
Referring to fig. 10, an electronic device 1000 may include at least one processor 1010 and memory 1020. The processor 1010 may execute instructions stored in the memory 1020. The processor 1010 is communicatively coupled to the memory 1020 via a data bus. In addition to memory 1020, processor 1010 may be communicatively coupled with input devices 1030, output devices 1040, and communication devices 1050 via a data bus.
The processor 1010 may be any conventional processor, such as a commercially available CPU. The processor may also include, for example, an image processor (Graphic Process Unit, GPU), a field programmable gate array (Field Programmable Gate Array, FPGA), a System On Chip (SOC), an application specific integrated Chip (Application Specific Integrated Circuit, ASIC), or a combination thereof.
The memory 1020 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
In the embodiment of the present disclosure, the memory 1020 stores executable instructions, and the processor 1010 may read the executable instructions from the memory 1020 and execute the instructions to implement all or part of the steps of the method for sharing a hardware network card in a multiple virtual machine system according to any one of the above exemplary embodiments.
Exemplary computer-readable storage Medium
In addition to the methods and apparatus described above, exemplary embodiments of the present disclosure may also be a computer program product or a computer readable storage medium storing the computer program product. The computer program product comprises computer program instructions executable by a processor to perform all or part of the steps described in any of the methods of the exemplary embodiments described above.
The computer program product may write program code for performing the operations of embodiments of the present application in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages, as well as scripting languages (e.g., python). The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device, partly on a remote computing device, or entirely on the remote computing device or server.
The computer readable storage medium may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may include, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the readable storage medium include: a Static Random Access Memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic memory, a flash memory, a magnetic or optical disk, or any suitable combination of the foregoing having one or more electrical conductors.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure. This application is intended to cover any adaptations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It is to be understood that the present disclosure is not limited to the precise arrangements and instrumentalities shown in the drawings, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (10)

1. A method of sharing a hardware network card in a multi-virtual machine system, wherein a system on a chip including the hardware network card is shared with a plurality of virtual machines in the multi-virtual machine system through a virtual machine manager, the method comprising:
the virtual network data forwarding device is arranged on the virtual machine manager, responds to the first data frame received from the hardware network card and sent to any one of the plurality of virtual machines, and acquires the identification of the target virtual machine waiting for receiving the first data frame according to the destination mac address of the first data frame by utilizing the mapping relation between the mac address of the established virtual network card and the identification of the virtual machine;
According to the identification of the target virtual machine, storing the first data frame in a shared memory between the virtual machine manager and the target virtual machine; wherein a shared memory between the virtual machine manager and the target virtual machine is associated with an identity of the target virtual machine;
sending a request receiving data notification to a virtual network card of the target virtual machine by using the identification of the target virtual machine;
and the virtual network card of the target virtual machine responds to the received data notification request and acquires the first data frame from the shared memory.
2. The method according to claim 1, wherein the method further comprises:
the virtual network card is arranged in any virtual machine, and responds to receiving a second data frame from an application program running in the virtual machine, and the second data frame is stored in a shared memory between the virtual machine manager and the virtual machine; and
sending a request to send data notification to the virtual machine manager by using a hypercall interface;
the virtual machine manager responds to the received request to send a data notification, and the second data frame is acquired from a shared memory between the virtual machine manager and the virtual machine; and
And transmitting the second data frame to the hardware network card by using the virtual network data forwarding device so that the hardware network card forwards the second data frame to a physical network connected with the hardware network card.
3. The method according to claim 1 or 2, characterized in that the method further comprises:
when any virtual machine is initialized, a virtual network card initialization request is sent to the virtual machine manager;
the virtual machine manager responds to the received virtual network card initialization request and establishes a mapping relation between a mac address allocated for the virtual network card of the virtual machine and the identifier of the virtual machine; and
and distributing a shared memory for the virtual machine, and establishing a mapping relation between the shared memory and the identifier of the virtual machine.
4. The method of claim 1, wherein the virtual network data forwarding device comprises a multi-port first virtual bridge associated with the hardware network card, and a back-end virtual network card corresponding to the virtual network card of each virtual machine, the back-end virtual network card being identical to the mac address of its corresponding virtual network card, all back-end virtual network cards being connected to the first virtual bridge through different ports of the first virtual bridge;
The virtual network data forwarding device receives the first data frame by:
the first virtual network bridge receives the first data frame from the hardware network card; and
forwarding the first data frame to a target port of the first virtual bridge corresponding to the destination mac address according to the destination mac address of the first data frame;
a back-end virtual network card connected with the target port, which receives the first data frame from the target port;
storing the first data frame in a shared memory between the virtual machine manager and the target virtual machine according to the identifier of the target virtual machine, including:
and the back-end virtual network card stores the first data frame in a shared memory between the virtual machine manager and the target virtual machine according to the identification of the target virtual machine.
5. The method of claim 1, wherein the virtual network data forwarding device is a second virtual bridge associated with the hardware network card;
the virtual network data forwarding device receives the first data frame by:
the second virtual network bridge receives the first data frame from the hardware network card;
Storing the first data frame in a shared memory between the virtual machine manager and the target virtual machine according to the identifier of the target virtual machine, including:
and the second virtual network bridge stores the first data frame in a shared memory between the virtual machine manager and the target virtual machine according to the identification of the target virtual machine.
6. The method of claim 5, wherein the shared memory between the virtual machine manager and any virtual machine is established by:
and taking the receiving buffer zone of the second virtual network bridge as the shared memory.
7. An apparatus for sharing a hardware network card in a multiple virtual machine system, comprising:
the first acquisition module is used for enabling the virtual network data forwarding equipment arranged on the virtual machine manager to respond to the received first data frame which is from the hardware network card and is sent to any one of the plurality of virtual machines, and acquiring the identification of the target virtual machine waiting for receiving the first data frame by utilizing the mapping relation between the established mac address of the virtual network card and the identification of the virtual machine according to the destination mac address of the first data frame;
The first storage module is used for storing the first data frame in a shared memory between the virtual machine manager and the target virtual machine according to the identification of the target virtual machine; wherein a shared memory between the virtual machine manager and the target virtual machine is associated with an identity of the target virtual machine;
the first sending module is used for sending a request receiving data notification to a virtual network card of the target virtual machine by utilizing the identification of the target virtual machine;
and the second acquisition module is used for enabling the virtual network card of the target virtual machine to respond to the received data notification request and acquire the first data frame from the shared memory.
8. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
the processor is configured to read the executable instructions from the memory and execute the instructions to implement the method for sharing a hardware network card in a multiple virtual machine system according to any one of claims 1-6.
9. A computer readable storage medium having stored thereon computer program instructions, which when executed by a processor, perform the steps of the method of sharing a hardware network card in a multi-virtual machine system as claimed in any of claims 1-6.
10. A vehicle is characterized in that,
a set of instructions stored for execution by the vehicle to implement the method of sharing a hardware network card in a multiple virtual machine system of any one of claims 1-6.
CN202311826410.7A 2023-12-27 2023-12-27 Method and device for sharing hardware network card in multi-virtual machine system and electronic equipment Pending CN117880221A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311826410.7A CN117880221A (en) 2023-12-27 2023-12-27 Method and device for sharing hardware network card in multi-virtual machine system and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311826410.7A CN117880221A (en) 2023-12-27 2023-12-27 Method and device for sharing hardware network card in multi-virtual machine system and electronic equipment

Publications (1)

Publication Number Publication Date
CN117880221A true CN117880221A (en) 2024-04-12

Family

ID=90585954

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311826410.7A Pending CN117880221A (en) 2023-12-27 2023-12-27 Method and device for sharing hardware network card in multi-virtual machine system and electronic equipment

Country Status (1)

Country Link
CN (1) CN117880221A (en)

Similar Documents

Publication Publication Date Title
CN107733839B (en) Data transmission method and system
US10659280B2 (en) Vehicle-based communication method, system, and apparatus
US20230153099A1 (en) Gateway device, in-vehicle network system, and firmware update method
US9973351B2 (en) Data processing method and apparatus, storage controller, and cabinet
CN108322325B (en) Virtual machine management method and device
US20200193027A1 (en) Firmware upgrade method, slave station of robot, and machine readable storage medium
US10657095B2 (en) Virtualizing connection management for virtual remote direct memory access (RDMA) devices
CN114327137A (en) Touch method and device based on multiple vehicle-mounted operating systems and computer equipment
CN114201268B (en) Data processing method, device and equipment and readable storage medium
CN109808697B (en) Vehicle control method, device and equipment
CN110990110A (en) Virtual machine creation method and device based on Sriov network card
CN113419845A (en) Calculation acceleration method and device, calculation system, electronic equipment and computer readable storage medium
CN109257955B (en) Method for operating hard disk and hard disk manager
CN112055251A (en) Media data playing method, device, equipment and storage medium
EP4300298A1 (en) Vehicular display device
CN115103036A (en) Efficient TCP/IP datagram processing method and system
CN117880221A (en) Method and device for sharing hardware network card in multi-virtual machine system and electronic equipment
CN111221660B (en) Method, apparatus and storage medium for I2C device management in a stacked system
US20200021862A1 (en) Multimedia streaming and routing apparatus and operation method of the same
CN113434089B (en) Data moving method and device and PCIE system
CN113660123B (en) Virtual switch upgrading method, device, electronic equipment and storage medium
CN115291998A (en) Rbd-nbd mapping method and device
US20200201667A1 (en) Virtual machine live migration method, apparatus, and system
CN109150810B (en) Set top box convergence gateway and starting method, device and storage medium thereof
CN116418848A (en) Method and device for processing configuration and access requests of network nodes

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination