Bus hardware equipment direct connection method, host machine and storage medium
By deploying the target container and virtualization management device on the host machine, USB devices can be directly mounted to the virtual machine, solving the problem of low data interaction efficiency in USB device management and realizing efficient USB device pass-through communication.
Patent Information
- Application Number
- CN202411365456.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2025-02-07
AI Technical Summary
When connecting a large number of USB devices to a virtual machine, existing technologies require management through power strip assistant software, resulting in long data exchange links and low efficiency.
By deploying the target container on the host machine, using a virtualization management device to mount the bus hardware device to the target container, and mapping the storage address space of the target hardware device to the storage address space of the virtual machine, pass-through communication between the USB device and the virtual machine is achieved.
It reduces data transmission links, improves the interaction efficiency and stability of USB devices, saves resources, and supports lightweight and convenient management and scalability.
Smart Images

Figure CN119396521A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a bus hardware device direct access method, a host machine and a computer storage medium. Background Art
[0002] Currently, many devices are connected using specific interfaces, such as USB interfaces. The same device can be connected to multiple USB devices. In an application scenario, a batch of USB devices can be connected to a virtual machine (such as a Windows virtual machine) running the computer device operating system, and the USB devices are mapped through the PID (device identifier) and VID (vendor identifier) of the USB devices. However, since USB devices produced by the same manufacturer may have the same PID and VID, when a batch of USB devices are connected to a virtual machine, it is necessary to use the socket assistant software to manage the connected USB devices.
[0003] However, when a large number of USB devices are connected to a computer through the socket assistant software, the socket assistant software is needed to manage the USB devices and interact with the USB devices through the network. The data interaction link is long and the data interaction efficiency is low. Summary of the invention
[0004] The embodiments of the present application provide a bus hardware device direct pass method, a host machine and a computer storage medium to solve the technical problem that the data interaction link is long when a USB device is connected, resulting in low data interaction efficiency.
[0005] In a first aspect, a bus hardware device direct access method based on a host machine is provided, wherein the host machine is deployed with a target container, and the target container runs a virtual machine and a virtualization management device, and the method comprises: The virtualization management device mounts the bus hardware device connected to the host machine to the target container; The virtualization management device identifies the bus hardware device successfully mounted on the target container and selects the target hardware device; The virtualization management device mounts the target hardware device to the virtual machine; The virtualization management device maps the storage address space of the target hardware device to the storage address space of the virtual machine to obtain a mapped storage address space; The virtual machine communicates and interacts with the target hardware device based on the mapped storage address space.
[0006] Furthermore, the virtual machine communicates and interacts with the target hardware device based on the mapped storage address space, including: The virtual machine directly accesses the mapped storage address space to achieve communication interaction with the target hardware device.
[0007] Furthermore, the virtual machine communicates and interacts with the target hardware device based on the mapped storage address space, including: When the virtual machine initiates a device access request for the target hardware device, the memory management unit of the host machine maps the mapped storage address space of the host machine to the virtual memory address corresponding to the device access request; The virtual machine accesses the virtual memory address to achieve communication interaction with the target hardware device.
[0008] Furthermore, the selecting of the target hardware device includes: The virtualization management device reads a device configuration file mounted on the virtual machine, wherein the device configuration file is mounted to the virtual machine when the target container is started; The virtualization management device selects the target hardware device from the bus hardware devices successfully mounted on the target container based on the device configuration file.
[0009] Furthermore, the device type of the bus hardware device includes a serial port bus device.
[0010] Further, the virtual machine includes a first operating system virtual machine, the first operating system virtual machine runs client software and automation tools, and the virtual machine communicates and interacts with the target hardware device based on the mapped storage address space, including: The first operating system virtual machine implements an automated operation process for the client software based on the automation tool, wherein, during the execution of the automated operation process, communication and interaction are performed with the target hardware device based on the mapped storage address space.
[0011] Furthermore, before the virtualization management device mounts the bus hardware device connected to the host machine to the target container, the method further includes: The virtualization management device creates a container to be orchestrated in the host machine, creates multiple service pools, and determines the client software type corresponding to each service pool; The virtualization management device establishes a correspondence between each container and a service pool, wherein containers in the same service pool match the client software type corresponding to the service pool; The virtualization management device starts containers of different service pools in parallel using different threads based on the correspondence between each container and the service pool; The virtualization management device selects the target container from the started containers according to the type of client software on the virtual machine.
[0012] In a second aspect, a host machine is provided, wherein a target container is deployed on the host machine, and a virtual machine and a virtualization management device are running on the target container, wherein: The virtualization management device mounts the bus hardware device connected to the host machine to the target container; The virtualization management device identifies the bus hardware device successfully mounted on the target container and selects the target hardware device; The virtualization management device mounts the target hardware device to the virtual machine; The virtualization management device maps the storage address space of the target hardware device to the storage address space of the virtual machine to obtain a mapped storage address space; The virtual machine communicates and interacts with the target hardware device based on the mapped storage address space.
[0013] In a third aspect, a host machine is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the aforementioned bus hardware device pass-through methods when executing the computer program.
[0014] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the bus hardware device direct pass method as described in any one of the above items is implemented. In any of the solutions provided above, when using a power strip to access a large number of bus hardware devices such as USB devices, there is no need to use the network communication form of the power strip assistant software to communicate and interact with the bus hardware devices. The bus hardware devices can directly exchange data with the virtual machine in the target container through the host machine hardware serial port. For example, a batch of USB devices can directly exchange data with the Windows virtual machine in the target container through the host machine hardware serial port, achieving direct connection, reducing the data transmission link and improving data interaction efficiency, and effectively improving the interaction stability of USB devices; in addition, the embodiment of the present application adopts the container method, which is first mounted on the container, and also has the advantages of being lightweight and convenient, which can save resources, achieve direct connection based on the container, and facilitate the subsequent use of the cloud native technology stack to conveniently manage services, and has stronger application scenarios and scalability. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0016] Figure 1 This is a schematic diagram of an application environment of a host-based bus hardware device direct access method in an embodiment of the present application; Figure 2 It is a flow chart of a bus hardware device direct access method based on a host machine in one embodiment of the present application; Figure 3 It is a structural diagram of a virtualization management device in one embodiment of the present application; Figure 4 It is a structural schematic diagram of a host machine in one embodiment of the present application. DETAILED DESCRIPTION
[0017] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0018] The embodiment of the present application provides a host-based bus hardware device direct access method, which can be applied as follows: Figure 1 Specifically, the host-based bus hardware device direct access method is applied in the following application environments: Figure 1 In the host machine shown, the host machine may refer to any computer device that can deploy a target container and a virtualization management device. The host machine includes a hardware interface for connecting to a bus hardware device. Exemplarily, the above-mentioned bus hardware device includes but is not limited to a serial bus device (Universal Serial Bus, USB) device, a MicroUSB device or a hardware device in the form of other hardware interfaces, without specific limitation.
[0019] The target container on the host machine runs a virtual machine and a virtualization management device. The target container refers to a container that can deploy and run a virtual machine. As an example explanation, the container type of the target container includes but is not limited to containers such as Docker containers and Podman containers. In addition, as another explanation, the target container can be a container built based on the Linux system or a container built based on the Windows system, without specific limitation. The virtual machine refers to a virtual operating system that can run on the target container. As an example explanation, the virtual machine includes but is not limited to Windows virtual machines, Linux virtual machines, etc., without specific limitation.
[0020] In the embodiment of the present application, when a large number of bus hardware devices are used, for example, when a large number of USB devices are used, a large number of USB devices can be directly mounted to the virtual machine in the target container of the host machine, so as to realize direct communication between the USB device and the virtual machine, without using the network method of the socket assistant software to manage the USB device, thus shortening the data transmission link and improving the interaction stability of the USB device. The embodiment of the present application is described in detail below through specific embodiments.
[0021] In one embodiment, if Figure 1 As shown, a bus hardware device direct pass method based on a host machine is provided, and the method is applied in Figure 1 Taking the host machine in as an example, the host machine is deployed with a target container, and the target container runs a virtual machine and a virtualization management device. The method includes the following steps: S10: The virtualization management device mounts the bus hardware device connected to the host machine to the target container.
[0022] S20: The virtualization management device identifies the bus hardware device successfully mounted on the target container, and selects the target hardware device.
[0023] S30: The virtualization management apparatus mounts the target hardware device onto the virtual machine.
[0024] In this embodiment, the target container on the host machine runs a virtual machine and a virtualization management device. The virtualization management device is a module on the running target container set to implement virtualization management. The target container refers to a container that can deploy and run a virtual machine. As an example explanation, the container type of the target container includes but is not limited to a docker container. The virtual machine refers to a virtual operating system that can run on the target container, that is, a virtual machine; as an example explanation, the operating system virtual machine includes but is not limited to a windows virtual machine, and is not specifically limited. For the sake of convenience, the embodiments of this application and subsequent embodiments will be explained using the above examples as examples, but without limitation.
[0025] In steps S10-S30, when a large number of bus hardware devices are used, the large number of bus hardware devices are first connected to the corresponding hardware interfaces of the host machine through the hardware interfaces, and then the bus hardware devices connected through the interfaces are mounted on the target container, and the bus hardware devices successfully mounted on the target container are identified, and the target hardware devices are selected therefrom, and then the selected target hardware devices are further mounted on the virtual machine.
[0026] Among them, bus hardware devices include but are not limited to USB devices or devices in the form of other hardware interfaces, and are not specifically limited. For example, taking USB devices as an example, when using a large number of USB devices, a large number of USB devices need to be connected to the host through a serial port. After detecting the USB device connected to the host, the virtualization management device will mount the USB device that has been connected through the interface to the target container. For example, the host / dev / bus directory of the host is mounted into the target container, thereby realizing the mounting of the USB device connected through the USB interface into the target container.
[0027] After successfully mounting into the target container, the virtualization management device identifies the bus hardware device successfully mounted on the target container and selects the target hardware device. As an example, the lsusb tool can be used to execute: yuminstall usbutils -y; execute the lsusb -tv command. Since the bus and port number corresponding to each real USB port are fixed, the bus and port number corresponding to each USB port can be recorded, and the identification ID of the USB device can be located according to the bus and port number. By executing lsusb to extract the pid and vid of the specified USB device (target hardware device), the USB device can be directly assigned to the Windows virtual machine on the target container, so that the Windows virtual machine can safely access the USB device on the host machine and realize device transmission. As an explanatory example, in the specific implementation, the Xml device mounting file can be used in conjunction with the virsh command line tool to directly assign the USB device to the Windows virtual machine on the target container, so that the USB device can be accurately mounted in the Windows virtual machine for use.
[0028] S40: The virtualization management device maps the storage address space of the target hardware device to the storage address space of the virtual machine to obtain a mapped storage address space.
[0029] S50: The virtual machine communicates and interacts with the target hardware device based on the mapped storage address space.
[0030] In steps S40-S50, after the virtualization management device mounts the target hardware device to the virtual machine on the target container, direct interaction between the container's virtual machine and the target hardware device can be achieved. Since there is only a mounting relationship, in order to achieve the purpose of direct data interaction, the virtualization management device also needs to map the storage address space of the target hardware device to the storage address space of the virtual machine to obtain a mapped storage address space. It should be understood that after mapping, operations on the storage address space of the virtual machine will be mapped back to the storage address space of the target hardware device, so that the virtual machine can communicate and interact with the target hardware device based on the mapped storage address space.
[0031] It can be seen that in an embodiment of the present application, a host-based bus hardware device direct access method is provided. When using a power strip to access a large number of bus hardware devices such as USB devices, there is no need to use the network communication form of the power strip assistant software to manage the bus hardware devices. The bus hardware devices can directly interact with the virtual machine in the target container through the host hardware serial port. For example, a batch of USB devices can directly interact with the Windows virtual machine in the target container through the host hardware serial port, reducing the data transmission link and improving the data interaction efficiency, effectively improving the interaction stability of the USB device; in addition, the embodiment of the present application adopts the container method, which is first mounted on the container, and also has the advantages of being lightweight and convenient, which can save resources and achieve direct access based on the container. It is also convenient for the subsequent use of the cloud native technology stack to conveniently manage services, and the application scenarios and scalability are stronger.
[0032] It should be noted that after the virtualization management device maps the storage address space of the target hardware device to the storage address space of the virtual machine, the virtual machine can achieve the purpose of communicating and interacting with the target hardware device based on the mapped storage address space. Among them, the embodiments of the present application provide at least two implementation methods, which are described below respectively.
[0033] In one embodiment, in the above step S50, that is, the virtual machine communicates and interacts with the target hardware device based on the mapped storage address space, including: S51A: The virtual machine directly accesses the mapped storage address space to achieve communication interaction with the target hardware device.
[0034] In this embodiment, as one of the implementation methods, the virtualization management device maps the storage address space of the target hardware device to the storage address space of the virtual machine to obtain a mapped storage address space. After mapping, operations on the storage address space of the virtual machine will be mapped back to the storage address space of the target hardware device, so that the virtual machine can communicate and interact with the target hardware device based on the mapped storage address space. Specifically, the virtual machine directly accesses the mapped storage address space to achieve communication and interaction with the target hardware device. Since there is a mapping relationship between the storage address spaces of the two, the virtual machine can directly access the mapped storage address space to access the target hardware device, including access operations such as reading / writing data of the target hardware device, which are not specifically limited.
[0035] In this embodiment, a direct access scenario is provided in which a virtual machine of a target container in a host machine is directly connected to a target hardware device, which is simple and fast.
[0036] In one embodiment, in the above step S50, that is, the virtual machine communicates and interacts with the target hardware device based on the mapped storage address space, including: S51B: when the virtual machine initiates a device access request for the target hardware device, the memory management unit of the host machine maps the mapped storage address space of the host machine to the virtual memory address corresponding to the device access request; S52B: The virtual machine accesses the virtual memory address to achieve communication interaction with the target hardware device.
[0037] In this embodiment, as one of the implementation methods, the virtualization management device maps the storage address space of the target hardware device to the storage address space of the virtual machine to obtain a mapped storage address space. After mapping, the operation on the storage address space of the virtual machine will be mapped back to the storage address space of the target hardware device, so that the virtual machine can communicate and interact with the target hardware device based on the mapped storage address space. Specifically, the virtual machine does not directly access the mapped storage address space as in the previous embodiment, but the virtual machine first issues a device access request for the target hardware device, that is, the virtual machine issues an access request for accessing the target hardware device. When the virtual machine initiates a device access request for the target hardware device, the memory management unit (Input / Output Memory Management Unit, abbreviated as: IOMMU) of the host machine will create a corresponding virtual memory address in response to the device access request triggered by the virtual machine. The virtual memory address corresponds to the real memory address of the virtual machine divided by the host machine, and then the mapped storage address space of the host machine is mapped to the virtual memory address corresponding to the device access request, so that the virtual machine accesses the virtual memory address to achieve communication and interaction with the target hardware device.
[0038] It should be understood that the IOMMU unit is a unit module in the host machine for managing computer memory, which allows physical memory to be mapped to a virtual address space. The IOMMU unit manages and optimizes memory access by using dedicated hardware, thereby improving system performance and stability. The IOMMU unit divides the physical memory of the host machine into multiple areas, each of which has a unique ID. These physical memory areas can be continuous or discontinuous. In this embodiment, when the target hardware device needs to access a certain physical memory area, the IOMMU will convert the request into a virtual memory address, and then map this virtual memory address to the corresponding physical memory address. In this way, the IOMMU unit is a direct memory access, that is, the target hardware device communicates directly with the host machine's memory without going through the host machine's CPU.
[0039] Since there is a mapping relationship between the virtual memory addresses, real memory addresses and the storage address space of the target hardware device, the virtual machine can access the virtual memory address to achieve communication interaction with the target hardware device, including the virtual machine's access operations such as reading / writing data on the target hardware device, without specific limitation.
[0040] It can be seen that in this embodiment, another direct pass-through scenario is provided by the participation of the IOMMU unit in the host machine. On the one hand, the host machine CPU can be avoided from being involved, further reducing the data interaction in the host machine; on the other hand, since the mapping relationship of the virtual memory address is set, it is possible to effectively avoid or reduce the connected target hardware devices from directly accessing the host machine, and reduce the direct access of the target hardware devices with infringing or malicious behaviors to the host machine memory, causing damage to the client running on the virtual machine or causing access to any memory beyond the address space range.
[0041] Through the above embodiment, the virtual machine can operate the USB device like a local device.
[0042] It should be noted that, in the above embodiment, after the bus hardware device is successfully mounted to the target container, the virtualization management device selects a specific target hardware device from the mounted multiple bus hardware devices. In one embodiment, a selection method is provided, that is, step S20, wherein the target hardware device is selected, including: S21: the virtualization management device reads a device configuration file mounted on the virtual machine, wherein the device configuration file is mounted to the virtual machine when the target container is started; S22: The virtualization management apparatus selects the target hardware device from the bus hardware devices successfully mounted on the target container based on the device configuration file.
[0043] In this embodiment, when the target container is started, the target container will run an initialization script, which will start the virtual machine deployed in the target container and set the specified bus hardware device information in a device configuration file, such as a device configuration file in the form of an XML file, so that the XML file can be mounted to the virtual machine of the target container for use, that is, the device configuration file is mounted to the virtual machine when the target container is started. The logic used by the initialization script to specify the bus hardware device can be determined by the upper-level processing logic. For example, unified control is performed when creating the target container, so that the parameters passed by each target container determine the hardware bus device to be mounted to the virtual machine. For example, the USB device to be mounted is determined by the device configuration file configuration, thereby completing the purpose of specifying the USB device.
[0044] For the virtualization management device, it can read the device configuration file (such as the configuration XML file) mounted on the virtual machine. Since the device configuration file specifies the target hardware device, the virtualization management device can select the target hardware device from the bus hardware devices successfully mounted on the target container based on the device configuration file. For example, the target USB device is selected from multiple USB devices that are connected. In other words, once the USB device is selected, the virtualization management device can create a virtual USB controller to map the physical USB device to the virtual machine, so as to transfer the control of the USB device from the host operating system to the virtual machine in the target container, so that the virtual machine can access the USB device.
[0045] It can be seen that in this embodiment, the device configuration file can be configured when the host creates the target container for unified management, so that the parameters passed by the target container determine the hardware bus device of the virtual machine to be mounted on the target container, which is convenient for unified management of the direct USB device. Of course, in other embodiments, the selection can also be made randomly or by user selection, which is not specifically limited.
[0046] It can be seen that in the direct pass solution provided in the present application, an innovative processing mechanism for bus hardware devices to directly pass through the virtual machine in the container is proposed. Based on the above processing mechanism, compared with the traditional method, there can be new breakthroughs and changes in the application scenarios, including but not limited to, for example, the crawler tool in the target container can be combined to provide corresponding automation services for the client software (client software) based on a specific system virtual machine (such as a Windows virtual machine).
[0047] In one embodiment, the virtual machine includes a first operating system virtual machine, the first operating system virtual machine runs client software and automation tools, on this basis, in step S50, that is, the client software runs on the virtual machine, the virtual machine communicates and interacts with the target hardware device based on the mapped storage address space, and further includes: S51C: The virtual machine implements an automated operation process for the client software based on an automated tool, wherein, during the execution of the automated operation process, the virtual machine communicates and interacts with the target hardware device based on the mapped storage address space.
[0048] As an explanation, exemplarily, the first operating system is a Windows system, and accordingly, the virtual machine is a Windows virtual machine, and the target container can be a Windows container, or other situations are not specifically limited. Taking this as an example, the benefits of this processing mechanism are explained.
[0049] For example, for some traditional client software, such as banking software, due to the slow update iteration of banking software and the backward infrastructure of banking software, the operation of such client software can only support traditional single operating systems (such as Windows systems) and cannot support more other systems (such as Linux systems). Therefore, it is impossible to use the conventional Linux container environment to deploy and run these banking software. However, for some automation tools, such as RPA automation tools (Robotic Process Automation), RPA automation tools are tools that use software robots to simulate humans to perform repetitive tasks on computers. Since automation tools need to simulate some processes of client software operations, they need to run on the system environment of client software and cannot be separated from it. This will lead to the following problems: a. Since the automation tools and client software are deployed on a Windows system, the automation tools and client software rely on the same configuration and environment variables, and the mutual influence may lead to the inability to execute in parallel; since the client software and automation tools are on a Windows system, only one process service can be run, which will cause the automation tools to be executed serially and cannot maximize the use of service resources.
[0050] To this end, it is necessary to build a Windows container based on the Windows system, and run the client software and automation tools in the Windows virtual machine in the Windows container to achieve environmental isolation and task parallel processing, and maximize the use of resources. The RPA automation tool needs to read the key information in the USB device to simulate the bank software login process and other processes. This involves the USB device direct pass-through solution based on the Windows container mentioned in the embodiment of this application, which allows the USB device to be mounted from the host machine to the Windows container, and then the USB device of the Windows container is mounted to the Windows virtual machine, and finally the RPA automation tool can directly operate the USB device on the host machine.
[0051] Therefore, by implementing the processing mechanism provided in the embodiment of the present application, some software processing tasks that are strongly dependent on the Windows system can be solved, so that with the help of the USB device direct pass of the Windows container, while retaining the original environment (Windows system; Windows client, such as banking software; Windows processing software, such as RPA automation tools, etc.), container technology can be used to unify the orchestration of services and improve resource utilization, thereby achieving technical unification of the overall architecture; thereby effectively reducing or avoiding the situation where the Windows environment is deployed with a virtual machine and the Linux environment is deployed with a container, so as to reduce operation and maintenance costs, and at the same time improve resource utilization.
[0052] It should be noted that the above-mentioned scenario of implementing the automated process service is only an exemplary description. For other similar scenarios, the embodiments of the present application are also applicable. No specific examples will be given for explanation. For example, if the automated service is replaced with other tools that rely on the Windows system, the above-mentioned problems still exist, and the mechanism of the embodiments of the present application can also be solved.
[0053] In one embodiment, before step S10, that is, before the virtualization management device mounts the bus hardware device connected to the host machine to the target container, the method further includes: S101: The virtualization management device creates a container to be orchestrated in the host machine, creates multiple service pools, and determines the client software type corresponding to each service pool; S102: The virtualization management device establishes a correspondence between each container and a service pool, wherein containers in the same service pool match the client software type corresponding to the service pool; S103: The virtualization management device starts containers of different service pools in parallel using different threads based on the correspondence between each container and the service pool; S104: The virtualization management device selects the target container from the started containers according to the type of client software on the virtual machine.
[0054] It should be noted that before the virtualization management device mounts the bus hardware device connected to the host machine to the target container, the embodiment of the present application can also realize the effective orchestration and management of the container deployed on the host machine to improve the management effectiveness. Specifically, the virtualization management device creates a container to be orchestrated in the host machine, and creates multiple service pools, determines the client software type corresponding to each service pool; establishes a correspondence between each container and the service pool, wherein the container of the same service pool matches the client software type corresponding to the service pool, such as bank software with an older version, slow update iteration, or video software with a faster update iteration and a newer version; different client software types correspond to corresponding service pools; the virtualization management device then starts the containers of different service pools in parallel with different threads based on the correspondence between each container and the service pool, and selects the target container from the started container in a matching manner according to the client software type on the virtual machine.
[0055] In this embodiment, since the containers of the same service pool match the client software type corresponding to the service pool and are started in parallel with different threads, the same type of client software can be started in different threads respectively; and containers of multiple different types of service pools can be started at the same time; and the selected target container is also selected from the container corresponding to the corresponding service pool based on the client software type currently running on the virtual machine, which is conducive to separate and unified management of the operation of different client software types, and can effectively unify the orchestration of the operation of the container, facilitate management, maintenance and expansion, and improve the efficiency of container management.
[0056] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0057] The above-mentioned embodiment introduces a bus hardware device pass-through method based on a host machine provided by the present application. Correspondingly, the embodiment of the present application also provides a host machine, and its function or role is described below from the perspective of the host machine.
[0058] In one embodiment, if Figure 1 The embodiment of the present application further provides a host machine, wherein the host machine is deployed with a target container, and the target container runs a virtual machine and a virtualization management device, wherein: The virtualization management device mounts the bus hardware device connected to the host machine to the target container; The virtualization management device identifies the bus hardware device successfully mounted on the target container and selects the target hardware device; The virtualization management device mounts the target hardware device to the virtual machine; The virtualization management device maps the storage address space of the target hardware device to the storage address space of the virtual machine to obtain a mapped storage address space; The virtual machine communicates and interacts with the target hardware device based on the mapped storage address space.
[0059] In combination with the above-mentioned host machine embodiment, in one embodiment, the virtual machine communicates and interacts with the target hardware device based on the mapped storage address space, including: The virtual machine directly accesses the mapped storage address space to achieve communication interaction with the target hardware device.
[0060] In combination with the above-mentioned host machine embodiment, in one embodiment, the virtual machine communicates and interacts with the target hardware device based on the mapped storage address space, including: When the virtual machine initiates a device access request for the target hardware device, the memory management unit of the host machine maps the mapped storage address space of the host machine to the virtual memory address corresponding to the device access request; The virtual machine accesses the virtual memory address to achieve communication interaction with the target hardware device.
[0061] In combination with the above-mentioned host machine embodiment, in one embodiment, the step of selecting a target hardware device includes: The virtualization management device reads a device configuration file mounted on the virtual machine, wherein the device configuration file is mounted to the virtual machine when the target container is started; The virtualization management device selects the target hardware device from the bus hardware devices successfully mounted on the target container based on the device configuration file.
[0062] In combination with the above-mentioned embodiment of the host machine, in one embodiment, the device type of the bus hardware device includes a serial port bus device.
[0063] In combination with the above-mentioned embodiment of the host machine, in one embodiment, the virtual machine includes a first operating system virtual machine, the first operating system virtual machine runs client software and an automation tool, and the virtual machine communicates and interacts with the target hardware device based on the mapped storage address space, including: The first operating system virtual machine implements an automated operation process for the client software based on the automation tool, wherein, during the execution of the automated operation process, communication and interaction are performed with the target hardware device based on the mapped storage address space.
[0064] In this embodiment, the host machine can solve some software processing tasks that are strongly dependent on a specific system (such as a Windows system) by implementing the processing mechanism provided in the embodiment of the present application, so that it can make use of the USB device pass-through of the Windows container. On the premise of retaining the original environment (Windows system; Windows client, such as banking software; Windows processing software, such as RPA automation tools, etc.), it can use container technology to unify the orchestration of services and improve resource utilization, thereby achieving technical unification of the overall architecture; otherwise, it will lead to the situation where the Windows environment is deployed with a virtual machine and the Linux environment is deployed with a container, with extremely high operation and maintenance costs and low resource utilization.
[0065] In combination with the above-mentioned embodiment of the host machine, in one embodiment, before the virtualization management device mounts the bus hardware device connected to the host machine to the target container, the method further includes: The virtualization management device creates a container to be orchestrated in the host machine, creates multiple service pools, and determines the client software type corresponding to each service pool; The virtualization management device establishes a correspondence between each container and a service pool, wherein containers in the same service pool match the client software type corresponding to the service pool; The virtualization management device starts containers of different service pools in parallel using different threads based on the correspondence between each container and the service pool; The virtualization management device selects the target container from the started containers according to the type of client software on the virtual machine.
[0066] It can be seen that in an embodiment of the present application, a host machine is provided. When a power strip is used to connect a large number of bus hardware devices such as USB devices, there is no need to use the network communication form of the power strip assistant software to manage the bus hardware devices. The bus hardware devices can directly exchange data with the virtual machine in the target container through the host machine hardware serial port. For example, a batch of USB devices can directly exchange data with the Windows virtual machine in the target container through the host machine hardware serial port, reducing the data transmission link and improving the data interaction efficiency, effectively improving the interaction stability of the USB device; in addition, the embodiment of the present application adopts the container method, which is first mounted on the container, and also has the advantages of being lightweight and convenient, which can save resources, achieve direct connection based on the container, and facilitate the subsequent use of the cloud native technology stack to conveniently manage services, and has stronger application scenarios and scalability.
[0067] It should be noted that, regarding the specific limitations of the host machine in this embodiment and the technical effects brought about, please refer to the above definition of a bus hardware device pass-through method based on the host machine, which will not be repeated here.
[0068] In one embodiment, a virtualization management device is provided, which corresponds one-to-one to the virtualization management device in the host-based bus hardware device direct pass method in the above embodiment, such as Figure 3 In one embodiment, the virtualization management device includes a first mounting module 101, an identification module 102, a second mounting module 103 and a mapping module 104, wherein: A first mounting module 101 is used to mount the bus hardware device connected to the host machine to the target container; An identification module 102, used to identify the bus hardware device successfully mounted on the target container and select the target hardware device; A second mounting module 103, used to mount the target hardware device to the virtual machine; The mapping module 104 maps the storage address space of the target hardware device to the storage address space of the virtual machine to obtain a mapped storage address space, so that the virtual machine can communicate and interact with the target hardware device based on the mapped storage address space.
[0069] For the specific definition of the virtualization management device, please refer to the definition of the virtualization management device in the above-mentioned method for passing through a bus hardware device based on a host machine, which will not be repeated here. Each of the above modules can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0070] In one embodiment, a host machine is provided. The host machine is a computer device on which a container can be deployed, such as a server, etc., and its internal structure diagram can be as follows: Figure 4 As shown. The host machine includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the host machine is used to provide computing and control capabilities. The memory of the host machine includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the host machine is used to communicate with an external bus hardware device through an interface connection. When the computer program is executed by the processor, a direct pass method for a bus hardware device based on the host machine is implemented.
[0071] In one embodiment, a host machine is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, a bus hardware device direct access method based on the host machine in the above embodiment is implemented.
[0072] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method for passing through a bus hardware device based on a host machine in the above embodiment is implemented. To avoid repetition, it is not described here.
[0073] It should be noted that, regarding the specific limitations of the host machine or computer-readable storage medium in this embodiment and the technical effects brought about, please refer to the relevant limitations in the above-mentioned method for passing through a bus hardware device based on a host machine. To avoid repetition, they will not be repeated here.
[0074] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0075] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0076] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A host-based bus hardware device direct access method, characterized in that: The host machine is deployed with a target container, the target container runs a virtual machine and a virtualization management device, and the method includes: The virtualization management device mounts the bus hardware device connected to the host machine to the target container; The virtualization management device identifies the bus hardware device successfully mounted on the target container and selects the target hardware device; The virtualization management device mounts the target hardware device to the virtual machine; The virtualization management device maps the storage address space of the target hardware device to the storage address space of the virtual machine to obtain a mapped storage address space; The virtual machine communicates and interacts with the target hardware device based on the mapped storage address space.
2. The bus hardware device direct access method according to claim 1, characterized in that: The virtual machine communicates and interacts with the target hardware device based on the mapped storage address space, including: The virtual machine directly accesses the mapped storage address space to achieve communication interaction with the target hardware device.
3. The bus hardware device direct access method according to claim 1, characterized in that: The virtual machine communicates and interacts with the target hardware device based on the mapped storage address space, including: When the virtual machine initiates a device access request for the target hardware device, the memory management unit of the host machine maps the mapped storage address space of the host machine to the virtual memory address corresponding to the device access request; The virtual machine accesses the virtual memory address to achieve communication interaction with the target hardware device.
4. The bus hardware device direct access method according to claim 1, characterized in that: The step of selecting a target hardware device includes: The virtualization management device reads a device configuration file mounted on the virtual machine, wherein the device configuration file is mounted to the virtual machine when the target container is started; The virtualization management device selects the target hardware device from the bus hardware devices successfully mounted on the target container based on the device configuration file.
5. The bus hardware device direct access method according to claim 1, characterized in that: The device type of the bus hardware device includes a serial bus device.
6. The bus hardware device direct access method according to claim 1, characterized in that: The virtual machine includes a first operating system virtual machine, the first operating system virtual machine runs client software and an automation tool, and the virtual machine communicates and interacts with the target hardware device based on the mapped storage address space, including: The first operating system virtual machine implements an automated operation process for the client software based on the automation tool, wherein, during the execution of the automated operation process, communication and interaction are performed with the target hardware device based on the mapped storage address space.
7. The bus hardware device direct access method according to any one of claims 1 to 6, characterized in that: Before the virtualization management device mounts the bus hardware device connected to the host machine to the target container, the method further includes: The virtualization management device creates a container to be orchestrated in the host machine, creates multiple service pools, and determines the client software type corresponding to each service pool; The virtualization management device establishes a correspondence between each container and a service pool, wherein containers in the same service pool match the client software type corresponding to the service pool; The virtualization management device starts containers of different service pools in parallel using different threads based on the correspondence between each container and the service pool; The virtualization management device selects the target container from the started containers according to the type of client software on the virtual machine.
8. A host machine, characterized in that: The host machine is deployed with a target container, and the target container runs a virtual machine and a virtualization management device, wherein: The virtualization management device mounts the bus hardware device connected to the host machine to the target container; The virtualization management device identifies the bus hardware device successfully mounted on the target container and selects the target hardware device; The virtualization management device mounts the target hardware device to the virtual machine; The virtualization management device maps the storage address space of the target hardware device to the storage address space of the virtual machine to obtain a mapped storage address space; The virtual machine communicates and interacts with the target hardware device based on the mapped storage address space.
9. A host computer, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the bus hardware device direct pass method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the bus hardware device direct pass method according to any one of claims 1 to 7 is implemented.