Hypervisor-based USB device virtualization method and computer device

Through the USB virtualization method managed by hypervisor, the problems of USB hardware device allocation and data transmission performance in multi-operating system environments are solved, and efficient virtual USB device management and data transmission effect with performance close to real hardware is achieved.

CN119225903APending Publication Date: 2024-12-31ZHONGLING ZHIXING (CHENGDU) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411254217.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-09
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

In a virtualized environment of multiple operating systems, the allocation and data transmission performance of USB hardware devices is difficult to approach real hardware devices, resulting in management and performance problems.

Method used

Through the USB virtualization method managed by hypervisor, a dedicated channel and driver interaction is established, a USB hardware device is redirected, and the registration and operation of virtual USB devices is realized through virtualized drivers and software components to ensure that the data transmission performance is close to the real hardware.

Benefits of technology

It realizes flexible and efficient allocation and management of USB hardware devices, improves hardware utilization, reduces latency and resource usage, increases throughput, and makes the data transmission performance of virtual USB devices close to real hardware devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119225903A_ABST
    Figure CN119225903A_ABST
Patent Text Reader

Abstract

The invention discloses a hypervisor-based USB (Universal Serial Bus) equipment virtualization method and computer equipment, which are applied to a source operating system and a target operating system which are managed and operated by a hypervisor, and the method comprises the following steps of: determining real USB hardware equipment which needs to be redirected in the source operating system; establishing a dedicated channel between the USB virtualization drive of the source operating system and the USB virtualization drive of the target operating system through a hypervisor; registering a USB virtual device corresponding to the USB hardware device to a USB software component of the target operating system through a USB virtualization drive of the target operating system; sending an operation request received from the dedicated channel to the USB hardware device through a USB virtualization driver of the source operating system; sending an operation request received from the dedicated channel to the USB software component through a USB virtualization drive of the target operating system; according to the scheme, the problem that the USB controller and the USB equipment controlled by the USB controller are difficult to distribute to each operating system is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of virtualization, and in particular to a hypervisor-based USB device virtualization method and computer equipment. Background Art

[0002] With the development of virtualization technology and hardware technology, as well as the demand for product cost and security, running multiple operating systems on a hardware platform has become feasible and necessary. In this multi-operating system virtualization operating environment, a flexible and efficient method is urgently needed to allocate various hardware resources to each operating system.

[0003] Specifically in the case of USB hardware, current hardware platforms usually have several USB controllers, each of which may work in device mode or host mode. A USB controller in host mode can control various types of USB hardware devices. How to allocate each USB controller and the USB devices it controls to each operating system and ensure that the data transmission performance of the USB device is as close to the real hardware as possible has become a practical requirement that must be met. Summary of the invention

[0004] The purpose of the present invention is to provide a hypervisor-based USB device virtualization method and computer device, so as to allocate each USB controller and the USB device controlled by it to each operating system, and ensure that the data transmission performance of the virtual USB device is close to the transmission performance of the real hardware device.

[0005] A first aspect of an embodiment of the present invention provides a hypervisor-based USB device virtualization method, which is applied to a source operating system and a destination operating system managed and run by a hypervisor, comprising:

[0006] Determine the real USB hardware device that needs to be redirected in the source operating system;

[0007] Establishing a dedicated channel between the USB virtualization driver of the source operating system and the USB virtualization driver of the destination operating system through the hypervisor;

[0008] Registering a USB virtual device corresponding to the USB hardware device to a USB software component of the target operating system through a USB virtualization driver of the target operating system;

[0009] Sending the operation request received from the dedicated channel to the USB hardware device through the USB virtualization driver of the source operating system;

[0010] The operation request received from the dedicated channel is transmitted to the USB software component through the USB virtualization driver of the target operating system.

[0011] Further, the determining of the real USB hardware device that needs to be redirected in the source operating system includes:

[0012] The real USB hardware devices that need to be redirected in the source operating system are determined by reading and parsing a redirection configuration file pre-stored in the source operating system, wherein the redirection configuration file includes: the name of the USB hardware device that needs to be redirected, the name of the target operating system, the working mode of the redirected USB hardware device, and a list of USB hardware devices that need to be redirected and managed by a USB controller.

[0013] Further, the step of registering a USB virtual device corresponding to the USB hardware device with a USB software component of the target operating system through a USB virtualization driver of the target operating system includes:

[0014] Parsing the USB redirection configuration file through the USB virtualization driver in the source operating system and generating a configuration database;

