CN107544930B - Transparent transmission method and device for communication port - Google Patents

Transparent transmission method and device for communication port Download PDF

Info

Publication number
CN107544930B
CN107544930B CN201610480633.6A CN201610480633A CN107544930B CN 107544930 B CN107544930 B CN 107544930B CN 201610480633 A CN201610480633 A CN 201610480633A CN 107544930 B CN107544930 B CN 107544930B
Authority
CN
China
Prior art keywords
port
communication
port information
information
communication port
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.)
Active
Application number
CN201610480633.6A
Other languages
Chinese (zh)
Other versions
CN107544930A (en
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.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies 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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201610480633.6A priority Critical patent/CN107544930B/en
Priority to PCT/CN2017/086905 priority patent/WO2018001037A1/en
Publication of CN107544930A publication Critical patent/CN107544930A/en
Application granted granted Critical
Publication of CN107544930B publication Critical patent/CN107544930B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Small-Scale Networks (AREA)

Abstract

The embodiment of the invention discloses a transparent transmission method and a transparent transmission device for a communication port, wherein the method comprises the following steps: when a first communication port of a host machine is transmitted to a virtual machine, first port information of the first communication port is extracted; acquiring port information of each communication port in a host machine; determining second port information matched with the first port information in the port information of all communication ports of the host machine; and transmitting the second communication port corresponding to the second port information to the virtual machine. The scheme provided by the invention can automatically transmit the second communication port on the cascade equipment of the first communication port to the virtual machine under the condition that the first communication port is transmitted to the virtual machine.

Description

Transparent transmission method and device for communication port
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a transparent transmission method and apparatus for a communication port.
Background
Currently, virtualization technologies include virtualization of communication ports in addition to virtualization of processors. In order to ensure that the communication port can be exclusively used by the operating system of the virtual machine, a passthrough (passthrough) technology is required to pass through the communication port to the virtual machine. Transparent communication of a communication port to a virtual machine refers to providing communication port isolation to the operating system of the virtual machine so that the communication port can be exclusively used by the operating system of the virtual machine.
When the communication port of the host machine is transmitted to the virtual machine by using the transmission technology, the virtual machine can use the communication port. However, if the user expands the cascade device on the communication port, the virtual machine cannot identify the communication port of the cascade device, so that the virtual machine cannot use the communication port of the cascade device.
For example, assume that the communication port is a Universal Serial Bus (USB) port, the host has 3 USB ports, the 3 USB ports are respectively a port x1, a port x2 and a port x3, the host is provided with a virtual machine a, and the host passes through the port x1 to the virtual machine a, so that the virtual machine a can monopolize the port x1. At this time, the user connects a USB hub, which is a tandem device, to the port x1, and the USB hub has 2 ports, i.e., the port x1.1 and the port x1.2, which is equivalent to extending the port x1 to the port x1.1 and the port x1.2 by using the USB hub. Although the user wants to pass the ports x1.1 and x1.2 of the USB hub through to virtual machine a for use, virtual machine a cannot recognize the ports x1.1 and x1.2 of the USB hub, so virtual machine a cannot use the ports x1.1 and x 1.2.
Therefore, how to automatically pass through the communication port on the cascade device of the communication port to the virtual machine under the condition that the communication port is passed through to the virtual machine becomes a technical problem which needs to be solved at present.
Disclosure of Invention
The embodiment of the invention provides a transparent transmission method and a transparent transmission device of a communication port, which are used for automatically transmitting a second communication port on cascade equipment of a first communication port to a virtual machine under the condition that the first communication port is transmitted to the virtual machine.
The first aspect of the present invention provides a transparent transmission method for a communication port, where the method is applied to a host machine equipped with a virtual machine, and the method includes:
when a first communication port of the host machine is transmitted to the virtual machine, extracting first port information of the first communication port;
acquiring port information of each communication port in the host machine;
determining second port information matched with the first port information in port information of all communication ports of the host, wherein a second communication port corresponding to the second port information is a communication port of the cascade equipment of the first communication port;
and transmitting a second communication port corresponding to the second port information to the virtual machine.
With reference to the first aspect, in a first possible implementation manner, after the step of obtaining port information of each communication port in the host, the method further includes:
judging whether second port information matched with the first port information exists in the port information of all the communication ports or not;
when the second port information matched with the first port information exists in the port information of all the communication ports, executing a step of determining the second port information matched with the first port information in the port information of all the communication ports;
and when the second port information matched with the first port information does not exist in the port information of all the communication ports, waiting for a preset time, and executing the step of acquiring the port information of each communication port in the host again.
With reference to the first aspect, in a second possible implementation manner, after the step of extracting the first port information of the first communication port, the method further includes:
listening to the first communication port for the first communication port,
judging whether an insertion event of the first communication port is monitored;
when monitoring the insertion event of the first communication port, executing the step of acquiring the port information of each communication port in the host machine;
when the insertion event of the first communication port is not monitored, the first communication port is monitored continuously.
With reference to the first aspect, the first possible implementation manner of the first aspect, or the second possible implementation manner of the first aspect, in a third possible implementation manner, when the port information of the communication port is a port number, the step of determining, from the port information of all communication ports of the host, second port information that is matched with the first port information includes:
determining a third port number which is the same as a prefix portion of the first port number among the port numbers of all the communication ports;
determining the second port number in the third port number that contains a suffix portion.
With reference to the first aspect, the first possible implementation manner of the first aspect, or the second possible implementation manner of the first aspect, in a fourth possible implementation manner, when the port information of the communication port includes a port number and a bus number, the step of determining, from the port information of all communication ports of the host, second port information that is matched with the first port information includes:
determining fourth port information having a bus number of the first port information among port information of all the communication ports;
determining fifth port information which is identical to a prefix part of the port number of the first port information in the fourth port information;
determining the second port information containing a suffix part in a port number of the fifth port information.
The second aspect of the present invention provides another transparent transmission method for a communication port, where the method is applied to a network device installed with a virtual machine, and the method includes:
acquiring port information of each communication port in the network equipment;
determining second port information matched with the first port information in the port information of all communication ports of the network equipment, wherein a second communication port corresponding to the second port information is a communication port of cascade equipment of the first communication port corresponding to the first port information; the first communication port is any one of the communication ports;
sending the matching relation of the first port information and the second port information to a network controller;
and when an instruction sent by the network controller and used for transmitting the second communication port corresponding to the second port information to the virtual machine is received, transmitting the second communication port corresponding to the second port information to the virtual machine.
With reference to the second aspect, in a first possible implementation manner, after the step of obtaining the port information of each communication port in the network device, the method further includes:
judging whether second port information matched with the first port information exists in the port information of all the communication ports or not;
when the second port information matched with the first port information exists in the port information of all the communication ports, executing a step of determining the second port information matched with the first port information in the port information of each communication port;
and when the second port information matched with the first port information does not exist in the port information of all the communication ports, waiting for a preset time, and executing the step of acquiring the port information of each communication port in the network equipment again.
With reference to the second aspect, in a second possible implementation manner, before the step of obtaining the port information of each communication port in the network device, the method further includes:
monitoring each communication port of the network equipment;
judging whether an insertion event of the first communication port is monitored;
when monitoring the insertion event of the first communication port, executing the step of acquiring the port information of each communication port in the network equipment;
when the insertion event of the first communication port is not monitored, the step of monitoring each communication port is continuously executed.
With reference to the second aspect, the first possible implementation manner of the second aspect, or the second possible implementation manner of the second aspect, in a third possible implementation manner, when the port information of the communication port is a port number, the step of determining, from the port information of all the communication ports, second port information that matches the first port information includes:
determining a third port number which is the same as a prefix portion of the first port number among the port numbers of all the communication ports;
determining the second port number in the third port number that contains a suffix portion.
With reference to the second aspect, the first possible implementation manner of the second aspect, or the second possible implementation manner of the second aspect, in a fourth possible implementation manner, when the port information of the communication port includes a port number and a bus number, the step of determining, from the port information of all the communication ports, second port information that matches the first port information includes:
determining fourth port information having a bus number of the first port information among port information of all the communication ports;
determining fifth port information which is identical to a prefix part of the port number of the first port information in the fourth port information;
determining the second port information containing a suffix part in a port number of the fifth port information.
The third aspect of the present invention provides another transparent transmission method for a communication port, which is applied to a network controller, and the method includes:
receiving a matching relation between first port information and second port information sent by a network device, wherein a second communication port corresponding to the second port information is a communication port of a cascade device of a first communication port corresponding to the first port information;
storing the matching relation of the first port information and the second port information;
and when receiving an instruction for transmitting a second communication port corresponding to the second port information to the virtual machine, sending the instruction to the network equipment.
A fourth aspect of the present invention provides a transparent transmission device for a communication port, where the device is a host, and the device includes:
the extraction unit is used for extracting first port information of a first communication port when the first communication port of the host machine is transmitted to the virtual machine;
the acquisition unit is used for acquiring port information of each communication port in the host machine;
a determining unit, configured to determine, in port information of all communication ports of the host, second port information that is matched with the first port information, where a second communication port corresponding to the second port information is a communication port of the cascade device of the first communication port;
and the transparent transmission unit is used for transmitting the second communication port corresponding to the second port information to the virtual machine.
With reference to the fourth aspect, in a first possible implementation manner, the apparatus further includes:
a first judging unit, configured to judge whether second port information that matches the first port information exists in the port information of all the communication ports; triggering the determining unit when the second port information matched with the first port information exists in the port information of all the communication ports; or when the second port information matched with the first port information does not exist in the port information of all the communication ports, waiting for a preset time and triggering the acquisition unit.
With reference to the fourth aspect, in a second possible implementation manner, the apparatus further includes:
a listening unit for listening to the first communication port,
a second judging unit, configured to judge whether an insertion event of the first communication port is monitored; when monitoring the insertion event of the first communication port, triggering the acquisition unit; or when the insertion event of the first communication port is not monitored, triggering the monitoring unit.
With reference to the fourth aspect, the first possible implementation manner of the fourth aspect, or the second possible implementation manner of the fourth aspect, in a third possible implementation manner, the determining unit is specifically configured to:
determining a third port number which is the same as a prefix portion of the first port number among the port numbers of all the communication ports; and determining the second port number in the third port number that contains a suffix portion.
With reference to the fourth aspect, the first possible implementation manner of the fourth aspect, or the second possible implementation manner of the fourth aspect, in a fourth possible implementation manner, the determining unit is specifically configured to:
determining fourth port information having a bus number of the first port information among port information of all the communication ports; determining fifth port information which is identical to a prefix part of the port number of the first port information in the fourth port information; and determining the second port information including a suffix part in a port number of the fifth port information.
A fifth aspect of the present invention provides a transparent transmission apparatus for a communication port, where the apparatus is a network device, and the apparatus includes:
an obtaining unit, configured to obtain port information of each communication port in the network device;
a determining unit, configured to determine, in port information of all communication ports of the network device, second port information that is matched with first port information, where a second communication port corresponding to the second port information is a communication port of a cascade device of a first communication port corresponding to the first port information; the first communication port is any one of the communication ports;
a sending unit, configured to send the matching relationship between the first port information and the second port information to a network controller;
and the transparent transmission unit is used for transmitting the second communication port corresponding to the second port information to the virtual machine when receiving an instruction which is sent by the network controller and used for transmitting the second communication port corresponding to the second port information to the virtual machine.
With reference to the fifth aspect, in a first possible implementation manner, the apparatus further includes:
a first judging unit, configured to judge whether second port information that matches the first port information exists in the port information of all the communication ports; when the second port information matched with the first port information exists in the port information of all the communication ports, triggering the determining unit; or when the second port information matched with the first port information does not exist in the port information of all the communication ports, waiting for a preset time, and triggering the acquisition unit again.
With reference to the fifth aspect, in a second possible implementation manner, the apparatus further includes:
the monitoring unit is used for monitoring each communication port of the network equipment;
a second judging unit, configured to judge whether an insertion event of the first communication port is monitored; when monitoring the insertion event of the first communication port, triggering the acquisition unit; or when the insertion event of the first communication port is not monitored, the monitoring unit is continuously triggered.
With reference to the fifth aspect, the first possible implementation manner of the fifth aspect, or the second possible implementation manner of the fifth aspect, in a third possible implementation manner, the determining unit is specifically configured to: determining a third port number which is the same as a prefix portion of the first port number among the port numbers of all the communication ports; and determining the second port number in the third port number that contains a suffix portion.
With reference to the fifth aspect, the first possible implementation manner of the fifth aspect, or the second possible implementation manner of the fifth aspect, in a fourth possible implementation manner, the determining unit is specifically configured to:
determining fourth port information having a bus number of the first port information among port information of all the communication ports; determining fifth port information which is identical to a prefix part of the port number of the first port information in the fourth port information; and determining the second port information including a suffix part in a port number of the fifth port information.
A sixth aspect of the present invention provides another transparent transmission apparatus for a communication port, which is applied to a network controller, and includes:
a receiving unit, configured to receive a matching relationship between first port information and second port information sent by a network device, where a second communication port corresponding to the second port information is a communication port of a cascade device of a first communication port corresponding to the first port information;
the storage unit is used for storing the matching relation between the first port information and the second port information;
and the sending unit is used for sending the instruction to the network equipment when receiving the instruction which is transmitted to the virtual machine through the second communication port corresponding to the second port information.
The seventh aspect of the present invention provides a transparent transmission device for a communication port, including: the processor and the memory, wherein the memory stores therein operation instructions executable by the processor, and the processor reads the operation instructions in the memory to: implementing the method of the first aspect of the invention and its various implementations; or implementing the method of the second aspect of the invention and its various implementations; or a method implementing the third aspect of the invention and implementations thereof.
Compared with the prior art, the technical scheme provided by the embodiment has the following advantages and characteristics:
in the scheme provided by the invention, if a user expands a second communication port on a first communication port, the second communication port is a cascade device of the first communication port, and second port information of the second communication port is matched with first port information of the first communication port, so that when the first communication port of a host is transmitted to a virtual machine, the first port information of the first communication port and the port information of each communication port in the host need to be extracted, and then the second port information matched with the first port information is determined in the port information of all the communication ports, so that the second port information of the second communication port cascaded with the first communication port is found in the port information of each communication port, and then the second communication port corresponding to the second port information is transmitted to the virtual machine. Therefore, the scheme provided by the invention can automatically transmit the second communication port on the cascade device of the first communication port to the virtual machine under the condition that the first communication port is transmitted to the virtual machine.
Drawings
In order to more clearly illustrate the technical solution in the embodiments of the present invention, the drawings required to be used in the embodiments will be briefly described below.
Fig. 1 is a flowchart of a transparent transmission method for a communication port according to an embodiment of the present invention;
FIG. 2 is a block diagram of a host according to an embodiment of the present invention;
fig. 3 is a schematic diagram illustrating a framework of a network controller 2 and a network device 3 according to an embodiment of the present invention;
fig. 4 is a flowchart of a transparent transmission method for a communication port according to another embodiment of the present invention;
fig. 5 is a flowchart of a transparent transmission method for a communication port according to another embodiment of the present invention;
fig. 6 is a flowchart of a transparent transmission method for a communication port according to another embodiment of the present invention;
fig. 7 is a flowchart of a transparent transmission method for a communication port according to another embodiment of the present invention;
fig. 8 is a flowchart of a transparent transmission method for a communication port according to another embodiment of the present invention;
fig. 9 is a flowchart of a transparent transmission method for a communication port according to another embodiment of the present invention;
fig. 10 is a schematic diagram of a framework of the network controller 4 and the network device 5 according to an embodiment of the present invention;
fig. 11 is a schematic diagram of a transparent transmission device of a communication port according to an embodiment of the present invention;
fig. 12 is a schematic diagram of a transparent transmission device of a communication port according to another embodiment of the present invention;
fig. 13 is a schematic diagram of a transparent transmission device of a communication port according to another embodiment of the present invention;
fig. 14 is a schematic diagram of a transparent transmission device of a communication port according to another embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention.
Fig. 1 is a flowchart of a transparent transmission method for a communication port according to an embodiment of the present invention. The transparent transmission method of the communication port shown in fig. 1 may automatically transmit the second communication port on the cascade device of the first communication port to the virtual machine in the case that the first communication port has been transmitted to the virtual machine. The method comprises the following steps.
Step S11, when the first communication port of the host is passed through to the virtual machine, extracting first port information of the first communication port.
The method provided by the invention can be applied to a host machine provided with a virtual machine, and the host machine can be a computer, a switch or a router and other equipment. The host has at least one communication port, which may be a USB port, or may be other types of ports.
The port information of the communication port may be different information according to different situations. For example, if the bus numbers of all communication ports on the host are the same, the port information of the communication ports may be the port number. As another example, if there is a case where the bus number of one communication port is not the same as the bus number of another port on the host, the port information of the communication port may include the bus number and the port number.
Under the condition that the bus numbers of all communication ports on the host machine are the same, when the first communication port of the host machine is transmitted to the virtual machine, the extracted first port information is the port number. For example, assume that a host has 3 communication ports, which are port x1, port x2, and port x3, respectively, where the port number of port x1 is p1, the port number of port x2 is p2, the port number of port x3 is p3, and the host is provided with a virtual machine a. When the user passes port x1 of the host machine through to virtual machine a, the host machine needs to extract port number p1 of port x1.
Under the condition that the bus number of one communication port is different from the bus number of the other port on the host machine, when the first communication port of the host machine is transmitted to the virtual machine, first port information of the first communication port needs to be extracted, and at the moment, the first port information comprises the bus number and the port number. For example, assume that a host has 3 communication ports, which are a port x1, a port x2, and a port x3, respectively, where the port number of the port x1 is p1, the bus number of the port x1 is b1, the port number of the port x2 is p2, the bus number of the port x2 is b2, the port number of the port x3 is p3, and the bus number of the port x3 is b3, and the host is provided with a virtual machine a. When the user passes port x1 of the host through to virtual machine a, then the host needs to fetch port x1 with bus number b1 and port number p1.
The first communication port is a communication port on the host machine, the first communication port refers to a communication port which is transmitted to the virtual machine from the host machine, and the number of the first communication ports is at least one. For example, assuming that a host has 3 communication ports, namely a port x1, a port x2 and a port x3, and the host is provided with a virtual machine a, if a user passes through the port x1 to the virtual machine a, the first communication port is a port x 1; if the user passes port x1, port x2, and port x3 through to virtual machine A, then the first communication ports are port x1, port x2, and port x 3.
The method provided by the invention can be applied to different technical scenes. For example, the method provided by the invention can be applied to a scene that a user interacts with a host. For another example, the method provided by the present invention may also be applied to an interaction scenario between a network controller and a network device, where the network device is a host.
In a scene that a user interacts with a host machine, if the user needs to pass a first communication port of the host machine through to a virtual machine, the user inputs an instruction for passing the first communication port through to the virtual machine to the host machine by using an input device. When the host machine receives an instruction which is input to the host machine by the user through the input equipment and is used for transmitting the first communication port to the virtual machine, the host machine transmits the first communication port to the virtual machine according to the instruction, so that the virtual machine can monopolize the first communication port.
In the interaction scenario of the network controller and the network device, the network administrator may control the network device through the network controller. If the network administrator needs to pass through the first communication port of the network device to the virtual machine, the network administrator sends an instruction to the network device to pass through the first communication port to the virtual machine using the network controller. When the network device receives an instruction sent by a network administrator to the network device by using the network controller to pass the first communication port through to the virtual machine, the network device passes the first communication port through to the virtual machine according to the instruction, so that the virtual machine can monopolize the first communication port.
And step S12, acquiring the port information of each communication port in the host.
After the host machine extracts the first port information of the first communication port, the host machine further needs to obtain the port information of each communication port in the host machine. Each communication port in a host refers to all communication ports on the host.
For example, when the port information is a port number, the host has 3 communication ports, namely a port x1, a port x2 and a port x3, wherein the port number of the port x1 is p1, the port number of the port x2 is p2, the port number of the port x3 is p3, and the host is provided with a virtual machine a. When the user passes port x1 of the host through to virtual machine a, then the host needs to fetch port number p1 of port x1. Then, the host further needs to acquire port numbers p1, p2, and p3 of each communication port in the host.
Step S13, determining second port information matched with the first port information in the port information of all the communication ports of the host, where the second communication port corresponding to the second port information is a communication port of the cascade device of the first communication port.
After the host obtains the port information of each communication port in the host, the host needs to determine the second port information matched with the first port information from the port information of all the communication ports. The second port information refers to port information matched with the first port information, and the number of the second communication ports is at least one.
If the second communication port is cascaded on the first communication port, the port information of all the communication ports on the host machine comprises the second port information of the second communication port, and the second port information and the first port information have certain similarity. For example, when the port information is a port number, then the first port information is a first port number and the second port information is a second port number, and assuming that the first port number is p1 and the second port number is p1.3, the same point is that the prefix portions of the first port number and the second port number are both p1, with the difference that the second port number has a suffix portion of.3, and the first port number does not have a suffix portion.
Therefore, the method provided by the embodiment of the present invention can query, in the port information of all the communication ports, the second port information that is the same as the prefix portion of the first port information and has the suffix portion, and at this time, it can be known that the second communication port corresponding to the second port information is the communication port of the cascade device of the first communication port.
Since there are a plurality of specific implementations of determining the second port information matching the first port information among the port information of all the communication ports, two ways are briefly described below. Of course, the present invention is not limited to the following two modes.
In the first mode, when the port information of the communication port is a port number, determining the second port information that matches the first port information among the port information of all the communication ports may include: first, a third port number identical to the prefix portion of the first port number is determined among the port numbers of all the communication ports. Then, a second port number having a suffix portion is determined in the third port number.
The implementation of the first mode is described below by way of example. For example, assuming that the port information is a port number, the host has 3 communication ports, which are respectively a port x1, a port x2 and a port x3, where the port number of the port x1 is p1, the port number of the port x2 is p2, the port number of the port x3 is p3, and the host is provided with a virtual machine a. Suppose a user connects a USB hub as a tandem device to port x1, and the USB hub has 2 ports, i.e., port x4 and port x5, on the USB hub, the port number of port x4 is p1.1, and the port number of port x5 is p 1.2. When the user passes port x1 of the host machine through to virtual machine a, the host machine needs to extract port number p1 of port x1. Then, the host further needs to acquire port numbers p1, p2, p3, p1.1, and p1.2 of each communication port in the host. At this time, the host determines the same port numbers p1, p1.1, and p1.2 as the prefix portion p1 of the port number p1 among all the port numbers p1, p2, p3, p1.1, and p 1.2. Then, the second port numbers p1.1 and p1.2 containing suffix parts are determined among the port numbers p1, p1.1, and p 1.2.
In a second mode, when the port information of the communication ports includes a port number and a bus number, determining second port information that matches the first port information among the port information of all the communication ports may include: first, fourth port information having the bus number of the first port information is determined among the port information of all the communication ports. Then, fifth port information identical to a prefix part of the port number of the first port information is determined in the fourth port information. Finally, the second port information having the suffix part is determined in the port number of the fifth port information.
The execution of the second mode will be described below by way of example. For example, assume that the port information includes a bus number and a port number, and the host has 3 communication ports, port x1 and port x2, respectively, wherein the port information of port x1 includes a port number p1 and a bus number b1, i.e., b1-p 1; the port information of the port x2 includes a port number p1 and a bus number b2, i.e., b2-p1, and the host machine is provided with a virtual machine a. Assuming that a user connects a cascade device USB extension line to port x1 and the cascade device USB extension line has 1 port, the port information of port x3 includes port number p1.1 and bus number b1, i.e., b1-p1.1, for port x 3. When the user passes the port x1 of the host machine to the virtual machine A, the host machine needs to extract the port information b1-p1 of the port x1. Then, the host also needs to acquire port information b1-p1, b2-p1 and b1-p1.1 of each communication port in the host. At this time, the host determines port information b1-p1 and b1-p1.1 of the bus number b1 having the port information b1-p1 among all the port information b1-p1, b2-p1 and b1-p 1.1. Secondly, the host determines port information b1-p1 and b1-p1.1, which are the same as the prefix portion p1 of the port number p1 of the port information b1-p1, among the port information b1-p1 and b1-p 1.1. Finally, the host determines the port information b1-p1.1 containing the suffix part.1 in the port numbers p1 and p1.1 of the port information b1-p1 and b1-p 1.1.
And step S14, transmitting the second communication port corresponding to the second port information to the virtual machine.
After the host determines second port information matched with the first port information in the port information of all the communication ports, the host can transmit the second communication port corresponding to the second port information to the virtual machine, so that the second communication port on the cascade equipment of the first communication port is automatically transmitted to the virtual machine under the condition that the first communication port is transmitted to the virtual machine.
In the embodiment shown in fig. 1, if a user expands a second communication port on a first communication port, the second communication port is a cascade device of the first communication port, and second port information of the second communication port is matched with first port information of the first communication port, so when the first communication port of a host is transmitted to a virtual machine, it is necessary to extract the first port information of the first communication port and port information of each communication port in the host, and then determine second port information matched with the first port information from the port information of all the communication ports, so as to find the second port information of the second communication port cascaded with the first communication port from the port information of each communication port, and then transmit the second port corresponding to the second port information to the virtual machine. Therefore, the scheme provided by the invention can automatically transmit the second communication port on the cascade device of the first communication port to the virtual machine under the condition that the first communication port is transmitted to the virtual machine.
In order to explain the embodiment shown in fig. 1 more clearly, the embodiment shown in fig. 1 is described below by way of a specific usage scenario.
Referring to fig. 2, fig. 2 is a schematic diagram of a host according to an embodiment of the present invention.
In the embodiment shown in fig. 2, it is assumed that the virtual machine 11 and the emulation program 12 are installed in advance on the host 1, and the host 1 has 2 communication ports on the motherboard 16, which are the USB port 13 and the USB port 14, respectively, where the port number of the USB port 13 is p1, and the port number of the USB port 14 is p 2. The simulation program may be a Quick EMUlator (QEMU), or the like. Among them, QEMU is a method for implementing hardware virtualization.
First, when a user inputs an instruction to the host 1 to pass the USB port 13 to the virtual machine 11, the host 1 passes the USB port 13 to the virtual machine 11 according to the instruction, and at this time, the host 1 extracts the port number p1 of the USB port 13.
Then, the simulation program 12 needs to periodically acquire the port number of each communication port in the host 1. Initially, since the host 1 has not connected any device of the expansion port, the emulator 12 may acquire the port number p1 of the USB port 13 and the port number p2 of the USB port 14 in the host 1.
Next, assuming that the user wants to expand the USB port 13, the USB hub15 is connected to the USB port 13, the USB hub15 has two communication ports, namely, a USB port 151 and a USB port 152, and assuming that the port numbers of the USB port 151 are p1.1 and the port number of the USB port 152 is p 1.2. At this time, due to the access of the USB hub15, the emulator 12 can acquire that the port numbers of each communication port in the host 1 are p1, p2, p1.1, and p1.2, respectively.
Again, the simulation program 12 determines the port numbers p1.1 and p1.2 matching the port number p1 that has been passed through to the virtual machine 11 among the port numbers p1, p2, p1.1, and p1.2 of all communication ports, that is, determines the port numbers p1, p1.1, and p1.2 that are the same as the prefix portion of the port number p1 among the port numbers p1, p2, p1.1, and p1.2 of each communication port, and then determines the port numbers p1.1 and p1.2 that contain the suffix portion among the port numbers p1, p1.1, and p 1.2.
Finally, the emulator 12 passes through the USB port 151 corresponding to the port number p1.1 and the USB port 152 corresponding to the port number p1.2 to the virtual machine 11, so that the USB port 151 and the USB port 152 on the USB hub15 of the USB port 13 are automatically passed through to the virtual machine 11 when the USB port 13 has been passed through to the virtual machine 11.
Referring to fig. 3, fig. 3 is a schematic diagram of a framework of a network controller 2 and a network device 3 according to an embodiment of the present invention.
In the embodiment shown in fig. 3, it is assumed that the control node 21 of the cloud computing management platform (e.g., OpenStack) is preinstalled on the network controller 2, and the virtual machine 31 and the computing node 32 of the cloud computing management platform are preinstalled on the network device 3. The motherboard 36 of the network device 3 has 2 communication ports, which are a USB port 33 and a USB port 34, respectively, wherein the port number of the USB port 33 is p1, and the port number of the USB port 34 is p 2.
First, after receiving an instruction for passing the USB port 33 to the virtual machine 31 from the control node 21 of the network controller 2 to the network device 3, the network device 3 passes the USB port 33 to the virtual machine 31 according to the instruction, and at this time, the network device 3 extracts the port number p1 of the USB port 33.
Then, the computing node 32 needs to periodically acquire the port number of each communication port in the network device 3. Initially, since the network device 3 has not connected any device of the expansion port, the computing node 32 may acquire the port number p1 of the USB port 33 and the port number p2 of the USB port 34 in the network device 3.
Next, assuming that the user wants to expand the USB port 33, the USB hub35 is connected to the USB port 33, the USB hub35 has two communication ports, namely, a USB port 351 and a USB port 352, and assuming that the port numbers of the USB port 351 are p1.1 and the port number of the USB port 352 is p 1.2. At this time, due to the access of the USB hub35, the computing node 32 can acquire that the port numbers of each communication port in the network device 3 are p1, p2, p1.1, and p1.2, respectively.
Again, the computing node 32 determines the port numbers p1.1 and p1.2 that match the port number p1 that has been passed through to the virtual machine 31 among the port numbers p1, p2, p1.1, and p1.2 of each communication port. The specific matching process is described above, in which the port numbers p1, p1.1, and p1.2 identical to the prefix portion of the port number p1 are determined in the port numbers p1, p2, p1.1, and p1.2 of each communication port, and then the port numbers p1.1 and p1.2 having the suffix portions are determined in the port numbers p1, p1.1, and p 1.2.
Finally, the computing node 32 passes through the USB port 351 corresponding to the port number p1.1 and the USB port 352 corresponding to the port number p1.2 to the virtual machine 31, so that the USB port 351 and the USB port 352 on the USB hub35 of the USB port 33 are automatically passed through to the virtual machine 31 when the USB port 33 is passed through to the virtual machine 31.
Referring to fig. 4, fig. 4 is a flowchart of another transparent transmission method for a communication port according to an embodiment of the present invention. The embodiment shown in fig. 4 is an improved embodiment based on fig. 1, so the same contents as fig. 1 can be referred to the embodiment shown in fig. 1. With respect to the embodiment shown in fig. 1, the embodiment shown in fig. 4 may further include the following steps after step S12:
step S15, determine whether there is second port information matching the first port information in the port information of all communication ports. If there is second port information matching the first port information in the port information of all the communication ports, executing step S13; when the second port information matching the first port information does not exist in the port information of all the communication ports, step S16 is executed.
After the host obtains the port information of each communication port in the host, the host needs to determine whether second port information matched with the first port information exists in the port information of all the communication ports, and if the second port information exists, it indicates that the second communication port is already connected to the first communication port in a cascade manner, then step S13 is executed; if the port information does not exist, it indicates that the second communication port is not connected to the first communication port at the current time, the host waits for a preset time, and then performs step S12, so that the host obtains the port information of each communication port in the host again.
Step S16, wait for a preset time, and execute step S12 again.
The preset time is preset time, and can be set according to an actual scene. For example, the preset time may be set to 1 millisecond, or may be set to 1 second.
In the embodiment shown in fig. 4, the embodiment of the present invention can ensure that the host can monitor in real time whether the first communication port that is transparently transmitted is cascaded with the second communication interface, and if the first communication port is cascaded with the second communication interface, the host transparently transmits the second communication interface to the virtual machine; if the first communication port is cascaded with the second communication interface, the host continues to be in the listening state.
Referring to fig. 5, fig. 5 is a flowchart of another transparent transmission method for a communication port according to an embodiment of the present invention. The embodiment shown in fig. 5 is a modified embodiment based on fig. 1, so the same thing as fig. 1 can be referred to the embodiment shown in fig. 1. With respect to the embodiment shown in fig. 1, the embodiment shown in fig. 5 may further include the following steps after step S11:
and step S17, monitoring the first communication port.
After the host extracts the first port information of the first communication port, the host needs to monitor an insertion event of the first communication port. In general, the host will not listen to the insertion event of the first communication port until the external device is connected to the first communication port. Of course, when the first communication port is disconnected from the external device, the host may listen to the unplugging event of the first communication port. The insertion event refers to an event generated when a communication port is inserted into a communication device, and the extraction event is an event generated when the communication device is extracted from a communication port that has been inserted into the communication device. The communication device may be a USB extension cord or USB hub or the like.
Step S18, determine whether the insertion event of the first communication port is heard. When the insertion event of the first communication port is monitored, executing step S12; when the insertion event of the first communication port is not listened to, step S19 is executed.
And step S19, continuing to monitor the first communication port.
After the host monitors the insertion event of the first communication port, the host needs to determine whether to monitor the insertion event of the first communication port, and if the insertion event of the first communication port is monitored, which indicates that the first communication port is connected with the external device, step S12 is executed to obtain port information of each communication port in the host; if the insertion event of the first communication port is not monitored, which indicates that no external equipment is connected to the first communication port at the current moment, the host continues to monitor the first communication port, so that the host continues to monitor the insertion event of the first communication port.
In the embodiment shown in fig. 5, the embodiment of the present invention can ensure that the host can monitor the insertion event of the first communication port in real time, and the host will perform the subsequent steps when monitoring the insertion event of the first communication port; when the host does not monitor the insertion event of the first communication port, the host continues to monitor the insertion event of the first communication port, thereby ensuring that the insertion event of the first communication port is monitored constantly.
Fig. 6 is a flowchart of a transparent transmission method for a communication port according to another embodiment of the present invention. The transparent transmission method of the communication port shown in fig. 6 can be applied to network devices. The transparent transmission method of the communication port shown in fig. 6 may be configured to, when the second communication port is cascaded to the first communication port, send a matching relationship between first port information of the first communication port and second port information of the second communication port to the network controller, and transmit, according to an instruction sent by the network controller, the second communication port cascaded to the first communication port to the virtual machine. The method comprises the following steps.
And step S21, acquiring the port information of each communication port in the network equipment.
The method provided by the invention can be applied to network equipment provided with a virtual machine, and the network equipment can be a computer, a switch or a router and other equipment. The network device has at least one communication port, which may be a USB port, or may be other types of ports. The method provided by the embodiment of the invention can be applied to the interaction scene of the network controller and the network equipment.
The port information of the communication port can refer to the above embodiments.
The network device can periodically acquire the port information of each communication port in the network device. For example, the network device may obtain the port information of each communication port in the network device every 1 second.
The network device may also obtain port information of each communication port in the network device when an insertion event is detected on a certain communication port. For example, upon detecting an insertion event on a first communication port, the network device obtains port information for each communication port in the network device.
Each communication port in a network device refers to all communication ports on the network device. For example, when the port information is a port number, the network device has 3 communication ports, which are a port x1, a port x2, and a port x3, respectively, where the port number of the port x1 is p1, the port number of the port x2 is p2, the port number of the port x3 is p3, and the network device is provided with a virtual machine a. The network device can acquire the port numbers p1, p2, and p3 of each communication port in the network device.
Step S22, determining second port information matched with the first port information in the port information of all the communication ports, where the second communication port corresponding to the second port information is a communication port of the cascade device of the first communication port corresponding to the first port information, and the first communication port is any one of all the communication ports.
After the network device obtains the port information of each communication port in the network device, the network device needs to determine the second port information matched with the first port information from the port information of all the communication ports. The first communication port is a communication port on the network equipment, the first communication port is connected with the cascade equipment, the cascade equipment is provided with at least one second communication port, and the number of the second communication ports is at least one.
For example, assuming that a network device has 3 communication ports, which are port x1, port x2, and port x3, a virtual machine a is provided on the network device, and assuming that a cascade device y is connected to port x1, and the cascade device y has port y1 and port y2, the first communication port is port x1, and the second communication port is y1 and y 2.
If the second communication port is cascaded on the first communication port, the port information of all the communication ports on the network device includes the second port information of the second communication port, and the second port information and the first port information have certain similarity. For example, when the port information is a port number, then the first port information is a first port number and the second port information is a second port number, and assuming that the first port number is p1 and the second port number is p1.3, the same point is that the prefix portions of the first port number and the second port number are both p1, with the difference that the second port number has a suffix portion of.3, and the first port number does not have a suffix portion.
Therefore, the method provided by the embodiment of the present invention can query, in the port information of all the communication ports, the second port information that is the same as the prefix portion of the first port information and has the suffix portion, and at this time, it can be known that the second communication port corresponding to the second port information is the communication port of the cascade device of the first communication port.
An implementation manner of determining the second port information matched with the first port information among the port information of all the communication ports may refer to the description in the above embodiments.
And step S23, sending the matching relation between the first port information and the second port information to the network controller.
After the network device determines second port information matched with the first port information in the port information of all the communication ports, the network device sends the matching relationship between the first port information and the second port information to the network controller, so that the network controller can receive the matching relationship between the first port information and the second port information.
Step S24, when receiving the instruction sent by the network controller to pass the second communication port corresponding to the second port information to the virtual machine, pass the second communication port corresponding to the second port information to the virtual machine.
When the network device receives an instruction sent by the network controller to pass through the second communication port corresponding to the second port information to the virtual machine, the instruction indicates that an administrator of the network controller expects that the network device can pass through the second communication port corresponding to the second port information to the virtual machine, so that the network device can pass through the second communication port corresponding to the second port information to the virtual machine according to the instruction.
In the embodiment shown in fig. 6, the embodiment of the present invention may obtain port information of each communication port in the network device, and when the second communication port is cascaded to the first communication port on the network device, the network device sends the matching relationship between the first port information of the first communication port and the second port information of the second communication port to the network controller, and transparently transmits the second communication port cascaded to the first communication port to the virtual machine according to an instruction sent by the network controller. Therefore, according to the scheme provided by the embodiment of the invention, when the first communication port on the network device is cascaded with the second communication port, the matching relationship between the first port information of the first communication port and the second port information of the second communication port is sent to the network controller, so that the network controller can immediately monitor the condition of the communication port of the network device, and the network device can transmit the second communication port to the virtual machine according to the instruction sent by the network controller, thereby ensuring that the network controller can flexibly transmit the second communication port on the network device to the virtual machine.
Referring to fig. 7, fig. 7 is a flowchart of another transparent transmission method for a communication port according to an embodiment of the present invention. The embodiment shown in fig. 7 is a modified embodiment based on fig. 6, so the same contents as fig. 6 can be referred to the embodiment shown in fig. 6. With respect to the embodiment shown in fig. 6, the embodiment shown in fig. 7 may further include the following steps after step S21:
step S25, determine whether there is second port information matching the first port information in the port information of all communication ports. If there is second port information matching the first port information in the port information of all the communication ports, executing step S22; when the second port information matching the first port information does not exist in the port information of all the communication ports, step S26 is executed.
After the network device obtains the port information of each communication port in the network device, the network device needs to determine whether second port information matched with the first port information exists in the port information of all the communication ports, if so, it indicates that the first communication port is already connected with the second communication port in a cascade manner, and then step S22 is executed; if the port information does not exist, it indicates that the second communication port is not connected to the first communication port at the current time, the network device waits for a preset time, and then performs step S21, so that the network device obtains the port information of each communication port in the network device again.
Step S26, wait for a preset time, and execute step S21 again.
The preset time is preset time, and can be set according to an actual scene. For example, the preset time may be set to 1 millisecond, or may be set to 1 second.
In the embodiment shown in fig. 7, the embodiment of the present invention may ensure that the network device can monitor whether the first communication port is cascaded with the second communication interface in real time, and if the first communication port is cascaded with the second communication interface, the network device sends the matching relationship between the first port information and the second port information to the network controller; if the first communication port is concatenated with the second communication interface, the network device continues to be in the listening state.
Referring to fig. 8, fig. 8 is a flowchart of another transparent transmission method for a communication port according to an embodiment of the present invention. The embodiment shown in fig. 8 is a modified embodiment based on fig. 6, so the same contents as fig. 6 can be referred to the embodiment shown in fig. 6. With respect to the embodiment shown in fig. 6, the embodiment shown in fig. 8 may further include, before step S21, the following steps:
and step S27, monitoring a first communication port of the network equipment.
Wherein the network device needs to listen for an insertion event of the first communication port. Normally, the network device will not listen to the insertion event of the first communication port until the external device is connected to the first communication port. Of course, when the first communication port is disconnected from the external device, the network device may monitor the first communication port for a pull-out event.
Step S28, judging whether the insertion event of the first communication port is monitored, and executing step S21 when the insertion event of the first communication port is monitored; when the insertion event of the first communication port is not listened to, the step S27 is continuously executed.
The network device needs to determine whether to monitor an insertion event of the first communication port, and if the insertion event of the first communication port is monitored, which indicates that the first communication port is connected to the external device, step S21 is executed to obtain port information of each communication port in the network device; if the insertion event of the first communication port is not monitored, which indicates that no external device is connected to the first communication port at the present time, step S27 is executed to enable the network device to continue to monitor the insertion event of the first communication port.
In the embodiment shown in fig. 8, the embodiment of the present invention can ensure that the network device can monitor the insertion event of the first communication port in real time, and the subsequent steps are executed only when the network device monitors the insertion event of the first communication port; when the network device does not monitor the insertion event of the first communication port, the network device will continue to monitor the insertion event of the first communication port, thereby ensuring that the insertion event of the first communication port is monitored constantly.
Referring to fig. 9, fig. 9 is a flowchart of another transparent transmission method for a communication port according to an embodiment of the present invention. The embodiment shown in fig. 9 is an embodiment corresponding to fig. 6, the method shown in fig. 6 may be applied to a network device, and the method shown in fig. 9 may be applied to a network controller, and the network device and the network controller have information interaction. The method shown in fig. 9 includes the following steps.
Step S31, receiving a matching relationship between the first port information and the second port information sent by the network device, where the second communication port corresponding to the second port information is a communication port of the cascade device of the first communication port corresponding to the first port information.
When the network device determines that a first communication port corresponding to the first port information is connected with the cascade device at a higher level and the cascade device is provided with a second communication port corresponding to the second port information, the network device sends the matching relation between the first port information of the first communication port and the second port information of the second communication port to the network controller, so that the network controller can know that the first communication port on the network device is connected with the second communication port at a higher level, and the network controller allocates the virtual machine which the second communication port is transmitted to.
For example, if the network device determines that the cascade device N is connected to the first communication port x1 corresponding to the first port information p1 and the cascade device N is provided with the second communication port x2 corresponding to the second port information p1.1 and the second communication port x3 corresponding to the second port information p1.2, the network device sends the matching relationship between the first port information p1 and the second port information p1.1 and p1.2 to the network controller. When the network controller receives the matching relationship between the first port information p1 and the second port information p1.1 and p1.2 sent by the network device, the network controller needs to store the matching relationship between the first port information p1 and the second port information p1.1 and p1.2, so that an administrator using the network controller can view or use the information at any time.
And step S32, storing the matching relation between the first port information and the second port information.
The first port information and the second port information may be in a 1-to-1 relationship, or may be in a 1-to-many relationship. If the number of the second communication ports cascaded on the first communication port is 1, the first port information and the second port information are in a 1-to-1 relationship. If the number of the second communication ports cascaded on the first communication port is larger than 1, the first port information and the second port information are in a 1-to-many relationship.
And step S33, when receiving the instruction for transmitting the second communication port corresponding to the second port information to the virtual machine, sending the instruction to the network equipment.
After the network controller stores the matching relationship between the first port information and the second port information, the administrator can see the matching relationship between the first port information and the second port information. At this time, the administrator can freely allocate to which virtual machine the second communication port is passed through.
For example, it is assumed that when the network controller receives the matching relationship between the first port information p1 and the second port information p1.1 and p1.2 sent by the network device, the network controller needs to store the matching relationship between the first port information p1 and the second port information p1.1 and p 1.2. Assuming that the network device is equipped with a virtual machine a and a virtual machine B, and the administrator wishes to transmit the second communication port corresponding to the second port information p1.1 to the virtual machine a and transmit the second communication port corresponding to the second port information p1.2 to the virtual machine B, the administrator may input an instruction for transmitting the second communication port corresponding to the second port information p1.1 to the virtual machine a to the network controller by using the input/output device, and input an instruction for transmitting the second communication port corresponding to the second port information p1.2 to the virtual machine B to the network controller by using the input/output device. When the network controller receives the instruction y1 for transmitting the second communication port corresponding to the second port information p1.1 to the virtual machine a and the instruction y2 for transmitting the second communication port corresponding to the second port information p1.2 to the virtual machine B, the network controller sends the instructions y1 and y2 to the network device. When the network device receives the instruction y1 for transmitting the second communication port corresponding to the second port information p1.1 to the virtual machine a and the instruction y2 for transmitting the second communication port corresponding to the second port information p1.2 to the virtual machine B, the network device transmits the second communication port corresponding to the second port information p1.1 to the virtual machine a according to the instruction y1 and transmits the second communication port corresponding to the second port information p1.2 to the virtual machine B according to the instruction y2, thereby implementing the functions allocated by the network controller.
In order to explain the embodiment shown in fig. 6 and 9 more clearly, the embodiment shown in fig. 1 is described below by a specific use scenario.
Referring to fig. 10, fig. 10 is a schematic diagram of a framework of a network controller 4 and a network device 5 according to an embodiment of the present invention.
In the embodiment shown in fig. 10, it is assumed that the network controller 4 is pre-installed with a control node 41 of a cloud computing management platform (OpenStack), and the network device 5 is pre-installed with a virtual machine 51 and a computing node 52 of the cloud computing management platform (OpenStack). The motherboard 56 of the network device 5 has 2 communication ports, which are a USB port 53 and a USB port 54, wherein the port number of the USB port 53 is p1, and the port number of the USB port 54 is p 2.
First, when the control node 41 of the network controller 4 sends an instruction to the network device 5 to pass the USB port 53 to the virtual machine 51, the network device 5 passes the USB port 53 to the virtual machine 51 according to the instruction, and at this time, the network device 5 extracts the port number p1 of the USB port 53.
Then, the computing node 52 needs to periodically acquire the port number of each communication port in the network device 5. Initially, since the network device 5 has not connected any device of the expansion port, the computing node 52 may acquire the port number p1 of the USB port 53 and the port number p2 of the USB port 54 in the network device 5.
Next, assuming that the user wants to expand the USB port 53, the USB hub55 is connected to the USB port 53, the USB hub55 has two communication ports, namely, a USB port 551 and a USB port 552, and the port numbers of the USB port 551 and the USB port 552 are p1.1 and p1.2, respectively. At this time, due to the access of the USB hub55, the computing node 52 can acquire that the port numbers of each communication port in the network device 5 are p1, p2, p1.1, and p1.2, respectively.
Again, the computing node 52 determines the port numbers p1.1 and p1.2 that match the port number p1 that has been passed through to the virtual machine 51, among the port numbers p1, p2, p1.1, and p1.2 of each communication port. The specific matching process is described above, in which the port numbers p1, p1.1, and p1.2 identical to the prefix portion of the port number p1 are determined in the port numbers p1, p2, p1.1, and p1.2 of each communication port, and then the port numbers p1.1 and p1.2 having the suffix portions are determined in the port numbers p1, p1.1, and p 1.2.
Again, the computing node 52 sends the matching relationship of the port number p1 and the port numbers p1.1 and p1.2 to the control node 41 of the network controller 4. After the control node 41 receives the matching relationship between the port number p1 and the port numbers p1.1 and p1.2, the control node 41 stores the matching relationship between the port number p1 and the port numbers p1.1 and p 1.2. At this time, the administrator using the network controller 4 can see the matching relationship between the received port number p1 and the port numbers p1.1 and p1.2 by inputting the query instruction, and assuming that the administrator inputs an instruction to the control node 41 of the network controller 4 by using the input/output device, the instruction is transmitted to the virtual machine 51 through the USB port 551 corresponding to the port number p1.1 and the USB port 552 corresponding to the port number p1.2, and the control node 41 transmits the instruction to the network device 5.
Finally, when the network device 5 receives an instruction sent by the control node 41 of the network controller 4 to pass through the USB port 551 corresponding to the port number p1.1 and the USB port 552 corresponding to the port number p1.2 to the virtual machine 51, the network device 5 will pass through the USB port 551 corresponding to the port number p1.1 and the USB port 552 corresponding to the port number p1.2 to the virtual machine 51 according to the instruction, thereby ensuring that the network controller 4 can flexibly pass through the communication port on the network device 5 to the virtual machine.
Fig. 11 is a schematic diagram of a transparent transmission device of a communication port according to an embodiment of the present invention. Fig. 11 is an embodiment of the apparatus corresponding to fig. 1, and the same contents in fig. 11 as those in fig. 1 may refer to the embodiment corresponding to fig. 1. Referring to fig. 11, the apparatus includes the following units:
the extraction unit 101 is configured to extract first port information of a first communication port when the first communication port of a host is passed through to a virtual machine;
an obtaining unit 102, configured to obtain port information of each communication port in a host;
a determining unit 103, configured to determine, in port information of all communication ports of a host, second port information matched with the first port information, where a second communication port corresponding to the second port information is a communication port of a cascade device of the first communication port;
and the transparent transmission unit 104 is configured to transmit the second communication port corresponding to the second port information to the virtual machine.
Optionally, the apparatus further includes the following units:
the first judging unit is used for judging whether second port information matched with the first port information exists in the port information of all the communication ports; triggering the determining unit when second port information matched with the first port information exists in the port information of all the communication ports; or when second port information matched with the first port information does not exist in the port information of all the communication ports, waiting for preset time and triggering the acquisition unit. Optionally, the apparatus further includes the following units:
a listening unit for listening to the first communication port,
the second judging unit is used for judging whether the insertion event of the first communication port is monitored or not; when monitoring the insertion event of the first communication port, triggering the acquisition unit; or when the insertion event of the first communication port is not monitored, the monitoring unit is triggered.
Optionally, the determining unit is specifically configured to:
determining a third port number which is the same as the prefix part of the first port number among the port numbers of all the communication ports; and determining a second port number having a suffix portion in the third port number. Optionally, the determining unit is specifically configured to:
determining fourth port information having a bus number of the first port information among port information of all communication ports; determining fifth port information identical to a prefix part of the port number of the first port information in the fourth port information; and determining second port information including a suffix part in the port number of the fifth port information.
Fig. 12 is a schematic diagram of a transparent transmission device of a communication port according to another embodiment of the present invention. Fig. 12 is an embodiment of the apparatus corresponding to fig. 6, and the same contents in fig. 12 as those in fig. 6 may refer to the embodiment corresponding to fig. 6. Referring to fig. 12, the apparatus includes the following units:
an obtaining unit 201, configured to obtain port information of each communication port in the network device;
a determining unit 202, configured to determine, in port information of all communication ports of the network device, second port information matched with the first port information, where a second communication port corresponding to the second port information is a communication port of a cascade device of the first communication port corresponding to the first port information; the first communication port is any one of all communication ports;
a sending unit 203, configured to send the matching relationship between the first port information and the second port information to the network controller;
and the transparent transmission unit 204 is configured to, when receiving an instruction sent by the network controller to transmit the second communication port corresponding to the second port information to the virtual machine, transmit the second communication port corresponding to the second port information to the virtual machine.
Optionally, the apparatus further includes the following units:
the first judging unit is used for judging whether second port information matched with the first port information exists in the port information of all the communication ports; when second port information matched with the first port information exists in the port information of all the communication ports, the determining unit is triggered; or when second port information matched with the first port information does not exist in the port information of all the communication ports, waiting for preset time and triggering the acquisition unit again.
Optionally, the apparatus further includes the following units:
the monitoring unit is used for monitoring each communication port of the network equipment;
the second judging unit is used for judging whether the insertion event of the first communication port is monitored or not; when monitoring the insertion event of the first communication port, triggering the acquisition unit; or when the insertion event of the first communication port is not monitored, the monitoring unit is continuously triggered.
Optionally, the determining unit is specifically configured to:
determining a third port number which is the same as the prefix part of the first port number among the port numbers of all the communication ports; and determining a second port number having a suffix portion in the third port number. Optionally, the determining unit is specifically configured to:
determining fourth port information having a bus number of the first port information among port information of all communication ports; determining fifth port information identical to a prefix part of the port number of the first port information in the fourth port information; and determining second port information including a suffix part in the port number of the fifth port information.
Fig. 13 is a schematic diagram of a transparent transmission device of a communication port according to another embodiment of the present invention. Fig. 13 is a diagram of an embodiment of the apparatus corresponding to fig. 9, and the same contents in fig. 13 as those in fig. 9 are obtained by referring to the embodiment corresponding to fig. 9. Referring to fig. 13, the apparatus includes the following units:
a receiving unit 301, configured to receive a matching relationship between first port information and second port information sent by a network device, where a second communication port corresponding to the second port information is a communication port of a cascade device of a first communication port corresponding to the first port information;
a storage unit 302, configured to store a matching relationship between the first port information and the second port information;
the sending unit 303 is configured to send an instruction to the network device when receiving the instruction that the second communication port corresponding to the second port information is transmitted to the virtual machine.
Fig. 14 is a schematic diagram of a transparent transmission device of a communication port according to another embodiment of the present invention. The apparatus may be any of the hosts, network devices, or network controllers described above. Referring to fig. 14, the apparatus includes: the device comprises a processor 401 and a memory 402, wherein the memory 402 stores operation instructions capable of being executed by the processor 401, and the processor 401 reads the operation instructions in the memory 402 for implementing the method in the method embodiments.
It should be noted that the embodiments shown in fig. 1 to 14 are only preferred embodiments described in the present disclosure, and those skilled in the art can design many more embodiments based on the embodiments, so that the detailed description is omitted here.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a unit is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some ports, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (20)

1. A transparent transmission method of a communication port is applied to a host machine provided with a virtual machine, and comprises the following steps:
when a first communication port of the host machine is transmitted to the virtual machine, extracting first port information of the first communication port;
acquiring port information of each communication port in the host machine;
determining second port information matched with the first port information in port information of all communication ports of the host, wherein a second communication port corresponding to the second port information is a communication port of the cascade equipment of the first communication port;
and transmitting a second communication port corresponding to the second port information to the virtual machine.
2. The transparent transmission method for communication ports according to claim 1, wherein after the step of obtaining the port information of each communication port in the host, the method further comprises:
judging whether second port information matched with the first port information exists in the port information of all the communication ports or not;
when the second port information matched with the first port information exists in the port information of all the communication ports, executing a step of determining the second port information matched with the first port information in the port information of all the communication ports;
and when the second port information matched with the first port information does not exist in the port information of all the communication ports, waiting for a preset time, and executing the step of acquiring the port information of each communication port in the host again.
3. The pass-through method of a communication port of claim 1, wherein after the step of extracting the first port information of the first communication port, the method further comprises:
listening to the first communication port for the first communication port,
judging whether an insertion event of the first communication port is monitored;
when monitoring the insertion event of the first communication port, executing the step of acquiring the port information of each communication port in the host machine;
when the insertion event of the first communication port is not monitored, the first communication port is monitored continuously.
4. The transparent transmission method of the communication port according to any one of claims 1 to 3, wherein when the port information of the communication port is a port number, the step of determining, from the port information of all the communication ports of the host, second port information that matches the first port information includes:
determining a third port number which is the same as a prefix portion of the first port number among the port numbers of all the communication ports;
determining the second port number in the third port number that contains a suffix portion.
5. The transparent transmission method for the communication port according to any one of claims 1 to 3, wherein when the port information of the communication port includes a port number and a bus number, the step of determining, from the port information of all the communication ports of the host, second port information that matches the first port information includes:
determining fourth port information having a bus number of the first port information among port information of all the communication ports;
determining fifth port information which is identical to a prefix part of the port number of the first port information in the fourth port information;
determining the second port information containing a suffix part in a port number of the fifth port information.
6. A transparent transmission method of a communication port is applied to network equipment provided with a virtual machine, and the method comprises the following steps:
acquiring port information of each communication port in the network equipment;
determining second port information matched with the first port information in the port information of all communication ports of the network equipment, wherein a second communication port corresponding to the second port information is a communication port of cascade equipment of the first communication port corresponding to the first port information; the first communication port is a port which has been passed through to the virtual machine;
sending the matching relation of the first port information and the second port information to a network controller;
and when an instruction sent by the network controller and used for transmitting the second communication port corresponding to the second port information to the virtual machine is received, transmitting the second communication port corresponding to the second port information to the virtual machine.
7. The transparent transmission method for communication ports according to claim 6, wherein after the step of obtaining the port information of each communication port in the network device, the method further comprises:
judging whether second port information matched with the first port information exists in the port information of all the communication ports or not;
when the second port information matched with the first port information exists in the port information of all the communication ports, executing a step of determining the second port information matched with the first port information in the port information of each communication port;
and when the second port information matched with the first port information does not exist in the port information of all the communication ports, waiting for a preset time, and executing the step of acquiring the port information of each communication port in the network equipment again.
8. The transparent transmission method for communication ports according to claim 6, wherein before the step of obtaining the port information of each communication port in the network device, the method further comprises:
monitoring each communication port of the network equipment;
judging whether an insertion event of the first communication port is monitored;
when monitoring the insertion event of the first communication port, executing the step of acquiring the port information of each communication port in the network equipment;
when the insertion event of the first communication port is not monitored, the step of monitoring each communication port is continuously executed.
9. The transparent transmission method of the communication port according to any one of claims 6 to 8, wherein when the port information of the communication port is a port number, the step of determining, from the port information of all the communication ports, second port information that matches the first port information includes:
determining a third port number which is the same as a prefix portion of the first port number among the port numbers of all the communication ports;
determining the second port number in the third port number that contains a suffix portion.
10. The transparent transmission method for the communication port according to any one of claims 6 to 8, wherein when the port information of the communication port includes a port number and a bus number, the step of determining, among the port information of all the communication ports, second port information that matches the first port information includes:
determining fourth port information having a bus number of the first port information among port information of all the communication ports;
determining fifth port information which is identical to a prefix part of the port number of the first port information in the fourth port information;
determining the second port information containing a suffix part in a port number of the fifth port information.
11. A transparent transmission device of a communication port, wherein the device is a host machine installed with a virtual machine, the device comprises:
the extraction unit is used for extracting first port information of a first communication port when the first communication port of the host machine is transmitted to the virtual machine;
the acquisition unit is used for acquiring port information of each communication port in the host machine;
a determining unit, configured to determine, in port information of all communication ports of the host, second port information that is matched with the first port information, where a second communication port corresponding to the second port information is a communication port of the cascade device of the first communication port;
and the transparent transmission unit is used for transmitting the second communication port corresponding to the second port information to the virtual machine.
12. The apparatus of claim 11, further comprising:
a first judging unit, configured to judge whether second port information that matches the first port information exists in the port information of all the communication ports; when the second port information matched with the first port information exists in the port information of all the communication ports, triggering the determining unit; or when the second port information matched with the first port information does not exist in the port information of all the communication ports, waiting for a preset time and triggering the acquisition unit.
13. The apparatus of claim 11, further comprising:
a listening unit for listening to the first communication port,
a second judging unit, configured to judge whether an insertion event of the first communication port is monitored; when monitoring the insertion event of the first communication port, triggering the acquisition unit; or when the insertion event of the first communication port is not monitored, triggering the monitoring unit.
14. The apparatus according to any of claims 11 to 13, wherein the determining unit is specifically configured to:
determining a third port number which is the same as a prefix portion of the first port number among the port numbers of all the communication ports; and determining the second port number in the third port number that contains a suffix portion.
15. The apparatus according to any of claims 11 to 13, wherein the determining unit is specifically configured to:
determining fourth port information having a bus number of the first port information among port information of all the communication ports;
determining fifth port information which is identical to a prefix part of the port number of the first port information in the fourth port information; and
determining the second port information containing a suffix part in a port number of the fifth port information.
16. An apparatus for transparent transmission of a communication port, the apparatus being a network device installed with a virtual machine, the apparatus comprising:
an obtaining unit, configured to obtain port information of each communication port in the network device;
a determining unit, configured to determine, in port information of all communication ports of the network device, second port information that is matched with first port information, where a second communication port corresponding to the second port information is a communication port of a cascade device of a first communication port corresponding to the first port information; the first communication port is a port which has been passed through to the virtual machine;
a sending unit, configured to send the matching relationship between the first port information and the second port information to a network controller;
and the transparent transmission unit is used for transmitting the second communication port corresponding to the second port information to the virtual machine when receiving an instruction which is sent by the network controller and used for transmitting the second communication port corresponding to the second port information to the virtual machine.
17. The apparatus of claim 16, further comprising:
a first judging unit, configured to judge whether second port information that matches the first port information exists in the port information of all the communication ports; when the second port information matched with the first port information exists in the port information of all the communication ports, triggering the determining unit; or when the second port information matched with the first port information does not exist in the port information of all the communication ports, waiting for a preset time and triggering the acquisition unit.
18. The apparatus of claim 16, further comprising:
the monitoring unit is used for monitoring each communication port of the network equipment;
a second judging unit, configured to judge whether an insertion event of the first communication port is monitored; when monitoring the insertion event of the first communication port, triggering the acquisition unit; or when the insertion event of the first communication port is not monitored, triggering the monitoring unit.
19. The apparatus according to any of claims 16 to 18, wherein the determining unit is specifically configured to:
determining a third port number which is the same as a prefix portion of the first port number among the port numbers of all the communication ports; and
determining the second port number in the third port number that contains a suffix portion.
20. The apparatus according to any of claims 16 to 18, wherein the determining unit is specifically configured to:
determining fourth port information having a bus number of the first port information among port information of all the communication ports;
determining fifth port information which is identical to a prefix part of the port number of the first port information in the fourth port information; and
determining the second port information containing a suffix part in a port number of the fifth port information.
CN201610480633.6A 2016-06-27 2016-06-27 Transparent transmission method and device for communication port Active CN107544930B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201610480633.6A CN107544930B (en) 2016-06-27 2016-06-27 Transparent transmission method and device for communication port
PCT/CN2017/086905 WO2018001037A1 (en) 2016-06-27 2017-06-02 Communications port passthrough method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610480633.6A CN107544930B (en) 2016-06-27 2016-06-27 Transparent transmission method and device for communication port

Publications (2)

Publication Number Publication Date
CN107544930A CN107544930A (en) 2018-01-05
CN107544930B true CN107544930B (en) 2020-07-14

Family

ID=60786670

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610480633.6A Active CN107544930B (en) 2016-06-27 2016-06-27 Transparent transmission method and device for communication port

Country Status (2)

Country Link
CN (1) CN107544930B (en)
WO (1) WO2018001037A1 (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102821038A (en) * 2011-05-14 2012-12-12 国际商业机器公司 Method and system for data traffic handling in a distributed fabric protocol (dfp) switching network architecture
CN103873374A (en) * 2014-03-27 2014-06-18 杭州华三通信技术有限公司 Message processing method and device in virtualized system
CN103942088A (en) * 2014-04-01 2014-07-23 国云科技股份有限公司 Method for acquiring using conditions of USB storage device of virtual machine
CN104092747A (en) * 2014-06-30 2014-10-08 杭州华三通信技术有限公司 USB dynamic linking method and device in virtualization environment
CN104462881A (en) * 2014-12-02 2015-03-25 中国石油集团工程设计有限责任公司 Pooling method of software encryption dog resource under cloud computing environment
CN105159742A (en) * 2015-07-06 2015-12-16 北京星网锐捷网络技术有限公司 Unvarnished transmission method and system for PCI device of virtual machine
CN105183674A (en) * 2015-08-26 2015-12-23 深圳市深信服电子科技有限公司 USB virtualization network mapping method, USB virtualization network mapping device and USB hub

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101808428B (en) * 2010-04-21 2013-04-24 华为终端有限公司 Communication method and device of double-card dual-standby cell phone
US8166211B2 (en) * 2010-06-07 2012-04-24 Vmware, Inc. Safely sharing USB devices
US20160054755A1 (en) * 2014-08-21 2016-02-25 Edward Brian Depenbrock Usb pass-through device
US9804990B2 (en) * 2014-08-27 2017-10-31 Vmware, Inc. Sharing unclaimed USB devices as PCI devices

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102821038A (en) * 2011-05-14 2012-12-12 国际商业机器公司 Method and system for data traffic handling in a distributed fabric protocol (dfp) switching network architecture
CN103873374A (en) * 2014-03-27 2014-06-18 杭州华三通信技术有限公司 Message processing method and device in virtualized system
CN103942088A (en) * 2014-04-01 2014-07-23 国云科技股份有限公司 Method for acquiring using conditions of USB storage device of virtual machine
CN104092747A (en) * 2014-06-30 2014-10-08 杭州华三通信技术有限公司 USB dynamic linking method and device in virtualization environment
CN104462881A (en) * 2014-12-02 2015-03-25 中国石油集团工程设计有限责任公司 Pooling method of software encryption dog resource under cloud computing environment
CN105159742A (en) * 2015-07-06 2015-12-16 北京星网锐捷网络技术有限公司 Unvarnished transmission method and system for PCI device of virtual machine
CN105183674A (en) * 2015-08-26 2015-12-23 深圳市深信服电子科技有限公司 USB virtualization network mapping method, USB virtualization network mapping device and USB hub

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
"A Virtualized Testbed with Physical Outlets for Hands-on Computer Networking Education";Mark Schmidt等;《SIGITE" 14:Proceedings of the 15th Annual Conference on Information Technology Education》;20141018;第3-8页 *
"基于虚拟化的系统安全增强及显卡透传研究";侯建宁等;《计算机工程》;20120430;第38卷(第8期);第224-227页 *
"虚拟化环境下的USB设备访问方法";王继刚等;《计算机应用》;20110531;第31卷(第5期);第1439-1442页 *
"飞腾平台USB虚拟化的设计与实现";王伟;《中国优秀硕士学位论文全文数据库 信息科技辑》;20120715(第07期);论文第二章-第五章 *

Also Published As

Publication number Publication date
CN107544930A (en) 2018-01-05
WO2018001037A1 (en) 2018-01-04

Similar Documents

Publication Publication Date Title
EP3223152B1 (en) Method and server for presenting initialization degree of hardware in server
CN107360633B (en) Pairing connection method and device of virtual reality system and virtual reality system
CN103699481A (en) Code debugging method and code debugging system
CN106452951B (en) A kind of information processing method, apparatus and system
CN103634388B (en) Controller is restarted in treatment storage server method and relevant device and communication system
CN111417216B (en) Application program cross-system communication method and related device
CN110417789B (en) Server connection method, electronic device, system and medium
CN106534342B (en) Connect control method, host and system
CN103024056B (en) Data processing method, load equalizer and cloud system
CN112968927B (en) Log extraction method, log extraction device, storage medium and electronic equipment
CN112235300B (en) Cloud virtual network vulnerability detection method, system, device and electronic equipment
CN107544930B (en) Transparent transmission method and device for communication port
CN114020678B (en) Server serial console redirection method, device and system and electronic equipment
CN112463140B (en) Programming method and device based on electronic building blocks, electronic equipment and storage medium
CN115328609A (en) Cloud desktop data processing method and system
CN108495336B (en) Data receiving and transmitting method and device based on wireless communication and computer equipment
US10491544B2 (en) Consistency control of a logical path passing through a relay device
CN114610668B (en) Method and device for interaction between intelligent serial port screen and BMC
EP2874067A1 (en) Information processing system, information processing apparatus, terminal apparatus, control program, and control method
JP6349786B2 (en) Virtual machine management apparatus, virtual machine management method, and virtual machine management program
US11895200B2 (en) Access to an operator panel over an out-of-band local network domain
JP2019016056A (en) Transmission and reception system, control method for transmission and reception system, transmitting apparatus, and receiving apparatus
CN116166298B (en) Firmware upgrading method, device, equipment and storage medium
US9197497B2 (en) Configuration of network entities using firmware
EP2766815B1 (en) Establish client-host connection

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
GR01 Patent grant
GR01 Patent grant