KVM PCI Passthrough¶
1. Enable IOMMU by editing the grub configuration file.¶
For Intel, boot the machine, and append intel_iommu=on
to the end of the GRUB_CMDLINE_LINUX
line in the grub configuration file.
amd_iommu=on
to the end of the GRUB_CMDLINE_LINUX
line in the grub configuration file.
2. Refresh the grub.cfg file and reboot the host for these changes to take effect:¶
3. Prevent the driver from binding to the Device.¶
10de:11fa: bus id of device, can be get by
lspci -Dnn
4. Optional: Function Passthrough¶
If certain GPU functions, such as audio, cannot be passed through to the VM due to support limitations, you can modify the driver bindings of the endpoints within an IOMMU group to pass through only the necessary GPU functions.
-
Convert the GPU settings to XML and note the PCI address of the endpoints that you want to prevent from attaching to the host drivers.
-
Prevent the endpoints from attaching to the host driver.
driverctl set-override 0000:02:00.1 vfio-pci
REF¶
[1]. https://access.redhat.com/documentation/en-us/red_hat_virtualization/4.0/html/installation_guide/appe-configuring_a_hypervisor_host_for_pci_passthrough#Enabling_IOMMU_Manually
[2]. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/configuring_and_managing_virtualization/assembly_managing-gpu-devices-in-virtual-machines_configuring-and-managing-virtualization#proc_assigning-a-gpu-to-a-virtual-machine_assembly_managing-gpu-devices-in-virtual-machines