A USB device management method and apparatus

By deploying usb-daemon and usb-agent child processes on the host, listening for USB device access and updating information, and receiving instructions from the cloud management platform, the redirection and automatic reconnection of USB devices are achieved, solving the problem of USB devices becoming unusable after virtual machine hot migration, simplifying the configuration process and realizing unified management.

CN114153552BActive Publication Date: 2025-11-04NEW H3C BIG DATA TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111246968.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-26
Publication Date
2025-11-04
Estimated Expiration
2041-10-26

AI Technical Summary

Technical Problem

After a virtual machine is hot-migrated, the allocated USB devices become unusable. Existing technical solutions are complex and have poor usability, making it impossible to achieve unified management of physical USB devices on all hosts under the cloud management platform.

Method used

By deploying the USB device management module usb-daemon and the usb-agent subprocess on the host, the system listens for USB device access and updates device information, receives redirection instructions from the cloud management platform, starts the USB device redirection service, redirects the USB device to the target virtual machine, and automatically reconnects after the virtual machine is migrated.

Benefits of technology

It simplifies the USB device configuration process, ensures that USB devices can still be used normally after virtual machine migration, and realizes unified management and automatic reconnection under the cloud management platform.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114153552B_ABST
    Figure CN114153552B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of virtualization, in particular to a USB device management method and device. The method is applied to a host, each host is in communication connection with a cloud management platform, and the method comprises the following steps: if it is found that a USB device is connected to the local host, the device information of the USB device is acquired, and the device information of the USB device is updated to a USB device information list maintained locally; a target USB device redirection instruction issued by the cloud management platform is received, wherein the target USB device redirection instruction comprises target USB device information and target virtual machine information; based on the target USB device redirection instruction, a redirection service of the target USB device is started, and the target USB device is redirected to the target virtual machine.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of virtualization, and particularly relates to a USB device management method and device. BACKGROUND

[0002] With the rapid development of cloud computing technology, we have unknowingly entered the digital era. Although we enjoy the convenience brought by cloud computing, there are still many imperfect places in cloud computing technology, which affect the use experience. In the field of cloud computing, virtualization as a basic supporting technology is currently mature and stable, but compared with traditional IT infrastructure architecture, there are still some deficiencies, such as: the USB device of the virtual machine, although it can be used on the local host, but when the virtual machine is migrated to the remote host, since it has crossed the host physically, the original USB device cannot be used.

[0003] The USB over Network technology can solve the access to the USB device across the host. The implementation of the technology generally consists of three parts: usb server software, usb client software and usb hub hardware, that is, the usb server manages the USB device; the usb client is installed in the virtual machine and communicates with the usb server to realize the read and write operations of the USB device; the usb hub hardware has a network interface and a usb interface, and the USB device is plugged in and then accessed to the local area network where the virtual machine is located through the network. After the virtual machine is migrated from one host to another, the USB device can be accessed across the host by reconfiguring the usb server and the usb client. However, the USB over Network technology involves many components, is complicated to use, and the usb hub hardware is expensive, which not only increases the cost of customers, but also has poor usability.

[0004] The hostdev technology based on the open source software qemu can transmit the physical USB device of the local host to the virtual machine in a virtualized manner. A physical USB device is first plugged into the local host, and then the USB device is added to the virtual machine through the hostdev simulation technology. The virtual USB device added is deleted before the virtual machine is hot migrated, the physical USB device plugged into the local host is reinserted into the remote host after the virtual machine is hot migrated to the remote host, and finally the USB device is added to the virtual machine on the remote host. However, this scheme needs to manually plug and unplug the physical USB device on the host, needs to add and delete the virtual USB device for the virtual machine multiple times, has very poor usability, will interrupt the normal operation of the business software using the USB device in the virtual machine, and cannot uniformly manage the physical USB on all hosts under the cloud management platform. SUMMARY

[0005] The application provides a USB device management method and device to solve the problem that the USB device allocated for a period of time cannot be used after the virtual machine is migrated.

[0006] In a first aspect, the application provides a USB device management method applied to a host, each host being in communication connection with a cloud management platform, and the method comprises:

