Hardware device configuration method and related device

By using the virtio protocol and format conversion module, the driver format of hardware devices is converted to a format supported by the virtio front-end driver, which solves the problem of complex configuration of non-general-purpose hardware devices in virtualization environments and achieves the effects of rapid configuration and cost reduction.

WO2026124193A1PCT designated stage Publication Date: 2026-06-18HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
Filing Date
2025-11-25
Publication Date
2026-06-18

AI Technical Summary

Technical Problem

In virtualized environments, non-general-purpose hardware devices such as cryptographic cards or accelerator cards are difficult to configure quickly. Existing technologies require the installation of drivers in the Guest OS, resulting in complex configuration and high costs.

Method used

By using the virtio protocol and format conversion module, the driver format of the hardware device is converted to a format supported by the virtio front-end driver. The virtio front-end driver is then used to configure the hardware device, avoiding the need to install additional drivers in the Guest OS.

🎯Benefits of technology

It enables rapid configuration of hardware devices, improves the compatibility of Guest OS, reduces the configuration cost of non-standard hardware devices, and enhances configuration efficiency and compatibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025137303_18062026_PF_FP_ABST
    Figure CN2025137303_18062026_PF_FP_ABST
Patent Text Reader

Abstract

The present application provides a hardware device configuration method and a related device applied to the technical field of cloud computing. In the method, a format conversion module in a virtual machine converts a channel creation instruction in a first format into a channel creation instruction in a second format, and sends the channel creation instruction in the second format to a virtio front-end driver. The first format is a format capable of being processed by a hardware device. The second format is a format capable of being processed by a virtio device, and is an instruction format specified in a virtio protocol. The virtio front-end driver sends the channel creation instruction in the second format to a hardware device driver. The hardware device driver converts the channel creation instruction from the second format to the first format, calls the hardware device on the basis of the converted channel creation instruction, and creates a control channel. By means of conversion between the first format and the second format, the standardized virtio front-end driver is used to drive the hardware device, and there is no need to additionally install a driver for the hardware device in a Guest OS, thereby increasing the speed of configuring the hardware device.
Need to check novelty before this filing date? Find Prior Art

Description

A configuration method for a hardware device and related equipment

[0001] This application claims priority to Chinese Patent Application No. 2024118257201, filed on December 10, 2024, entitled "A Configuration Method and Related Equipment for a Hardware Device", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of cloud computing technology, and in particular to a hardware device configuration method and related equipment. Background Technology

[0003] Virtualization technology refers to a resource management technique that logically abstracts various physical resources of a computer, presenting them as different virtual resources. Using virtualization technology, the inseparable nature of physical structures can be broken down, virtualizing a physical computer system into one or more virtual machines (VMs). A virtual machine is simply called a virtual machine. The physical computer system that creates the virtual machine is called the host. Based on the physical resources provided by the host, each VM has callable hardware devices and can run an independent operating system (OS) and applications.

[0004] After the hardware devices are configured on the physical server, the physical hardware device drivers need to be installed on the host machine and also on the virtual machine's operating system (Guest OS) to achieve compatibility between the virtual machine and the hardware devices, enabling the virtual machine to call the hardware devices normally. However, there are many types of Guest OS drivers for hardware devices, and the process of configuring hardware devices is quite complex, making it difficult to achieve rapid configuration of hardware devices. Summary of the Invention

[0005] In view of this, this application provides a hardware device configuration method and related equipment, which can eliminate the need to install hardware device drivers in the Guest OS based on the virtio protocol, and realize the rapid configuration of hardware devices in virtual machines.

[0006] Firstly, this application provides a method for configuring a hardware device, which is applied to a host machine connected to the hardware device. A virtual machine is created on the host machine. Both the host machine and the virtual machine support the virtio virtual input / output protocol. The virtual machine has a virtio front-end driver installed. The virtio front-end driver is used to invoke the virtio device mounted on the virtual machine. The virtio device is a virtual device used to simulate a hardware device. The virtual machine includes a format conversion module. The host machine installs the hardware device driver for the hardware device. In the configuration method, the format conversion module obtains a channel creation instruction in a first format. The first format is a format supported by the hardware device. The format conversion module performs format conversion on the first format channel creation instruction, converting it into a second format channel creation instruction. The second format is a format supported by the virtio front-end driver. The format conversion module sends the converted second format channel creation instruction to the virtio front-end driver. The virtio front-end driver obtains the second format channel creation instruction and sends it to the hardware device driver. The hardware device driver has a format conversion function. The hardware device driver performs format conversion on the second-format channel creation command, transforming it into a first-format channel creation command. Based on the first-format channel creation command, the hardware device driver creates a control channel with the virtio front-end driver. The conversion between the first and second formats is achieved through the format conversion module and the hardware device driver's format conversion function. This allows the second-format channel creation command to enable interaction between the virtio front-end driver and the hardware device driver, thereby utilizing a standardized virtio front-end driver to drive the hardware device. This eliminates the need to install separate hardware device drivers on the Guest OS, improving hardware configuration speed, enhancing Guest OS compatibility, and further reducing the cost of driving non-standardized hardware devices.