[0015] The USB virtualization driver in the target operating system interacts with the USB virtualization driver in the source operating system to obtain the USB hardware device that needs to be redirected, wherein the USB hardware device includes a USB controller and a USB device;

[0016] For each USB controller that needs to be redirected, the USB virtualization driver of the target operating system will register a virtual USB controller with the USB software component of the target operating system, and bind the virtual USB controller to the real USB controller hardware in the source operating system through a dedicated channel;

[0017] Creating a virtual host controller for redirecting all specified USB hardware devices in the source operating system;

[0018] For each USB device that needs to be redirected, the USB virtualization driver of the target operating system will create a virtual USB device controlled by the virtual host controller, connect the virtual USB device to the real USB device in the source operating system through a dedicated channel, and start the device enumeration process of the virtual host controller.

[0019] Furthermore, the USB virtualization driver in the target operating system redirects the operation of the USB software component of the target operating system on the USB virtual device to the real hardware device in the source operating system, specifically:

[0020] The operation request of the user state and / or other kernel modules is received through the interface provided by the USB software component of the target operating system, and the operation request is forwarded to the USB virtualization driver of the target operating system. The USB virtualization driver of the target operating system forwards the operation request to the USB virtualization driver of the source operating system through the dedicated channel. The USB virtualization driver of the source operating system parses the operation request, converts the operation request into an operation request for a real hardware device, and submits it to the USB software component in the source operating system. The interface of the hardware driver is called by the USB software component in the source operating system to operate the real hardware device.

[0021] Further, the redirecting of the operation of the real hardware device to the USB software component in the destination operating system through the source operating system is specifically:

[0022] An operation request of a real hardware device is received through an interface defined by a USB software component in the source operating system. If the real hardware device is configured to be redirected to a certain target operating system, the USB software component in the source operating system redirects the operation request to a USB virtualization driver of the source operating system. The USB virtualization driver of the source operating system forwards the operation request to the USB virtualization driver in the target operating system. The operation request is parsed by the USB virtualization driver in the target operating system, and the USB software component in the target operating system is called.

[0023] Furthermore, the method further includes: setting a management interface in the source operating system for dynamically adding or deleting USB virtual devices when the system is running, and adjusting redirection information of USB virtual devices.

[0024] A second aspect of an embodiment of the present invention provides a computer device, wherein the hardware of the computer device includes a real USB hardware device, the operating system of the computer device includes a source operating system, and a destination operating system running based on a hypervisor, and the computer device is used to execute any one of the hypervisor-based USB device virtualization methods through the source operating system and the destination operating system.

[0025] The present invention has at least the following beneficial effects:

[0026] The present invention provides a hypervisor-based USB device virtualization method. In a multi-operating system environment supported by virtualization technology, USB hardware devices can be flexibly and efficiently redirected to other designated target operating system environments through a dedicated USB virtualization driver and hypervisor virtualization software. After the USB hardware devices are redirected, they will be recognized as native USB hardware devices by the target operating system. In the source operating system where they originally reside, the USB software components in the source operating system cooperate with the USB virtualization driver to redirect them to the target operating system, so they are invisible to all other software modules in the source operating system. This solution solves the problem that USB hardware devices are difficult to manage in a virtualized environment, and that various USB controllers and the USB devices they control are difficult to assign to various operating systems. In addition, since the virtualization solution does not rely on any specific USB hardware implementation, the versatility of the solution is guaranteed, so that the solution can be widely used in multi-operating system application scenarios involving USB hardware. Furthermore, since it relies on the support of the hypervisor, the data transmission of the USB hardware device is actually completed by the USB hardware, and the software does not perform actual data transmission operations, but only provides prerequisites for the hardware to transmit data, thereby maximizing the utilization of the hardware, reducing the delay during data transmission, increasing the throughput, and reducing the system resource usage, so that the data transmission performance of the virtual USB device is close to the transmission performance of the real hardware device.

[0027] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 A flow chart of a hypervisor-based USB device virtualization method provided by the present invention;

[0029] Figure 2 A schematic diagram of an application scenario of a hypervisor-based USB device virtualization method provided by the present invention. DETAILED DESCRIPTION

[0030] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.

[0031] In the description of the present invention, it is necessary to understand that the terms "upper", "lower", "front", "back", "left", "right", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship are based on the orientation or position relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.

[0032] Combination Figure 1-Figure 2 The embodiments are described.