[0007] If a USB device is detected to be connected to the local host, the device information of the USB device is obtained, and the device information of the USB device is updated to a USB device information list maintained locally;

[0008] A target USB device redirection instruction issued by the cloud management platform is received, wherein the target USB device redirection instruction comprises target USB device information and target virtual machine information;

[0009] Based on the target USB device redirection instruction, a redirection service of the target USB device is started, and the target USB device is redirected to the target virtual machine.

[0010] Optionally, each host comprises a USB device management module, and the USB device management module is run on each host in the form of a daemon process usb-daemon; based on the target USB device redirection instruction, the step of starting the redirection service of the target USB device comprises:

[0011] An usb-agent sub-process corresponding to the target USB device is created based on the daemon process usb-daemon running locally;

[0012] The bus, dev and path of the target USB device are sent to usbredirserver through the usb-agent sub-process, so that usbredirserver starts an usbredirserver sub-process corresponding to the target USB device, thereby starting the redirection service of the target USB device.

[0013] Optionally, the method further comprises:

[0014] The daemon process usb-daemon and the usb-agent sub-process perform heartbeat detection based on preset rules, and the daemon process usb-daemon periodically acquires the pid of the usb-agent sub-process and the pid of the usbredirserver sub-process, and when it is detected that the usb-agent sub-process or the usbredirserver sub-process stops running, the daemon process usb-daemon recreates a usb-agent sub-process and a usbredirserver sub-process corresponding to the target USB device.

[0015] Optionally, the target USB device and the target virtual machine are connected in a TCP / IP network mode; the method further comprises:

[0016] If the target USB device and the target virtual machine are disconnected after the target virtual machine is migrated to a remote host, the target USB device initiates reconnection to the target virtual machine within a preset time period, wherein the preset time period is longer than a time period required for migration of the target virtual machine.

[0017] In a second aspect, the application provides a USB device management method applied to a cloud management platform, wherein the cloud management platform is communicatively connected with a plurality of hosts, and the method comprises the following steps:

[0018] Sending a USB device information acquisition request to each host respectively;

[0019] Receiving USB device information returned by each host, and displaying the USB device information based on a web interface;

[0020] Based on a user-triggered instruction of assigning a target USB device to a target virtual machine, sending a target USB device redirection instruction to a target host, so that the target host starts a redirection service of the target USB device based on the target USB device redirection instruction, and redirects the target USB device to the target virtual machine, wherein the target USB device redirection instruction comprises target USB device information and target virtual machine information.

[0021] In a third aspect, the application provides a USB device management apparatus applied to a host, wherein each host is communicatively connected with a cloud management platform, and the apparatus comprises:

[0022] An acquisition unit, if it is detected that a USB device is connected to the local host, the acquisition unit is configured to acquire device information of the USB device, and update the device information of the USB device to a USB device information list maintained locally;

[0023] A receiving unit is configured to receive a target USB device redirection instruction issued by the cloud management platform, wherein the target USB device redirection instruction comprises target USB device information and target virtual machine information;

[0024] An enabling unit is configured to enable a redirection service of the target USB device based on the target USB device redirection instruction, and redirect the target USB device to the target virtual machine.

[0025] Optionally, each host comprises a USB device management module, which is run on each host in the form of a daemon process usb-daemon; when enabling the redirection service of the target USB device based on the target USB device redirection instruction, the enabling unit is specifically configured to:

[0026] create an usb-agent sub-process corresponding to the target USB device based on the locally run daemon process usb-daemon;

[0027] send bus, dev and path of the target USB device to usbredirserver through the usb-agent sub-process, so that usbredirserver starts an usbredirserver sub-process corresponding to the target USB device, thereby enabling the redirection service of the target USB device.

[0028] Optionally, the apparatus further comprises:

[0029] The daemon process usb-daemon and the usb-agent sub-process perform heartbeat detection based on a preset rule, and the daemon process usb-daemon periodically acquires the pid of the usb-agent sub-process and the pid of the usbredirserver sub-process; when detecting that the usb-agent sub-process or the usbredirserver sub-process stops running, the daemon process usb-daemon re-creates an usb-agent sub-process and an usbredirserver sub-process corresponding to the target USB device.