[0007] In one possible implementation, the hardware device driver creates a data channel between itself and the virtio frontend driver based on channel creation instructions. The mode of the data channel is determined according to the type of hardware device. For example, if the hardware device supports direct communication with the virtual machine, the data channel uses a pass-through mode. As another example, if the hardware device does not support direct communication with the virtual machine, the data channel uses a forwarding mode. This allows for the flexible creation of data channels with corresponding modes suitable for the hardware device type, facilitating interaction between the hardware device driver and the virtio frontend driver, and ultimately enabling applications running in the virtual machine to access the hardware device.

[0008] In one possible implementation, an application running on a virtual machine generates data packets containing business data. A format conversion module encapsulates the data packets into a first message in a second format. The format conversion module sends the first message in the second format to the virtio frontend driver. The virtio frontend driver sends the first message in the second format to the hardware device driver via a data channel. The hardware device driver receives the first message in the second format, performs format conversion on it, and converts the first message in the second format into a first message in the first format. The hardware device is capable of processing the first message in the first format. The hardware device driver invokes the hardware device to process the first message in the first format, generating a second message in the first format. The second message includes the processing result data generated by the hardware device processing the business data included in the first message. By converting the message format, the hardware device can be invoked to process business data, realizing hardware device invocation based on the standardized virtio protocol, reducing the cost of driving non-standardized hardware devices.

[0009] In one possible implementation, the hardware device driver performs format conversion on the second message in the first format, transforming it into a second message in a second format. The hardware device driver then sends the second message in the second format to the virtio front-end driver via a data channel. The virtio front-end driver obtains the second message in the second format and sends it to the format conversion module. The format conversion module decapsulates the second message in the second format to obtain the processing result data contained within it. The format conversion module then sends the processing result data to the application. In this way, the application can obtain the processing result data obtained from calling the hardware device to process business data, realizing the calling of the hardware device to process business data based on the standardized virtio protocol, without the need for additional hardware device driver configuration in the Guest OS, thus reducing the cost of configuring the hardware device.

[0010] In one possible implementation, the hardware device is a cryptographic card or an accelerator card. The virtio device is a virtual network interface card (NIC) device.

[0011] Secondly, this application provides a hardware device configuration apparatus. The apparatus is deployed on a host machine connected to the hardware device. A virtual machine is created on the host machine. The host machine and the virtual machine support the virtual input / output (virtio) protocol. The virtual machine installs a virtio front-end driver. The virtio front-end driver is used to call the virtio device mounted on the virtual machine. The virtio device is used to simulate the hardware device. The apparatus includes a format conversion module and a hardware device driver for the hardware device. The format conversion module is deployed on the virtual machine, and the hardware device driver is deployed on the host machine.

[0012] The format conversion module is used to obtain a channel creation instruction in a first format, wherein the first format is a format that the hardware device supports processing.

[0013] The format conversion module is used to convert the format of the channel creation instruction in the first format from the first format to the second format that the virtio front-end driver supports processing, and send the channel creation instruction in the second format to the virtio front-end driver.

[0014] The virtio front-end driver is used to obtain the channel creation instruction in the second format and send the channel creation instruction in the second format to the hardware device driver;

[0015] The hardware device driver is used to convert the format of the channel creation instruction in the second format from the second format to the first format;

[0016] The hardware device driver is used to create a control channel with the virtio front-end driver according to the channel creation instruction of the first format.

[0017] In one possible implementation, the hardware device supports direct communication with the virtual machine, and the hardware device driver is also used to create a pass-through data channel with the virtio frontend driver.

[0018] or,

[0019] The hardware device does not support direct communication with the virtual machine. The hardware device driver is also used to create a forwarding mode data channel with the virtio frontend driver.

[0020] In one possible implementation, the format conversion module is further configured to encapsulate the data packet into a first message in a second format, call the virtio front-end driver, and send the first message in the second format to the hardware device driver through the data channel. The data packet is generated by an application running on the virtual machine and includes business data.

[0021] The hardware device driver is also used to acquire the first message in the second format and convert the format of the first message in the second format from the second format to the first format;

[0022] The hardware device driver is also used to call the hardware device to process the first message of the first format and generate a second message of the first format. The second message includes processing result data, which is generated by the hardware device processing the business data.

[0023] In one possible implementation, the hardware device driver is further configured to convert the format of the second message in the first format to the second format, and send the second message in the second format to the virtio front-end driver through the data channel;

[0024] The format conversion module is further configured to obtain the second message in the second format sent by the virtio front-end driver, deseal the second message in the second format to obtain the processing result data, and send the processing result data to the application.

[0025] In one possible implementation, the hardware device is a cryptographic card or an accelerator card, and the virtio device is a virtual network interface card (NIC) device.

[0026] Thirdly, this application provides a computing device, which includes a processor and a memory. The memory stores instructions, and when the computing device is running, the processor executes the instructions stored in the memory to cause the computing device to perform the operation steps of the method described in the first aspect or any possible implementation thereof. It should be noted that the memory can be integrated into the processor or can be independent of the processor. Each computing device may also include a bus. The processor is connected to the memory via the bus. The memory may include readable storage and random access memory.

