How do I enable KVM device passthrough in Linux?
I have an MSI-GD65 Gaming motherboard and an Intel i7 4790. VT-D is enabled in the CPU Features section of the bios.
I'm running Ubuntu 14.04.1 LTS and when I try and detach a device, I get the following message:
# virsh nodedev-detach pci_0000_00_1f_2
error: Failed to detach device pci_0000_00_1f_2 error: Operation not supported: neither VFIO nor KVM device assignment is currently supported on this system
Dmesg includes some information about IOMMU but I can't tell if this means that VT-D is enabled
$ dmesg | grep -i iommu
[ 0.027450] dmar: IOMMU 0: reg_base_addr fed90000 ver 1:0 cap c0000020660462 ecap f0101a
[ 0.027455] dmar: IOMMU 1: reg_base_addr fed91000 ver 1:0 cap d2008020660462 ecap f010da
[ 0.027521] IOAPIC id 8 under DRHD base 0xfed91000 IOMMU 1
Can anyone advise what I need to do to enable VT-D on this system and pass through PCI devices to KVM guests please ?
The solution to this issue is to enable IOMMU in your GRUB boot parameters.
You can do this by setting the following in /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="intel_iommu=on"
If you're using an AMD processor, you should append amd_iommu=on
to the boot parameters instead
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash amd_iommu=on"
Then run update-grub
and reboot
This link helped me quite a bit: https://www.centos.org/forums/viewtopic.php?f=47&t=48115
See also: https://pve.proxmox.com/wiki/Pci_passthrough
This eluded me somewhat as I believed that iommu was an AMD alternative to VT-D.
Adding to Anonymouslemming's answer: There seems to be a bug in Ubuntu (18.04 for me), which causes the setting for GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub to be ignored.
It can be fixed by commenting out the GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub.d/50-curtin-settings.cfg
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1569567
You seem to have the hardware requirements because another module is using it (IOAPIC) In this case you need to simply setup the software end.
It looks like you need to make sure you have all the prerequisites installed to support the detachment of the appropriate device. It sounds like you don't have them installed, or they are not set up.
You need to have the appropriate libraries and kernel modules installed and initialized before you attempt to use them in a case like this. These will be various "host" system utilities and kernel modules for your KVM setup.
You need to read the section of the manual on how to appropriately set up your appropriate KVM solution, and follow those steps, before you attempt to just run the utilities. They don't simply setup on first launch just because the necessary packages are installed.
Please note, that if the device in question is embedded in the motherboard, it may not technically be a PCI device, but a PCI-Mapped device. These devices are actually attached by other means, but are mapped to the PCI BIOS space using their BIOS. They may or may not be compatible with device detachment, depending on various aspects of how they are attached to the system.
Additionally, you may not be able to detach sub-devices without detaching parent devices, if their drivers are interdependent. You can only detach devices with absolute certainity who's parent device is the PCI controller, PCI Bridge, or some other supported Bus controller or bridge