Http://pic.dhe.ibm.com/infocenter/lnxinfo/v3r0m0/index.jsp? Topic=%2fliaat%2fliaatbppassthrougtask.htm
Http://www.linux-kvm.org/page/How_to_assign_devices_with_VT-d_in_KVM
1. Check whether the hardware supports iommu.
This is a hardware function. It is called VT-D in Intel architecture.
It can be seen from the BIOS that the positions of different versions are different.
My website is under security-> virtualization-> VT-D.
2. Configure the kernel and support iommu
There is such an option on Intel machines,
Intel_iommu
│ Location: │
│-> Device Drivers │
│ (2)-> IOMMU Hardware Support (IOMMU_SUPPORT [= y])
3. Restart and check whether the service is enabled.
On intel, run
Dmesg | grep-e DMAR-e IOMMU
4. Unbind Device on host
Load the pci_stub module, modprobe pci_stub
Select a device, lspci-s. 0-n,. 0 0280: 8086: 0085 (rev 34)
Bind/unbind
- Echo "8086 0085">/sys/bus/PCI/Drivers/PCI-stub/new_id
- Echo response :0:00. 0>/sys/bus/PCI/devices/response :0:00. 0/driver/unbind
- Echo restart :0:00. 0>/sys/bus/PCI/Drivers/PCI-stub/Bind
5. Send the device to guest
./I386-softmmu/qemu-system-i386-enable-kvm \
-Drive file =.../../kvm/ubuntu. qcow2-boot dc-m 512 \
-Monitor stdio \
-Netdev user, id = usernet-device rtl8139, netdev = usernet \
-Device pci-assign, host =. 0
But even if it fails, an error is returned...
6. Error Analysis and Solution
According to the above method, I did not succeed. I read dmesg, and there is such a sentence.
Kvm_iommu_map_guest: No interrupt remapping support, disallowing device assignment. Re-enble with "allow_unsafe_assigned_interrupts = 1" module option.
After a slight investigation, we found that it was related to this option, config IRQ_REMAP. Unfortunately, I cannot enable it because it must be done on x86_64.
No way, I have to add this parameter when loading the kvm module.
After this parameter is added, it is enough. Like.
Next I used vfio for passthrough. The steps are slightly different..
1. Install the relevant kernel module
Sudo modprobe vfio
Sudo modprobe vfio-pci
In this way, the/dev/vfio device is generated.
2. Add the device to a group according to the document requirements.
Echo 0000: 0d: 00.0>/sys/bus/pci/devices/0000: 0d: 00.0/driver/unbind
Echo 1180 e823>/sys/bus/pci/drivers/vfio-pci/new_id
Echo response :0:00. 0>/sys/bus/pci/devices/response :0:00. 0/driver/unbind
Echo 8086 0085>/sys/bus/pci/drivers/vfio-pci/new_id
In this way,/dev/vfio/6 is generated (the number is determined by the iommu_group number)
3. Start guest
.. /Git/qemu-latest/i386-softmmu/qemu-system-i386-enable-kvm-drive file = ubuntu. qcow2-boot dc-m 512-monitor stdio-netdev user, id = usernet-device vfio-pci, host =. 0
If it is on the power machine, it is written
-Device "spapr-pci-vfio-host-bridge, id = CXGB3,Iommu = 4, Index = 6"
4. fix
By default, this will cause an error. Of course, this is on my machine.
Vfio_iommu_type1_open: No interrupt remapping support. Use the module param "allow_unsafe_interrupts" to enable vfio iommu support on this platform
This means that my machine does not support REMAP, so I just set this parameter to 1.