[0030] Optionally, the target USB device and the target virtual machine are connected in a TCP / IP network manner; the apparatus further comprises a reconnection unit:

[0031] If the target USB device is disconnected from the target virtual machine after the target virtual machine is migrated to a remote host, the reconnection unit is configured to instruct the target USB device to initiate reconnection with the target virtual machine within a preset time period, wherein the preset time period is longer than a time period required for the target virtual machine to be migrated.

[0032] In a fourth aspect, the present application provides a USB device management apparatus applied to a cloud management platform, wherein the cloud management platform is communicatively connected with a plurality of hosts, and the apparatus comprises:

[0033] A first sending unit is configured to send a USB device information acquisition request to each of the hosts.

[0034] A receiving unit is configured to receive USB device information returned by each of the hosts, and display the USB device information based on a web interface.

[0035] A second sending unit is configured to send a target USB device redirection instruction to a target host based on a user instruction of assigning a target USB device to a target virtual machine, so that the target host starts a redirection service of the target USB device based on the target USB device redirection instruction, and redirects the target USB device to the target virtual machine, wherein the target USB device redirection instruction comprises target USB device information and target virtual machine information.

[0036] In a fifth aspect, the present application provides a USB device management apparatus, which comprises:

[0037] A memory is configured to store program instructions.

[0038] A processor is configured to call the program instructions stored in the memory, and execute the steps of the method according to the obtained program instructions.

[0039] In a sixth aspect, the present application provides a computer readable storage medium, which stores computer executable instructions, and the computer executable instructions are used to make the computer execute the steps of the method according to any one of the first aspect.

[0040] In a seventh aspect, the present application provides a USB device management apparatus, which comprises:

[0041] A memory is configured to store program instructions.

[0042] A processor is configured to call the program instructions stored in the memory, and execute the steps of the method according to the obtained program instructions.

[0043] In an eighth aspect, the embodiments of the present application further provide a computer readable storage medium, which stores computer executable instructions for causing a computer to perform the steps of the method of any one of the above second aspects.

[0044] In summary, the USB device management method provided by the embodiments of the present application is applied to a host, each host is in communication connection with a cloud management platform, and the method comprises the following steps: if it is monitored that a USB device accesses locally, the device information of the USB device is acquired, and the device information of the USB device is updated to a USB device information list maintained locally; a target USB device redirection instruction issued by the cloud management platform is received, wherein the target USB device redirection instruction comprises target USB device information and target virtual machine information; based on the target USB device redirection instruction, a redirection service of the target USB device is started, and the target USB device is redirected to the target virtual machine.

[0045] By using the USB device management method provided by the embodiments of the present application, each host maintains the device information of the USB device accessing locally, the cloud management platform uniformly manages the allocation of each USB device, and the USB device is configured to a virtual machine in a redirection manner, so that the configuration process of the USB device is simplified. Furthermore, in the redirection manner, when the virtual machine is migrated from one host to a remote host, the USB device allocated for the virtual machine can still be connected to the migrated virtual machine in a reconnection manner. BRIEF DESCRIPTION OF DRAWINGS

[0046] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the description of the embodiments of the present application or the prior art. Obviously, the drawings in the following description are only some embodiments described in the present application, and other drawings can also be obtained by those skilled in the art according to these drawings of the embodiments of the present application.

[0047] Figure 1 A detailed flowchart of a USB device management method provided by the embodiments of the present application is provided.

[0048] Figure 2 A cloud management platform USB device display schematic diagram provided by the embodiments of the present application is provided.

[0049] Figure 3 A detailed flowchart of another USB device management method provided by the embodiments of the present application is provided.

[0050] Figure 4 A structure schematic diagram of a first USB device management device provided by the embodiments of the present application is provided.

[0051] Figure 5 A second USB device management apparatus provided by an embodiment of the present application is shown in a structural schematic diagram.

[0052] Figure 6 A third USB device management apparatus provided by an embodiment of the present application is shown in a structural schematic diagram.

[0053] Figure 7 A fourth USB device management apparatus provided by an embodiment of the present application is shown in a structural schematic diagram. DETAILED DESCRIPTION

