CN-122019056-A - Transparent transmission method of platform equipment, virtualization system, electronic equipment and storage medium
Abstract
The application provides a transparent transmission method of platform equipment, a virtualization system, electronic equipment and a storage medium, and relates to the technical field of computers. The method comprises the steps of associating target platform equipment in a host machine with a system memory management unit in the host machine so that the target platform equipment can conduct memory management through the system memory management unit, loading a dependent module in the host machine so as to unbind the target platform equipment and a driver of the host machine, binding the target platform equipment to a through driver, resetting the target platform equipment through a reset function corresponding to the target platform equipment in the through driver, and dynamically generating equipment tree nodes of the target platform equipment in the virtual machine according to equipment trees of the host machine when the virtual machine is started so that the virtual machine accesses the target platform equipment according to the equipment tree nodes. The method can realize the safe transparent transmission of the platform equipment, solve the DMA safety isolation problem of the platform equipment, and enable the virtual machine to correctly identify the platform equipment.
Inventors
- LI TONGFENG
- LI WENCHENG
Assignees
- 飞腾信息技术有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260129
Claims (12)
- 1. A method for transparent transmission of platform equipment, comprising: Associating target platform equipment in a host machine with a system memory management unit in the host machine so that the target platform equipment performs memory management through the system memory management unit; Loading a dependency module in the host machine so as to unbind the target platform equipment and the drive of the host machine, bind the target platform equipment to a through drive, and reset the target platform equipment through a reset function corresponding to the target platform equipment in the through drive; And when the virtual machine is started, dynamically generating equipment tree nodes of the target platform equipment in the virtual machine according to the equipment tree of the host machine, so that the virtual machine accesses the target platform equipment according to the equipment tree nodes.
- 2. The method of claim 1, wherein associating the target platform device in the host with the system memory management unit in the host comprises: Adding input and output memory management attribute information under a device tree node corresponding to the target platform device in a host device tree, wherein the input and output memory management attribute information comprises an identifier of the system memory management unit and an identifier of the target platform device connected to the system memory management unit; And creating an association relation between the target platform equipment and the system memory management unit according to the input/output memory management attribute information.
- 3. The method of claim 1, wherein a reset function corresponding to the target platform device is pre-registered in the pass-through drive.
- 4. A method according to claim 3, wherein resetting the target platform device by a reset function corresponding to the target platform device in a pass-through drive comprises: and running a reset function corresponding to the target platform equipment, stopping direct memory access transmission when the reset function runs, and disabling interruption.
- 5. The method of claim 1, wherein the dynamically generating device tree nodes of the target platform device in the virtual machine based on the device tree of the host machine at the time of starting the virtual machine comprises: Creating a virtual bus; Creating a virtual device object corresponding to the target platform device according to a parameter transmission instruction input by a user, and mounting the virtual device object to the virtual bus; When the virtual machine is started, according to the virtual equipment object mounted on the virtual bus, acquiring an equipment tree node corresponding to the target platform equipment in an equipment tree of a host machine, and dynamically generating the equipment tree node of the target platform equipment in the virtual machine according to the equipment tree node of the target platform equipment.
- 6. The method according to claim 5, wherein the obtaining, according to the virtual device object mounted on the virtual bus, a device tree node corresponding to the target platform device in a device tree of a host, and dynamically generating, in the virtual machine, the device tree node of the target platform device according to the device tree node of the target platform device, includes: Acquiring the identification of the target platform equipment according to the identification of the virtual equipment object; Reading and analyzing the equipment tree of the host machine, and acquiring the equipment tree node where the target platform equipment is located in the equipment tree of the host machine according to the identification of the target platform equipment; creating a virtual machine equipment tree in the virtual machine, and creating equipment tree nodes of the target platform equipment in the virtual machine equipment tree according to equipment tree nodes of the target platform equipment in the equipment tree of the host machine.
- 7. The method of claim 6, wherein creating a virtual machine device tree in the virtual machine comprises: And creating the virtual machine equipment tree under a file system specified path of the virtual machine.
- 8. The method of claim 6, wherein creating the device tree node of the target platform device in the virtual machine device tree from the device tree node of the host machine device at which the target platform device is located, comprises: reading equipment node attribute information of the target platform equipment from equipment tree nodes of the host machine, wherein the equipment tree nodes comprise physical addresses and interrupt numbers of the target platform equipment; And adding the equipment node attribute information of the target platform equipment to the position below the equipment tree node of the target platform equipment in the virtual machine equipment tree.
- 9. A virtualization system, comprising a host and at least one virtual machine running on the host, wherein the host at least comprises a platform device, and the host performs the steps of the method of any one of claims 1-8 to realize device transparent transmission from the platform device to the virtual machine.
- 10. The virtualization system of claim 9, wherein a virtual machine manager QEMU, a virtual function input output interface VFIO, a kernel-based virtual machine KVM, and a system memory management unit SMMU are deployed in the host; the host machine performs the method steps of any of claims 1-8 through QEMU, VFIO, KVM and SMMU to achieve device-transparent transfer of the platform device to the virtual machine.
- 11. An electronic device comprising a processor, a storage medium and a bus, the storage medium storing program instructions executable by the processor, the processor and the storage medium communicating over the bus when the electronic device is operating, the processor executing the program instructions to perform the method steps of any of claims 1-8.
- 12. A computer-readable storage medium, characterized in that the storage medium has stored thereon a computer program which, when executed by a processor, realizes the method steps of any of claims 1-8.
Description
Transparent transmission method of platform equipment, virtualization system, electronic equipment and storage medium Technical Field The present application relates to the field of computer technologies, and in particular, to a transparent transmission method of a platform device, a virtualization system, an electronic device, and a storage medium. Background In the field of virtualization technology, device transparent transmission is a technology that allows a Virtual Machine (Virtual Machine) to directly access a Host (Host) physical device, without passing through a Host operating system virtualization layer, so that performance of the device in the Virtual Machine can be significantly improved and delay can be reduced. Currently, the mainstream device pass-through methods are implemented for peripheral component interconnect express (PERIPHERAL COMPONENT INTERCONNECT EXPRESS, PCIe) devices, and lack pass-through to non-PCIe devices, such as pass-through to platform devices. Thus, there is a need for a transparent transmission technique for platform devices. Disclosure of Invention The application aims to overcome the defects in the prior art and provide a transparent transmission method, a virtualization system, electronic equipment and a storage medium of platform equipment so as to realize safe transparent transmission of the platform equipment. In order to achieve the above purpose, the technical scheme adopted by the embodiment of the application is as follows: In a first aspect, an embodiment of the present application provides a transparent transmission method for a platform device, including: Associating target platform equipment in a host machine with a system memory management unit in the host machine so that the target platform equipment performs memory management through the system memory management unit; Loading a dependency module in the host machine so as to unbind the target platform equipment and the drive of the host machine, bind the target platform equipment to a through drive, and reset the target platform equipment through a reset function corresponding to the target platform equipment in the through drive; And when the virtual machine is started, dynamically generating equipment tree nodes of the target platform equipment in the virtual machine according to the equipment tree of the host machine, so that the virtual machine accesses the target platform equipment according to the equipment tree nodes. Optionally, the associating the target platform device in the host with the system memory management unit in the host includes: Adding input and output memory management attribute information under a device tree node corresponding to the target platform device in a host device tree, wherein the input and output memory management attribute information comprises an identifier of the system memory management unit and an identifier of the target platform device connected to the system memory management unit; And creating an association relation between the target platform equipment and the system memory management unit according to the input/output memory management attribute information. Optionally, a reset function corresponding to the target platform device is registered in the pass-through drive in advance. Optionally, resetting the target platform device through a reset function corresponding to the target platform device in the through driving includes: and running a reset function corresponding to the target platform equipment, stopping direct memory access transmission when the reset function runs, and disabling interruption. Optionally, when the virtual machine is started, dynamically generating, in the virtual machine, a device tree node of the target platform device according to the device tree of the host machine, including: Creating a virtual bus; Creating a virtual device object corresponding to the target platform device according to a parameter transmission instruction input by a user, and mounting the virtual device object to the virtual bus; When the virtual machine is started, according to the virtual equipment object mounted on the virtual bus, acquiring an equipment tree node corresponding to the target platform equipment in an equipment tree of a host machine, and dynamically generating the equipment tree node of the target platform equipment in the virtual machine according to the equipment tree node of the target platform equipment. Optionally, the obtaining, according to the virtual device object mounted on the virtual bus, a device tree node corresponding to the target platform device in a device tree of a host, and dynamically generating, in the virtual machine, the device tree node of the target platform device according to the device tree node of the target platform device, includes: Acquiring the identification of the target platform equipment according to the identification of the virtual equipment object; Reading and analyzing the equipment tree of the hos