[0027] Fourthly, this application provides a computing device cluster, which includes at least one computing device, each computing device including a processor and a memory. The memory is used to store instructions. When the computing device cluster is running, the processor in each computing device executes the instructions stored in the memory to cause the computing device cluster to perform the operation steps of the method in the first aspect or any possible implementation of the first aspect. It should be noted that the memory can be integrated into the processor or can be independent of the processor. Each computing device may also include a bus. The processor is connected to the memory via the bus. The memory may include readable storage memory and random access memory.

[0028] Fifthly, this application provides a computer-readable storage medium storing instructions that, when run on a computing device cluster (which includes at least one computing device), cause the computing device cluster to perform the operational steps of the method described in the first aspect or any implementation thereof.

[0029] In a sixth aspect, this application provides a computer program product containing instructions that, when run on a computing device cluster (which includes at least one computing device), causes the computing device cluster to perform the operational steps of the method described in the first aspect or any implementation thereof.

[0030] Based on the implementation methods provided in the above aspects, this application can be further combined to provide more implementation methods. Attached Figure Description

[0031] Figure 1 is a schematic diagram of a system architecture provided in an embodiment of this application;

[0032] Figure 2 is a flowchart illustrating a hardware device configuration method provided in an embodiment of this application;

[0033] Figure 3 is a schematic diagram of a process for calling a hardware device to process business data according to an embodiment of this application;

[0034] Figure 4 is a schematic diagram of the configuration device of a hardware device provided in an embodiment of this application;

[0035] Figure 5 is a schematic diagram of the structure of a computing device provided in an embodiment of this application;

[0036] Figure 6 is a schematic diagram of the structure of a computing device cluster provided in an embodiment of this application;

[0037] Figure 7 is a schematic diagram of another computing device cluster provided in an embodiment of this application. Detailed Implementation

[0038] The embodiments of the present invention will now be described with reference to the accompanying drawings.

[0039] Furthermore, the terms "first" and "second" in the embodiments of this application are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined with "first" and "second" may explicitly or implicitly include one or more of that feature.

[0040] In this application embodiment, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.

[0041] Any embodiment or design described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.

[0042] To help those skilled in the art better understand the technical solutions of this application, some concepts involved in the embodiments of this application will be introduced first.

[0043] Virtualization technology is widely used in cloud computing scenarios. Virtualization virtualizes physical hardware resources such as computing, networking, and storage, and then dynamically allocates them on demand, improving resource utilization.

[0044] Virtualization technology can be mainly divided into full virtualization and paravirtualization.

[0045] Full virtualization, also known as hardware-assisted virtualization, refers to the complete simulation of the underlying hardware environment through software, making the virtual machine believe it is running directly on physical hardware without any modifications. For example, using the Quick Emulator (QEMU) to simulate a complete hardware device creates a virtual device. Virtual devices created by QEMU are standardized devices, and the guest OS supports their operation without requiring modifications. However, creating virtual devices using QEMU is inefficient, and simulating hardware devices is costly.

[0046] Paravirtualization, also known as operating system-assisted virtualization, works by modifying the guest operating system (SOS) to allow it to interact directly with the hypervisor, rather than directly emulating hardware devices. Specifically, dedicated interfaces are added to the guest operating system to optimize and generate instructions for interaction with the virtualization layer. Compared to full virtualization, paravirtualization reduces the cost of emulating hardware devices, but it has limitations in compatibility and security.

[0047] The Virtual Input / Output (Virtio) protocol is a paravirtualization technology. The Virtio protocol defines the initialization, communication, and notification processes for various devices and drivers. It defines the communication framework and programming interface between upper-layer applications and various hypervisor virtualization devices, enabling interaction between the virtual machine and the host machine, and resolving compatibility issues between various drivers and different virtualization solutions.

[0048] The Virtio framework, built on the Virtio protocol, primarily consists of four layers: Front-end Drivers, Back-end Devices, the Virtio Layer, and the Virtio-ring Layer. The Virtio-ring can be abbreviated as vring. The front-end drivers, running in the Guest OS, are responsible for receiving I / O requests from user space, encapsulating these requests according to the Virtio protocol, and then sending notifications to the QEMU back-end devices via I / O operations. The front-end drivers are the representation of Virtio devices in the virtual machine. The back-end devices, created in QEMU, receive I / O requests from the front-end drivers. The back-end devices parse the I / O requests, perform corresponding operations on the physical device, and then notify the front-end devices that the corresponding operations have been performed. The Virtio layer is a virtual queue interface that connects the front-end drivers to the back-end devices. The Virtio layer defines the communication protocol between the virtual devices and the host machine, including the device's functionality, configuration, and how data is transferred via virtqueue. The Virtio-ring layer is a concrete implementation of the Virtio layer, which uses virtqueue to handle data transfer. Virtqueue is an efficient data exchange mechanism that uses a ring buffer to store data descriptors that point to the actual data buffers. The Virtio-ring layer enables direct data transfer between the virtual machine and the host machine, reducing the overhead of data copying.