[0054] The terminology used in the present application merely for the purpose of describing particular embodiments, and is not intended to be limiting of the present application. The singular forms "a", "an", and "the" used in the present application and its claims are intended to include both singular and plural forms, unless the context clearly indicates otherwise. It will be further understood that the terms "and / or", as used in the present application, refers to any or all possible combinations of one or more of the associated listed items.

[0055] It should be understood that although the terms first, second, third, etc. can be used herein to describe various information, these terms are not intended to denote a particular order of the information. These terms are used merely to distinguish one type of information from another. For example, a first information can be termed a second information, and similarly, a second information can be termed a first information, without departing from the scope of the present application. Furthermore, the word "if" can be interpreted to mean "when" or "upon" or "in response to determining" depending on the context.

[0056] An exemplary USB device management method provided by an embodiment of the present application is shown in a detailed flowchart. The method is applied to a host, each host being in communication connection with a cloud management platform. The method comprises the following steps: Figure 1

[0057] Step 100: If a USB device is detected to be connected to the local host, the device information of the USB device is obtained, and the device information of the USB device is updated to a USB device information list maintained locally.

[0058] In an embodiment of the present application, a USB device management module is deployed on each host, and the USB device management module runs on each host in the form of a daemon process usb-daemon, and manages all USB devices on a single host.

[0059] ​For example, the host listens to the activity of the USB device on the host through libudev (an open source interface for monitoring device plugging and unplugging), when the host has a USB device plugged in or unplugged, the usb-daemon captures it, and then acquires the information of the USB device through libusb (an open source USB device access interface library), and updates the USB device information list maintained by the usb-daemon.

[0060] Step 110: receiving a target USB device redirection instruction issued by the cloud management platform, wherein the target USB device redirection instruction includes target USB device information and target virtual machine information.

[0061] In the embodiment of the present application, the cloud management platform is a platform providing cloud services, which presents a man-machine interactive interface in the form of web, and the network USB component is deployed on the cloud management platform, so that when the cloud service operation and maintenance personnel need to configure a USB device for a virtual machine, the network USB component can be used to achieve the configuration.

[0062] For example, the network USB component of the cloud management platform acquires the information of all USB devices on the host, specifically, the usb-daemon can be sent a request to acquire the USB device information, including usb type, usb bus, usb dev, usb port, usb vendor, usb product, usb Manufacturer, usb driver, and then the information is displayed on the web interface, on the interface, the redirection state of all USB devices on the host and which virtual machine uses the USB device can be viewed, and the redirection service of the USB device can also be started or stopped, for example, refer to Figure 2 , which is a USB device display schematic diagram of the cloud management platform provided by the embodiment of the present application.

[0063] That is, the usb-daemon is used as a server end to provide services for querying the USB device information of the host and configuring the USB device. The cloud management platform is used as a client, when the network USB component of the cloud management platform needs to acquire the USB device information of the host, a request is sent to the usb-daemon through the http protocol, then the information is acquired from the maintained USB device list, and the USB device information is returned to the network USB component of the cloud management platform in the xml format.

[0064] In the embodiment of the present application, when the USB device is configured for the virtual machine, the network USB component adds the USB redirection device (virtual machine USB redirection device xml format) to the virtual machine, and sends a command to the usb-daemon to start the redirection service of the USB device.

[0065] Step 120: Based on the target USB device redirection instruction, start the redirection service of the target USB device and redirect the target USB device to the target virtual machine.

[0066] When the cloud platform's network USB component needs to redirect USB devices to virtual machines, it sends commands to the usb-daemon server via the HTTP protocol. These commands are assembled using XML. After receiving the command request, usb-daemon parses the XML to determine the USB devices that need to be redirected, and then calls the submodule usb-agent to actually enable the redirection service for the USB devices.

[0067] Specifically, when enabling the redirection service of the target USB device based on the target USB device redirection instruction, a preferred timing method is as follows:

[0068] Based on the locally running daemon process usb-daemon, a usb-agent child process is created, which corresponds one-to-one with the target USB device. The usb-agent child process sends the bus, dev, and path of the target USB device to usbredirserver, so that usbredirserver starts a usbredirserver child process corresponding one-to-one with the target USB device, thereby enabling the redirection service of the target USB device.