[0033] A first aspect of the present embodiment provides a hypervisor-based USB device virtualization method, which is applied to a source operating system and a destination operating system managed and run by a hypervisor, including:

[0034] Determine the real USB hardware device that needs to be redirected in the source operating system;

[0035] Registering a USB virtual device corresponding to the USB hardware device to a USB software component of the target operating system through a USB virtualization driver of the target operating system;

[0036] Establishing a dedicated channel between the USB virtualization driver of the source operating system and the USB virtualization driver of the destination operating system through the hypervisor;

[0037] Sending the operation request received from the dedicated channel to the USB hardware device through the USB virtualization driver of the source operating system;

[0038] The operation request received from the dedicated channel is transmitted to the USB software component through the USB virtualization driver of the target operating system.

[0039] In the present invention, a source operating system and several other target operating systems are managed and run by a hypervisor. A redirection configuration file is pre-stored in the file system of the source operating system, in which how to redirect USB hardware devices is specified, and the USB hardware devices include USB controllers and USB devices. The USB virtualization driver in the source operating system reads the redirection configuration file, determines the USB controller and USB device that need to be redirected, and notifies the USB virtualization driver in the target operating system. The USB virtualization driver in the target operating system registers the virtual USB device corresponding to the USB device to the USB software component of the target operating system based on the redirection information provided by the USB virtualization driver in the source operating system. Under the support of the hypervisor, the USB virtualization drivers in the source operating system and the target operating system cooperate with each other. In the target operating system, the operation from the USB software component to the USB virtual device is redirected to the real USB device in the source operating system; in the source operating system, the operation from the USB hardware device is redirected to the USB software component in the target operating system.

[0040] The dedicated channel between the USB virtualization drivers in the source operating system and the target operating system is based on shared memory and interrupt mechanism, supported by a dedicated hypervisor, to achieve efficient communication between USB virtualization drivers.

[0041] This solution solves the problem of USB hardware devices being difficult to manage in a virtualized environment, and because the virtualization solution does not rely on any specific USB hardware implementation, the versatility of the solution is guaranteed, so that the solution can be widely used in multi-operating system application scenarios involving USB hardware; further, because it relies on the support of the hypervisor, the data transmission of the USB hardware device is actually completed by the USB hardware, and the software does not perform actual data transmission operations, but only provides prerequisites for the hardware to transmit data, thereby maximizing the utilization of the hardware, reducing the delay during data transmission, increasing the throughput, and reducing the system resource usage, so that the data transmission performance of the virtual USB device is close to the transmission performance of the real hardware device.

[0042] Further, the determining of the real USB hardware device that needs to be redirected in the source operating system includes:

[0043] The real USB hardware devices that need to be redirected in the source operating system are determined by reading and parsing a redirection configuration file pre-stored in the source operating system, wherein the redirection configuration file includes: the name of the USB hardware device that needs to be redirected, the name of the target operating system, the working mode of the redirected USB hardware device, and a list of USB hardware devices that need to be redirected and are managed by a USB controller. The working modes of the redirected USB hardware device include device mode and host mode. When the redirected USB hardware device is in host mode, the redirected USB hardware device is still a device managed by the USB controller.

[0044] Among them, the redirection configuration file can be set by the user according to actual needs and stored in the source operating system. Especially when there are multiple target operating systems, the user can indicate which target operating system each USB hardware device needs to be redirected to by setting the redirection configuration file according to actual needs. For example, the name of the USB hardware device to be redirected and the name of the target operating system included in the redirection configuration file can indicate the directional relationship between a specific USB hardware device and a specific target operating system.

[0045] Further, the step of registering a USB virtual device corresponding to the USB hardware device with a USB software component of the target operating system through a USB virtualization driver of the target operating system includes:

[0046] Parsing the USB redirection configuration file through the USB virtualization driver in the source operating system and generating a configuration database;

[0047] During the boot process of the source operating system, the USB virtualization driver in the source operating system will parse the USB redirection configuration file and generate a configuration database to prepare for the next step.

[0048] The USB virtualization driver in the target operating system interacts with the USB virtualization driver in the source operating system to obtain the USB hardware device that needs to be redirected, wherein the USB hardware device includes a USB controller and a USB device;

[0049] When the target operating system starts, the USB virtualization driver in the target operating system interacts with the USB virtualization driver in the source operating system to obtain the redirected USB hardware device that needs to be redirected, and the USB hardware device includes a USB controller and a USB device.