[0049] Virtio Data Path Acceleration (vDPA) is a virtualization technology. The core idea of ​​vDPA is to separate the virtual machine's data path from its control path, achieving semi-hardware virtualization. The data path refers to the actual data interaction operations, such as read and write operations. The control path refers to the configuration and management of input / output devices. The control path can be fully managed by software, while the data path is accelerated by hardware.

[0050] Vhost (Virtual Host) is a virtual host system in Linux. Vhost-vdpa is a virtualization technology that accelerates data transmission by hardware-enabling the virtual machine's data path. The core idea of ​​vhost-vdpa is to offload the data plane to hardware devices that support vDPA, thereby reducing host machine intervention and improving data transmission efficiency. The implementation of vhost-vdpa involves the use of the vhost user-space interface (vhost-user). vhost-vdpa allows virtual machines to communicate with the vhost service on the host machine via a socket.

[0051] Currently, virtualization technology is widely used in cloud computing scenarios to support the operation of virtual machines. The Virtio protocol mentioned above supports hardware devices with a relatively high degree of standardization. For some non-general-purpose hardware devices, such as cryptographic cards, graphics processing unit (GPU) cards, and vendor-customized hardware, the degree of standardization is lower, and it is still necessary to manually install the corresponding hardware device drivers in the Guest OS. However, there are many types of Guest OSes, and users can choose the appropriate OS type to install according to their needs. The variety of Guest OS types makes it difficult for non-general-purpose hardware devices to be quickly adapted to the Guest OS, and the configuration process for applications running in virtual machines to normally call non-general-purpose hardware devices is complex and costly.

[0052] In view of this, embodiments of this application provide a hardware device configuration method. This hardware device configuration method is applied to a host machine connected to the hardware device. A virtual machine is created on the host machine. Both the host machine and the virtual machine support the virtio protocol. The virtual machine installs a virtio front-end driver. The virtio device is used to emulate the hardware device. The host machine installs the hardware device driver. A format conversion module obtains a channel creation instruction in a first format. The first format is a format supported by the hardware device. The format conversion module converts the first format channel creation instruction into a second format channel creation instruction. The second format is a format supported by the virtio device and is the instruction format specified in the virtio protocol. The format conversion module sends the second format channel creation instruction to the virtio front-end driver. The virtio front-end driver obtains the channel creation instruction and sends the second format channel creation instruction to the hardware device driver. The hardware device driver converts the channel creation instruction from the second format back to the first format, and calls the hardware device according to the converted channel creation instruction to create a control channel. Through the conversion between the first and second formats, the interaction between the virtio front-end driver and the hardware device driver is achieved. This allows for the use of standardized virtio front-end drivers to drive hardware devices, eliminating the need to install separate hardware device drivers on the Guest OS. This improves the speed of hardware device configuration, enhances the compatibility of the Guest OS, and reduces the cost of driving non-standardized hardware devices.

[0053] In one possible application scenario, referring to Figure 1, which is a schematic diagram of a system architecture provided by an embodiment of this application, the host machine is connected to hardware devices. These hardware devices can be non-general-purpose and non-standardized devices, such as cryptographic cards, accelerator cards, vendor-customized hardware, and novel hardware devices. This application embodiment does not limit the type of host machine. For example, the host machine is a server in the infrastructure of a large-scale software platform such as a cloud platform, big data platform, or storage platform.

[0054] Hardware device drivers run in the host machine's kernel space. These drivers are used to operate hardware devices. The host machine's kernel space includes KVM (Kernel-based Virtual Machine). KVM is a virtualization module that provides support for hardware-assisted virtualization, primarily used for virtualizing the CPU and memory.

[0055] The QEMU process runs in the host machine's user space. Virtual machines are created based on the QEMU process. The QEMU process is used to create and manage the virtual machine's runtime environment, manage the virtual machine's lifecycle, handle hardware emulation and resource management, and provide an interface for interaction with the host operating system. Libvirt also runs in the host machine's user space. Libvirt is the interface for managing virtual machine tools and applications.

[0056] Both the host machine and the virtual machine support the virtio protocol. A virtio device is created on the host machine. The virtio device is used to emulate hardware devices. A virtio device includes a virtio front-end driver and a virtio back-end device.

[0057] Install the virtio driver in the Guest OS of the created virtual machine. The virtio driver allows the virtual machine's operating system to recognize and use the virtio device. For Linux systems, the virtio driver is included in the kernel. The virtio driver in the Guest OS can be called the virtio front-end driver. Create the virtio back-end device in the QEMU process.

[0058] Start the virtual machine and edit its configuration file to add the virtio device's information, thus mounting the virtio device to the virtual machine. The virtio device information includes, for example, the device type and its file path.

[0059] After mounting a virtio device on a virtual machine, a control channel and a data channel need to be created. The control channel is primarily used for configuration and initialization between the virtio frontend driver in the virtual machine and the virtio backend device in the host machine. Through the control channel, the virtio frontend driver can negotiate features with the virtio backend device, obtain hardware configuration information, and establish a data channel. The data channel is mainly responsible for data transmission. Data channels are typically implemented using virtqueues.