[0069] In this embodiment, usb-agent is an important submodule of usb-daemon, used to manage the USB device redirection service. usb-agent is a child process created by the usb-daemon process. If a USB device wants to enable the redirection service, a usb-agent child process is created, with a one-to-one relationship between the process and the USB device. usb-agent enables the USB redirection service by passing the USB device's bus, dev, and path information to usbredirserver (an open-source software providing USB redirection services) and starting a usbredirserver child process.

[0070] Further, the daemon process usb-daemon and the usb-agent sub-process perform heartbeat detection based on preset rules, and the daemon process usb-daemon acquires the pid of the usb-agent sub-process and the pid of the usbredirserver sub-process at a time, and when it is detected that the usb-agent sub-process or the usbredirserver sub-process stops running, the daemon process usb-daemon recreates a usb-agent sub-process and a usbredirserver sub-process corresponding to the target USB device.

[0071] For example, in order to ensure the stability of the USB device redirection service, a heartbeat packet (heartbeat packet xml format) needs to be sent between the usb-agent and the usb-daemon to ensure the reliability of the connection between them; in addition, the usb-daemon acquires the pid of the usb-agent sub-process and the pid of the usbredirserver sub-process at a time, and when the usb-agent or the usbredirserver stops running abnormally, the usb-daemon is recreated, which ensures the continuity of the USB device redirection service and further ensures that the service of using the USB device in the virtual machine is not interrupted.

[0072] In the embodiment of the application, the target USB device and the target virtual machine are connected in a TCP / IP network mode; the method further includes the following steps:

[0073] If the target virtual machine is migrated to a remote host and the connection between the target USB device and the target virtual machine is disconnected, the target USB device initiates reconnection to the target virtual machine within a preset time length, wherein the preset time length is greater than the time length required for migration of the target virtual machine.

[0074] In actual application, the usb redirection service uses the open-source usbredirserver software, the principle of which is to query the validity of the USB device by using specified USB device information (bus, dev, path) and an IP port, open the USB device, then create a TCP / IP socket connection to wait for the connection of the virtual machine usb-redir device, and finally read and write the USB device through standard C language interfaces read() and write().

[0075] In the embodiment of the application, the open-source usbredirserver is used as the server, and the virtual machine usb-redir device is used as the client. After the virtual machine is migrated to the remote host, the connection between the server and the client is disconnected. The server will attempt to reconnect after the connection is disconnected. The server will be disconnected after a timeout. The timeout time is greater than the migration time of the virtual machine. After the migration of the virtual machine is completed, the USB device will receive a reconnection request and reestablish the link, so that the reconnection is guaranteed to be successful.

[0076] For example, refer to Figure 3 As shown in the detailed flowchart of the USB device management method provided by the embodiment of the application, the method is applied to a cloud management platform. The cloud management platform is in communication connection with each host. The method comprises the following steps:

[0077] Step 300: Send a USB device information acquisition request to each host respectively.

[0078] Step 310: Receive the USB device information returned by each host, and display the USB device information based on a web interface.

[0079] Step 320: Based on a user-triggered instruction of assigning a target USB device to a target virtual machine, send a target USB device redirection instruction to the target host, so that the target host starts a redirection service of the target USB device based on the target USB device redirection instruction, and redirects the target USB device to the target virtual machine. The target USB device redirection instruction comprises target USB device information and target virtual machine information.

[0080] Based on the same inventive concept as the method embodiment applied to the host, for example, refer to Figure 4 As shown in the structural schematic diagram of the USB device management apparatus provided by the embodiment of the application, the apparatus is applied to a host. Each host is in communication connection with a cloud management platform. The apparatus comprises:

[0081] The acquisition unit 40 is used to acquire the device information of the USB device if it is found that the USB device is connected to the local, and update the device information of the USB device to the USB device information list maintained locally.

[0082] The receiving unit 41 is used to receive a target USB device redirection instruction issued by the cloud management platform. The target USB device redirection instruction comprises target USB device information and target virtual machine information.

[0083] The starting unit 42 is configured to start the redirection service of the target USB device based on the target USB device redirection instruction, and redirect the target USB device to the target virtual machine.