[0050] For each USB controller that needs to be redirected, the USB virtualization driver of the target operating system will register a virtual USB controller with the USB software component of the target operating system, which can be in device mode or host mode, and bind the virtual USB controller to the real USB controller hardware in the source operating system through a dedicated channel;

[0051] Creating a virtual host controller for redirecting all specified USB hardware devices in the source operating system;

[0052] For each USB device that needs to be redirected, the USB virtualization driver of the target operating system will create a virtual USB device controlled by the virtual host controller, connect the virtual USB device to the real USB device in the source operating system through a dedicated channel, and start the device enumeration process of the virtual host controller.

[0053] Furthermore, the USB virtualization driver in the target operating system redirects the operation of the USB software component of the target operating system on the USB virtual device to the real hardware device in the source operating system, specifically:

[0054] The operation request of the user state and / or other kernel modules is received through the interface provided by the USB software component of the target operating system, and the operation request is forwarded to the USB virtualization driver of the target operating system. The USB virtualization driver of the target operating system forwards the operation request to the USB virtualization driver of the source operating system through the dedicated channel. The USB virtualization driver of the source operating system parses the operation request, converts the operation request into an operation request for a real hardware device, and submits it to the USB software component in the source operating system. The interface of the hardware driver is called by the USB software component in the source operating system to operate the real hardware device.

[0055] In the target operating system, the user state or other kernel modules operate the virtual USB device by using the interface provided by the USB software component of the target operating system. The USB software component of the target operating system forwards these operation requests to the USB virtualization driver of the target operating system. The USB virtualization driver of the target operating system then forwards these operation requests to the USB virtualization driver in the source operating system through a dedicated channel. In the source operating system, the USB virtualization driver parses these operation requests, converts them into operation requests for the corresponding real hardware devices, and submits them to the USB software component in the source operating system. The USB software component in the source operating system finally calls the interface of the hardware driver to operate the real hardware device, and finally realizes redirecting the operation of the virtual USB device in the target operating system to the real USB device in the source operating system.

[0056] Further, the redirecting of the operation of the real hardware device to the USB software component in the destination operating system through the source operating system is specifically:

[0057] An operation request of a real hardware device is received through an interface defined by a USB software component in the source operating system. If the real hardware device is configured to be redirected to a certain target operating system, the USB software component in the source operating system redirects the operation request to a USB virtualization driver of the source operating system. The USB virtualization driver of the source operating system forwards the operation request to the USB virtualization driver in the target operating system. The operation request is parsed by the USB virtualization driver in the target operating system, and the USB software component in the target operating system is called.

[0058] In the source operating system, when the real hardware device driver uses the interface defined by the USB software component in the source operating system, if the hardware device is configured to be redirected to a certain target operating system, the USB software component in the source operating system redirects the operation request to the USB virtualization driver of the source operating system, and the USB virtualization driver of the source operating system then forwards these interface calls to the USB virtualization driver in the target operating system. In the target operating system, the USB virtualization driver parses these interface calls and converts them into interface calls to the USB software component in the target operating system, thereby finally redirecting the interface calls of the real device driver in the source operating system to the USB software component to the USB software component in the target operating system.

[0059] Furthermore, the method further includes: setting a management interface in the source operating system for dynamically adding or deleting USB virtual devices when the system is running, and adjusting redirection information of USB virtual devices.

[0060] In addition to the USB redirection configuration file in the source operating system, the source operating system also provides a management interface, allowing the virtual USB device to be dynamically added or deleted when the entire system is running, and adjusting the redirection configuration options of the virtual USB device, such as changing the target operating system for real device redirection, changing the redirection device filtering policy managed by a real controller, etc., and supporting the configuration operation to be saved in the redirection configuration file. The present invention can specify the redirection policy of USB hardware statically (configuration file mode) and dynamically (management interface mode), thereby improving flexibility.

[0061] A second aspect of an embodiment of the present invention provides a computer device, wherein the hardware of the computer device includes a real USB hardware device, the operating system of the computer device includes a source operating system, and a destination operating system running based on a hypervisor, and the computer device is used to execute any one of the hypervisor-based USB device virtualization methods through the source operating system and the destination operating system.

[0062] It should also be noted that the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of further restrictions, the elements defined by the sentence "includes one..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements. The words "first", "second" and the like are used to indicate names, but do not indicate any specific order. The above schematically describes the invention and its implementation methods, which is not restrictive. The invention can be implemented in other specific forms without departing from the spirit or basic features of the invention. What is shown in the accompanying drawings is only one of the implementation methods of the invention, and the actual structure is not limited thereto. Any figure mark in the claims should not limit the claims involved. Therefore, if a person of ordinary skill in the art is inspired by it, and does not deviate from the purpose of the invention, and designs a structural mode and an embodiment similar to the technical solution without creativity, they should all belong to the scope of protection of this patent.