[0060] The virtual machine's user space runs applications and a format conversion module. The format conversion module is used to convert the format of instructions and messages sent to the virtio frontend driver. For example, a software development kit (SDK) can be used for this purpose.

[0061] The process of creating control channels and data channels is described below.

[0062] The virtual machine management tool invokes a channel creation command in the first format. This command instructs the establishment of control and data channels. The first format is the format supported by the hardware device. The format conversion module obtains the first-format channel creation command and converts it into a second-format command. The second format is the format of commands supported by the virtio device. The second format is defined in the virtio protocol. The format conversion module sends the second-format channel creation command to the virtio frontend driver. The virtio frontend driver obtains the second-format command and sends it to the hardware device driver. The hardware device driver converts the second-format command back to the first-format command. The hardware device driver processes the first-format command, invokes the hardware device, and completes the creation of the control channel. After the control channel is created, the data channel is created. The establishment of the data channel involves the creation and initialization of a vring. A vring is a virtqueue that enables sharing between the virtual machine and the host machine. The virtio frontend driver creates a vring and shares it with the QEMU process so that the virtio backend device can access and process data. Based on the created control channel, the vring can be initialized, completing the establishment of the data channel. Using the established data channel, hardware devices can be invoked, enabling them to process data from applications running in the virtual machine's user space.

[0063] This allows non-generic hardware devices to be simulated as virtio devices based on the virtio protocol, enabling the Guest OS to call these non-generic hardware devices using the virtio front-end driver. This eliminates the need to install specific drivers for the hardware devices in the Guest OS, reducing the difficulty and cost of configuring hardware devices, improving the compatibility of hardware devices and the host machine, and increasing the efficiency of hardware configuration.

[0064] It should be noted that the system architecture and application scenario shown in Figure 1 are only examples, and the configuration method of the hardware device provided in this application embodiment is not limited to the application scenario shown in Figure 1.

[0065] Next, various non-limiting specific implementations of the hardware device configuration method will be described in detail.

[0066] Referring to Figure 2, which is a flowchart illustrating a hardware device configuration method provided in an embodiment of this application, including steps S201-S204.

[0067] S201: The format conversion module obtains the channel creation instruction for the first format.

[0068] Channel creation instructions are used to create control and data channels between the virtio frontend driver and the hardware device driver. The first format is the format supported by the hardware device. Channel creation instructions in the first format can be generated from the virtual machine's management plane, such as the virtual machine's console.

[0069] The format conversion module is used to convert the format of channel creation instructions. This module can be implemented, for example, based on an SDK. It can be integrated into applications running in the user space of the virtual machine or serve as a standalone module. The format conversion module can convert channel creation instructions in a first format into a second format that the virtio frontend driver supports for processing. This allows the virtio frontend driver to handle the channel creation instructions, eliminating the need to install other types of drivers in the virtual machine. When calling hardware devices, the format conversion module can be invoked to process the instructions and messages generated by the application, achieving format conversion.

[0070] S202: The format conversion module converts the channel creation command from the first format to the second format that the virtio device can process, and sends the second format channel creation command to the virtio front-end driver.

[0071] The format conversion module converts the channel creation command in the first format into a channel creation command in the second format. As one possible implementation, the virtio device is a virtual network interface card (NIC) device. The second format is the format supported by the virtual NIC device. The second format can be determined based on the command format defined in the virtio protocol.

[0072] The format conversion module sends the converted second-format channel creation command to the virtio front-end driver so that the second-format channel creation command can be sent to the hardware device driver through the virtualization layer.

[0073] S203: The virtio front-end driver obtains the channel creation command and sends the second-format channel creation command to the hardware device driver.

[0074] In one possible implementation, the virtio frontend driver forwards the second-format channel creation command via vhost-vdpa, performing interface conversion. Then, through the device interface of the hardware device extended by vdpa-Framework, it sends the second-format channel creation command to the hardware device driver, thus invoking the hardware device driver.

[0075] S204: The hardware device driver converts the channel creation instruction from the second format to the first format, and calls the hardware device according to the converted channel creation instruction to create a control channel.

[0076] The hardware device driver translates the second-format channel creation command into a first-format channel creation command. Based on the first-format channel creation command, the hardware device driver invokes the hardware device to negotiate performance between the virtio front-end driver and the hardware device, thus completing the creation of the control channel.

[0077] S205: The hardware device driver creates a data channel between the hardware device driver and the virtio front-end driver.

[0078] This application does not limit the type of data channel. As an example, if the hardware device supports direct communication with the virtual machine, a passthrough mode data channel can be established. Such hardware devices are typically configured as Virtual Functions (VFs). The virtual machine can directly access the VF. As another example, if the hardware device does not support direct communication with the virtual machine, a forwarding mode data channel can be established. In forwarding mode, the virtio front-end driver writes data to the vring's memory, the virtio back-end device reads the data, and then the hardware device driver forwards it to the hardware device. The vring's memory can be shared between the virtual machine and the host machine.