[0084] Optionally, each host comprises a USB device management module, which is run on each host in the form of a daemon process usb-daemon; when starting the redirection service of the target USB device based on the target USB device redirection instruction, the starting unit 42 is specifically configured to:

[0085] create a usb-agent sub-process corresponding to the target USB device based on the locally run daemon process usb-daemon;

[0086] send bus, dev and path of the target USB device to the usbredirserver through the usb-agent sub-process, so that the usbredirserver starts a usbredirserver sub-process corresponding to the target USB device, thereby starting the redirection service of the target USB device.

[0087] Optionally, the apparatus further comprises:

[0088] The daemon process usb-daemon and the usb-agent sub-process perform heartbeat detection based on a preset rule, and the daemon process usb-daemon periodically acquires the pid of the usb-agent sub-process and the pid of the usbredirserver sub-process; when detecting that the usb-agent sub-process or the usbredirserver sub-process stops running, the daemon process usb-daemon re-creates a usb-agent sub-process and a usbredirserver sub-process corresponding to the target USB device.

[0089] Optionally, the target USB device and the target virtual machine are connected in a TCP / IP network manner; the apparatus further comprises a reconnection unit:

[0090] If the target virtual machine is migrated to a remote host, and the connection between the target USB device and the target virtual machine is disconnected, the reconnection unit is configured to instruct the target USB device to initiate reconnection to the target virtual machine within a preset time length, wherein the preset time length is greater than a time length required for migration of the target virtual machine.

[0091] Based on the same inventive concept as the method embodiment applied to the cloud management platform, an exemplary embodiment is described with reference to Figure 5As shown in the figure, a structure schematic diagram of a USB device management apparatus provided by an embodiment of the present application is shown, the apparatus is applied to a cloud management platform, the cloud management platform is in communication link with each host, the apparatus comprises:

[0092] A first sending unit 50 is configured to send a USB device information acquisition request to each host respectively;

[0093] A receiving unit 51 is configured to receive USB device information returned by each host, and display each USB device information based on a web interface.

[0094] A second sending unit 52 is configured to send a target USB device redirection instruction to a target host based on a user triggered instruction of assigning a target USB device to a target virtual machine, so that the target host starts a redirection service of the target USB device based on the target USB device redirection instruction, and redirects the target USB device to the target virtual machine, wherein the target USB device redirection instruction comprises target USB device information and target virtual machine information.

[0095] The above units can be one or more integrated circuits configured to implement the above method, for example, one or more application specific integrated circuits (ASICs), or one or more digital signal processors (DSPs), or one or more field programmable gate arrays (FPGAs), etc. For another example, when a certain unit above is implemented in the form of a processing element scheduling code, the processing element can be a general purpose processor, such as a central processing unit (CPU) or other processor that can invoke program code. For another example, the units can be integrated together to implement in the form of a system on a chip (SOC).

[0096] Further, the USB device management apparatus provided by the embodiment of the present application is from the hardware layer, the hardware architecture schematic diagram of the USB device management apparatus can be referred to Figure 6 As shown in the figure, the USB device management apparatus can comprise a memory 60 and a processor 61,

[0097] The memory 60 is configured to store program instructions, and the processor 61 invokes the program instructions stored in the memory 60, and executes the above method applied to the host according to the obtained program instructions. The specific implementation and technical effects are similar, and will not be repeated here.

[0098] Optionally, the present application also provides a host comprising at least one processing element (or chip) for executing the above-mentioned method embodiments applied to the host.

[0099] Optionally, the present application also provides a program product, for example, a computer readable storage medium, which stores computer executable instructions for causing the computer to execute the above-mentioned method embodiments applied to the host.

[0100] Further, the USB device management apparatus provided by the embodiments of the present application, in terms of hardware layer, the hardware architecture diagram of the USB device management apparatus can be seen from Figure 7 As shown, the USB device management apparatus can include a memory 70 and a processor 71,

[0101] The memory 70 is configured to store program instructions; the processor 71 invokes the program instructions stored in the memory 70, and executes the above-mentioned method embodiments applied to the cloud management platform according to the obtained program instructions. The specific implementation manners and technical effects are similar, and will not be repeated here.