Claims

1. A hypervisor-based USB device virtualization method, applied to a source operating system and a destination operating system managed and run by a hypervisor, characterized in that: include: Determine the real USB hardware device that needs to be redirected in the source operating system; Establishing a dedicated channel between the USB virtualization driver of the source operating system and the USB virtualization driver of the destination operating system through the hypervisor; Registering a USB virtual device corresponding to the USB hardware device to a USB software component of the target operating system through a USB virtualization driver of the target operating system; Sending the operation request received from the dedicated channel to the USB hardware device through the USB virtualization driver of the source operating system; The operation request received from the dedicated channel is transmitted to the USB software component through the USB virtualization driver of the target operating system.

2. The method for virtualizing a USB device based on a hypervisor according to claim 1, characterized in that: Determining the real USB hardware device that needs to be redirected in the source operating system includes: The real USB hardware devices that need to be redirected in the source operating system are determined by reading and parsing a redirection configuration file pre-stored in the source operating system, wherein the redirection configuration file includes: the name of the USB hardware device that needs to be redirected, the name of the target operating system, the working mode of the redirected USB hardware device, and a list of USB hardware devices that need to be redirected and managed by a USB controller.

3. The method for USB device virtualization based on hypervisor according to claim 1, characterized in that: The step of registering a USB virtual device corresponding to the USB hardware device with a USB software component of the target operating system through a USB virtualization driver of the target operating system comprises: Parsing the USB redirection configuration file through the USB virtualization driver in the source operating system and generating a configuration database; The USB virtualization driver in the target operating system interacts with the USB virtualization driver in the source operating system to obtain the USB hardware device that needs to be redirected, wherein the USB hardware device includes a USB controller and a USB device; For each USB controller that needs to be redirected, the USB virtualization driver of the target operating system will register the corresponding virtual USB controller with the USB software component of the target operating system, and bind the virtual USB controller to the real USB controller hardware in the source operating system through a dedicated channel; Creating a virtual host controller for redirecting all specified USB hardware devices in the source operating system; For each USB device that needs to be redirected, the USB virtualization driver of the target operating system will create a corresponding virtual USB device controlled by the virtual host controller, connect the virtual USB device to the real USB device in the source operating system through a dedicated channel, and start the device enumeration process of the virtual host controller.

4. The method for USB device virtualization based on hypervisor according to claim 3, characterized in that: The USB virtualization driver in the target operating system is used to redirect the operation of the USB software component of the target operating system on the USB virtual device to the real hardware device in the source operating system, specifically: The operation request of the user state and / or other kernel modules is received through the interface provided by the USB software component of the target operating system, and the operation request is forwarded to the USB virtualization driver of the target operating system. The USB virtualization driver of the target operating system forwards the operation request to the USB virtualization driver of the source operating system through the dedicated channel. The USB virtualization driver of the source operating system parses the operation request, converts the operation request into an operation request for a real hardware device, and submits it to the USB software component in the source operating system. The interface of the hardware driver is called by the USB software component in the source operating system to operate the real hardware device.

5. The method for USB device virtualization based on hypervisor according to claim 3, characterized in that: The redirection of the operation of the real hardware device to the USB software component in the destination operating system through the source operating system is specifically: An operation request of a real hardware device is received through an interface defined by a USB software component in the source operating system. If the real hardware device is configured to be redirected to the target operating system, the USB software component in the source operating system redirects the operation request to a USB virtualization driver of the source operating system. The USB virtualization driver of the source operating system forwards the operation request to a USB virtualization driver in the target operating system. The operation request is parsed by the USB virtualization driver in the target operating system, and the USB software component in the target operating system is called.

6. The method for USB device virtualization based on hypervisor according to claim 1, characterized in that: Also includes: A management interface is set in the source operating system to dynamically add or delete USB virtual devices and adjust redirection information of USB virtual devices when the system is running.

7. A computer device, characterized in that: The hardware of the computer device includes a real USB hardware device, the operating system of the computer device includes a source operating system and a destination operating system running based on a hypervisor, and the computer device is used to execute the method described in any one of claims 1 to 6 through the source operating system and the destination operating system.