[0079] Based on the above, it is clear that for non-general-purpose hardware devices, simulating them as virtio devices and performing instruction format conversion within the virtual machine and the hardware device driver, while utilizing the virtualization mechanism of the virtio protocol, eliminates the need to install special drivers for the hardware devices on the Guest OS. By using virtio front-end drivers to call hardware devices, the cost of hardware configuration can be reduced, the efficiency of hardware configuration can be improved, and the compatibility of hardware devices can be enhanced. This helps to expand the scope of hardware device use and facilitates the rapid promotion of hardware devices within the current virtualization software and hardware ecosystem.

[0080] Furthermore, by utilizing the virtio front-end driver, the drivers in the GuestOS can be decoupled from the hardware device drivers within the HostOS. When hardware device drivers within the HostOS need to be upgraded or updated, there is no need to upgrade or update the virtio front-end driver in conjunction with these changes, reducing the cost of hardware device driver upgrades and increasing the configuration speed of hardware device driver upgrades.

[0081] After the data channel is established, the application running on the virtual machine can call the hardware device to process business. Referring to Figure 3, this figure is a schematic diagram of a process for calling the hardware device to process business data according to an embodiment of this application, including steps S301-S306.

[0082] S301: The application generates a data packet.

[0083] The application runs in the user space of a virtual machine. During business processing, the application generates business data. The application packages this business data into a data packet. This data packet includes business data that requires processing by hardware devices.

[0084] S302: The format conversion module encapsulates the data packet into a first message in the second format, calls the virtio front-end driver, and sends the first message in the second format to the hardware device driver through the data channel.

[0085] The format conversion module acquires the data packets that need to be processed by the hardware device, encapsulates the data packets into a first message in a second format, and then sends it to the hardware device through the virtio frontend driver. The format conversion module sends the first message in the second format to the virtio frontend driver. The virtio frontend driver then sends the first message in the second format to the hardware device driver through the data channel.

[0086] S303: The hardware device driver converts the acquired second-format first message into a first-format first message.

[0087] The hardware device driver obtains the first message in the second format and converts it into a first message in the first format. The first message in the first format supports hardware device processing.

[0088] S304: The hardware device driver calls the hardware device to process the first message in the first format and obtains the second message in the first format.

[0089] The hardware device driver invokes the hardware device to process a first message in a first format, thereby processing the business data included in the first message. After processing the first message in the first format, the hardware device generates processing result data. The hardware device driver obtains the processing result data generated by the hardware device and encapsulates the processing result data to generate a second message in the first format.

[0090] S305: The hardware device driver converts the second message from the first format to the second format and sends the second message in the second format to the virtio front-end driver through the data channel.

[0091] The hardware device driver converts the second message in the first format to generate a second message in the second format, so that the second message in the second format can be sent to the virtio front-end driver through the data channel.

[0092] After obtaining the second message in the second format, the virtio frontend driver sends the second message in the second format to the format conversion module.

[0093] S306: The format conversion module obtains the second message in the second format sent by the virtio front-end driver, decapsulates the second message in the second format, obtains the result data, and sends the result data to the application.

[0094] The format conversion module decapsulates the second message in the second format to obtain the result data. The format conversion module then sends the result data to the application program, completing the processing of the business data.

[0095] Based on the relevant content of steps S301-S306 above, it can be seen that during the process of calling hardware devices to process business, data can be transmitted through the created data channel by format conversion, realizing the data transmission method between the virtual machine and the host machine defined by the virtio protocol.

[0096] This application also provides a hardware device configuration device deployed on a host machine connected to the hardware device. A virtual machine is created on the host machine. The host machine and the virtual machine support the virtio protocol. A virtio front-end driver is installed on the virtual machine. The virtio front-end driver is used to call the virtio device mounted on the virtual machine. The virtio device is used to emulate the hardware device. As shown in Figure 4, the hardware device configuration device 400 includes a format conversion module 401 and a hardware device driver 402. The format conversion module 401 is deployed on the virtual machine. The hardware device driver 402 is deployed on the host machine.

[0097] The format conversion module 401 is used to obtain a channel creation instruction of a first format, wherein the first format is a format that the hardware device supports processing.

[0098] The format conversion module 401 is used to convert the format of the channel creation instruction in the first format from the first format to the second format supported by the virtio front-end driver, and send the channel creation instruction in the second format to the virtio front-end driver.

[0099] The virtio front-end driver is used to obtain the channel creation instruction in the second format and send the channel creation instruction in the second format to the hardware device driver 402.

[0100] The hardware device driver 402 is used to convert the format of the channel creation instruction of the second format from the second format to the first format;

[0101] The hardware device driver 402 is used to create a control channel with the virtio front-end driver according to the channel creation instruction of the first format.

[0102] In one possible implementation, the hardware device supports direct communication with the virtual machine, and the hardware device driver 402 is also used to create a pass-through data channel with the virtio front-end driver.

[0103] or,

[0104] The hardware device does not support direct communication with the virtual machine. The hardware device driver 402 is also used to create a forwarding mode data channel with the virtio frontend driver.

[0105] In one possible implementation, the format conversion module 401 is further configured to encapsulate the data packet into a first message in a second format, call the virtio front-end driver, and send the first message in the second format to the hardware device driver 402 through the data channel. The data packet is generated by an application running on the virtual machine and includes business data.