[0102] Optionally, the present application also provides a cloud management platform comprising at least one processing element (or chip) for executing the above-mentioned method embodiments applied to the cloud management platform.

[0103] Optionally, the present application also provides a program product, for example, a computer readable storage medium, which stores computer executable instructions for causing the computer to execute the above-mentioned method embodiments applied to the cloud management platform.

[0104] Here, the machine readable storage medium can be any electronic, magnetic, optical, or other physical storage apparatus, and can contain or store information such as executable instructions, data, and the like. For example, the machine readable storage medium can be a RAM (Random Access Memory, random access memory), a volatile memory, a non-volatile memory, a flash memory, a storage drive (such as a hard disk drive), a solid state drive, any type of storage disk (such as an optical disk, a dvd, etc.), or similar storage medium, or a combination thereof.

[0105] The system, apparatus, module or unit illustrated in the above embodiments can be specifically implemented by a computer chip or entity, or by a product with certain functions. A typical implementation device is a computer, and the specific form of the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0106] For the sake of description, the above-described apparatus is described with various units in function for convenience. Of course, the units can be implemented by one or more software and / or hardware for the implementation of this application.

[0107] Those skilled in the art should understand that embodiments of the present application can be provided as a method, a system or a computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory and the like) containing computer-usable program code.

[0108] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce the functions described in the flowcharts and / or block diagrams for implementing the flows and / or blocks in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 an apparatus that performs the functions specified in the flow or flows and / or block or blocks.

[0109] Furthermore, these computer program instructions can also be stored in a computer-readable memory capable of directing the computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including instruction apparatus, which implements the flows and / or blocks in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 an apparatus that performs the functions specified in the flow or flows and / or block or blocks.

[0110] These computer program instructions can also be loaded into a computer or other programmable data processing device, so that a series of operation steps are performed on the computer or other programmable data processing device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable data processing device provide the functions described in the flowcharts and / or block diagrams for implementing the flows and / or blocks in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 an apparatus that performs the functions specified in the flow or flows and / or block or blocks.

[0111] The above only is the preferred embodiment of the present application, and is not used to limit the present application, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims

1. A USB device management method, characterized by, The application is applied to hosts, each host is in communication connection with a cloud management platform, a web interface of the cloud management platform shows redirection states of USB devices on all hosts, which USB devices are used by which virtual machines, and meanwhile redirection services of the USB devices can be started or stopped, and the method comprises the following steps: If it is monitored that a USB device is accessed to a local host, device information of the USB device is acquired, and the device information of the USB device is updated to a USB device information list maintained locally; A target USB device redirection instruction issued by the cloud management platform is received, wherein the target USB device redirection instruction comprises target USB device information and target virtual machine information; Based on the target USB device redirection instruction, a redirection service of the target USB device is started, and the target USB device is redirected to the target virtual machine.

2. The method of claim 1, wherein, Each host comprises a USB device management module, the USB device management module is run on each host in the form of a daemon process usb-daemon, and based on the target USB device redirection instruction, the step of starting the redirection service of the target USB device comprises the following steps: A usb-agent sub-process corresponding to the target USB device is created based on the daemon process usb-daemon run locally; The bus, dev and path of the target USB device are sent to usbredirserver through the usb-agent sub-process, so that usbredirserver starts a usbredirserver sub-process corresponding to the target USB device, thereby starting the redirection service of the target USB device.

3. The method of claim 2, wherein, The method further comprises the following steps: The daemon process usb-daemon and the usb-agent sub-process perform heartbeat detection based on preset rules, and the daemon process usb-daemon acquires the pid of the usb-agent sub-process and the pid of the usbredirserver sub-process at a time, when it is detected that the usb-agent sub-process or the usbredirserver sub-process stops running, the daemon process usb-daemon re-creates a usb-agent sub-process and a usbredirserver sub-process corresponding to the target USB device.

4. The method according to any one of claims 1 to 3, characterized in that, The target USB device and the target virtual machine are connected in a TCP / IP network mode; the method further comprises the following steps: If the target virtual machine is migrated to a remote host, the connection between the target USB device and the target virtual machine is disconnected, then the target USB device initiates reconnection to the target virtual machine within a preset time length, wherein the preset time length is longer than a time length required for migration of the target virtual machine.