[0106] The hardware device driver 402 is also used to acquire the first message in the second format and convert the format of the first message in the second format from the second format to the first format;

[0107] The hardware device driver 402 is further configured to call the hardware device to process the first message of the first format and generate a second message of the first format. The second message includes processing result data, which is generated by the hardware device processing the business data.

[0108] In one possible implementation, the hardware device driver 402 is further configured to convert the format of the second message in the first format to the second format, and send the second message in the second format to the virtio front-end driver through the data channel;

[0109] The format conversion module 401 is further configured to obtain the second message in the second format sent by the virtio front-end driver, deseal the second message in the second format to obtain the processing result data, and send the processing result data to the application.

[0110] In one possible implementation, the hardware device is a cryptographic card or an accelerator card, and the virtio device is a virtual network interface card (NIC) device.

[0111] Both the format conversion module 401 and the hardware device driver 402 can be implemented in software. For example, the implementation of the format conversion module 401 will be described below.

[0112] As an example of a software functional unit, the format conversion module 401 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, or a container. Further, the aforementioned computing instance may be one or more. For example, the format conversion module 401 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed within the same region or in different regions. Further, the multiple hosts / virtual machines / containers used to run the code may be distributed within the same availability zone (AZ) or in different AZs, each AZ including one or more geographically proximate data centers. Typically, a region may include multiple AZs.

[0113] Similarly, multiple hosts / virtual machines / containers used to run this code can be distributed within the same Virtual Private Cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Communication between two VPCs within the same region, as well as between VPCs in different regions, requires a communication gateway to be set up within each VPC to enable interconnection between VPCs.

[0114] This application also provides a computing device 500. As shown in FIG5, the computing device 500 includes: a bus 502, a processor 504, a memory 506, and a communication interface 508. The processor 504, the memory 506, and the communication interface 508 communicate with each other via the bus 502. The computing device 500 may be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in the computing device 500.

[0115] Bus 502 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, only one line is used in Figure 5, but this does not imply that there is only one bus or one type of bus. Bus 502 can include pathways for transmitting information between various components of computing device 500 (e.g., memory 506, processor 504, communication interface 508).

[0116] Processor 504 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0117] Memory 506 may include volatile memory, such as random access memory (RAM). Processor 504 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).

[0118] The memory 506 stores executable program code, which the processor 504 executes to implement the functions of the aforementioned format conversion module 401 and hardware device driver 402, thereby implementing the hardware device configuration method. In other words, the memory 506 stores instructions for executing the hardware device configuration method.

[0119] The communication interface 508 uses transceiver modules, such as, but not limited to, network interface cards and transceivers, to enable communication between the computing device 500 and other devices or communication networks.

[0120] This application also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.

[0121] As shown in Figure 6, the computing device cluster includes at least one computing device 500. The memory 506 of one or more computing devices 500 in the computing device cluster may store the same instructions for executing configuration methods for the hardware devices.

[0122] In some possible implementations, the memory 506 of one or more computing devices 500 in the computing device cluster may also store partial instructions for executing configuration methods for the hardware devices. In other words, a combination of one or more computing devices 500 can jointly execute instructions for executing configuration methods for the hardware devices.

[0123] It should be noted that the memory 506 in different computing devices 500 within the computing device cluster can store different instructions, each used to execute a portion of the functions of the hardware device configuration device. That is, the instructions stored in the memory 506 of different computing devices 500 can implement the functions of one or more modules in the format conversion module 401 and the hardware device driver 402.

[0124] In some possible implementations, one or more computing devices in a computing device cluster can be connected via a network. This network can be a wide area network (WAN) or a local area network (LAN), etc. Figure 7 illustrates one possible implementation. As shown in Figure 7, two computing devices 500A and 500B are connected via a network. Specifically, they are connected to the network through communication interfaces in each computing device. In this type of possible implementation, the memory 506 in computing device 500A stores instructions for executing the functions of the format conversion module 401. Simultaneously, the memory 506 in computing device 500B stores instructions for executing the functions of the hardware device driver 402.

[0125] The connection method between the computing device clusters shown in Figure 7 can be considered in terms of the configuration method of the hardware devices provided in this application, so the function implemented by the hardware device driver 402 is handed over to the computing device 500B for execution.

[0126] It should be understood that the functions of computing device 500A shown in Figure 7 can also be performed by multiple computing devices 500. Similarly, the functions of computing device 500B can also be performed by multiple computing devices 500.

[0127] This application also provides a computer program product containing instructions. The computer program product may be a software or program product containing instructions, capable of running on a computing device or stored on any usable medium. When the computer program product is run on at least one computing device, it causes the at least one computing device to perform a hardware device configuration method.

[0128] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that a computing device can store, or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to perform a hardware configuration method.

[0129] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for configuring a hardware device, characterized in that, The method is applied to a host machine connected to a hardware device. A virtual machine is created on the host machine. Both the host machine and the virtual machine support the virtio virtual input / output protocol. The virtual machine installs a virtio front-end driver, which is used to call the virtio device mounted on the virtual machine. The virtio device is used to emulate the hardware device. The virtual machine includes a format conversion module. The host machine installs the hardware device driver for the hardware device. The method includes: The format conversion module obtains a channel creation instruction in a first format, wherein the first format is a format that the hardware device supports processing. The format conversion module converts the channel creation instruction of the first format into a second format that is supported by the virtio front-end driver, and sends the channel creation instruction of the second format to the virtio front-end driver. The virtio front-end driver obtains the channel creation instruction in the second format and sends the channel creation instruction in the second format to the hardware device driver; The hardware device driver converts the format of the channel creation instruction in the second format from the second format to the first format; The hardware device driver creates a control channel with the virtio front-end driver according to the channel creation instruction of the first format.

2. The method according to claim 1, characterized in that, The method further includes: The hardware device supports direct communication with the virtual machine, and the hardware device driver creates a pass-through data channel with the virtio front-end driver. or, The hardware device does not support direct communication with the virtual machine, and the hardware device driver creates a forwarding mode data channel with the virtio frontend driver.

3. The method according to claim 2, characterized in that, The method further includes: An application running on the virtual machine generates a data packet, which includes business data. The format conversion module encapsulates the data packet into a first message in a second format, calls the virtio front-end driver, and sends the first message in the second format to the hardware device driver through the data channel. The hardware device driver obtains the first message in the second format and converts the format of the first message in the second format to the first format. The hardware device driver calls the hardware device to process the first message in the first format and generate a second message in the first format. The second message includes processing result data, which is generated by the hardware device processing the business data.

4. The method according to claim 3, characterized in that, After generating the second message in the first format, the method further includes: The hardware device driver converts the format of the second message in the first format to the second format, and sends the second message in the second format to the virtio front-end driver through the data channel; The format conversion module obtains the second message in the second format sent by the virtio front-end driver, decapsulates the second message in the second format to obtain the processing result data, and sends the processing result data to the application.

5. The method according to any one of claims 1-4, characterized in that, The hardware device is a password card or an acceleration card, and the virtio device is a virtual network card device.

6. A configuration device for a hardware device, characterized in that, The device is deployed on a host machine connected to the hardware device. A virtual machine is created on the host machine. The host machine and the virtual machine support the virtual input / output virtio protocol. The virtual machine installs a virtio front-end driver. The virtio front-end driver is used to call the virtio device mounted on the virtual machine. The virtio device is used to simulate the hardware device. The device includes a format conversion module and a hardware device driver for the hardware device. The format conversion module is deployed on the virtual machine, and the hardware device driver is deployed on the host machine. The format conversion module is used to obtain a channel creation instruction in a first format, wherein the first format is a format that the hardware device supports processing. The format conversion module is used to convert the format of the channel creation instruction in the first format from the first format to the second format that the virtio front-end driver supports processing, and send the channel creation instruction in the second format to the virtio front-end driver. The virtio front-end driver is used to obtain the channel creation instruction in the second format and send the channel creation instruction in the second format to the hardware device driver; The hardware device driver is used to convert the format of the channel creation instruction in the second format from the second format to the first format; The hardware device driver is used to create a control channel with the virtio front-end driver according to the channel creation instruction of the first format.

7. The apparatus according to claim 6, characterized in that, The hardware device supports direct communication with the virtual machine, and the hardware device driver is also used to create a pass-through data channel with the virtio front-end driver; or, The hardware device does not support direct communication with the virtual machine. The hardware device driver is also used to create a forwarding mode data channel with the virtio frontend driver.

8. The apparatus according to claim 7, characterized in that, The format conversion module is further configured to encapsulate the data packet into a first message in a second format, call the virtio front-end driver, and send the first message in the second format to the hardware device driver through the data channel. The data packet is generated by the application running on the virtual machine and includes business data. The hardware device driver is also used to acquire the first message in the second format and convert the format of the first message in the second format from the second format to the first format; The hardware device driver is also used to call the hardware device to process the first message of the first format and generate a second message of the first format. The second message includes processing result data, which is generated by the hardware device processing the business data.

9. The apparatus according to claim 8, characterized in that, The hardware device driver is further configured to convert the format of the second message in the first format to the second format, and send the second message in the second format to the virtio front-end driver through the data channel; The format conversion module is further configured to obtain the second message in the second format sent by the virtio front-end driver, deseal the second message in the second format to obtain the processing result data, and send the processing result data to the application.

10. The apparatus according to any one of claims 6-9, characterized in that, The hardware device is a password card or an acceleration card, and the virtio device is a virtual network card device.

11. A computing device cluster, characterized in that, It includes at least one computing device, each computing device including a processor and memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device to cause the cluster of computing devices to perform the operational steps of the method as described in any one of claims 1 to 5.

12. A computer program product containing instructions, characterized in that, When the instruction is executed by the computing device cluster, the computing device cluster causes the computing device cluster to perform the operation steps of the method as described in any one of claims 1 to 5.

13. A computer-readable storage medium, characterized in that, It includes computer program instructions, which, when executed by a cluster of computing devices, perform the operational steps of the method as described in any one of claims 1 to 5.