5. A USB device management method, characterized by, The application is applied to a cloud management platform, the cloud management platform is in communication connection with hosts, and the method comprises the following steps: USB device information acquisition requests are respectively sent to the hosts; The USB device information of the local access returned by the hosts is received, and the USB device information is displayed based on a web interface, wherein the web interface displays the redirection state of the USB device on all hosts, which virtual machine uses the USB device, and the redirection service of the USB device can be started or stopped; Based on the instruction triggered by the user to assign the target USB device to the target virtual machine, a target USB device redirection instruction is sent to the target host, so that the target host starts the redirection service of the target USB device based on the target USB device redirection instruction, and redirects the target USB device to the target virtual machine, wherein the target USB device redirection instruction includes target USB device information and target virtual machine information.

6. A USB device management apparatus characterized by comprising: The application is applied to a host, each host is in communication connection with a cloud management platform, the web interface of the cloud management platform displays the redirection state of the USB device on all hosts, which virtual machine uses the USB device, and the redirection service of the USB device can be started or stopped, and the device comprises: If it is listened that a USB device accesses locally, the acquisition unit is used to acquire the device information of the USB device, and the device information of the USB device is updated to the USB device information list maintained locally; A receiving unit is configured to receive a target USB device redirection instruction issued by the cloud management platform, wherein the target USB device redirection instruction includes target USB device information and target virtual machine information; A starting unit is configured to start the redirection service of the target USB device based on the target USB device redirection instruction, and redirect the target USB device to the target virtual machine.

7. The apparatus of claim 6, wherein, Each host comprises a USB device management module, the USB device management module runs on each host in the form of a daemon process usb-daemon, and when the starting unit starts the redirection service of the target USB device based on the target USB device redirection instruction, the starting unit is specifically configured to: Based on the daemon process usb-daemon running locally, an usb-agent sub-process corresponding to the target USB device is created; The bus, dev and path of the target USB device are sent to usbredirserver through the usb-agent sub-process, so that usbredirserver starts an usbredirserver sub-process corresponding to the target USB device, thereby starting the redirection service of the target USB device.

8. The apparatus of claim 7, wherein, The device further comprises: The daemon process usb-daemon and the usb-agent sub-process perform heartbeat detection based on preset rules, and the daemon process usb-daemon periodically acquires the pid of the usb-agent sub-process and the pid of the usbredirserver sub-process, and when it is detected that the usb-agent sub-process or the usbredirserver sub-process stops running, the daemon process usb-daemon recreates a usb-agent sub-process and a usbredirserver sub-process corresponding to the target USB device.

9. The device of any one of claims 6-8, wherein, The target USB device and the target virtual machine are connected in a TCP / IP network mode; the apparatus further comprises a reconnection unit: If the target virtual machine is migrated to a remote host, the connection between the target USB device and the target virtual machine is disconnected, and the reconnection unit is configured to instruct the target USB device to initiate reconnection to the target virtual machine within a preset time period, wherein the preset time period is longer than the time period required for migration of the target virtual machine.

10. A USB device management apparatus, characterized by comprising: The apparatus is applied to a cloud management platform, the cloud management platform is communicatively connected with a plurality of hosts, and the apparatus comprises: A first sending unit configured to send USB device information acquisition requests to the plurality of hosts respectively; A receiving unit configured to receive USB device information returned by the plurality of hosts and display the USB device information based on a web interface, wherein the web interface displays the redirection status of USB devices on all hosts, which USB device is used by which virtual machine, and can also start / close the redirection service of the USB device; A second sending unit configured to send a target USB device redirection instruction to a target host based on an instruction triggered by a user to assign a target USB device to a target virtual machine, so that the target host starts the redirection service of the target USB device based on the target USB device redirection instruction and redirects the target USB device to the target virtual machine, wherein the target USB device redirection instruction comprises target USB device information and target virtual machine information.

Citation Information

Patent Citations

  • USB equipment network sharing system and method based on USB redirection

    CN105391652A