Q35 platform is required. For this documentation, the guest OS used is Ubuntu 18.04 server and OVMF UEFI.
Using:
virsh edit <vm-name>
In features
section add:
<ioapic driver='qemu'/>
And in devices
section add:
<iommu model='intel'>
<driver intremap='on'/>
</iommu>
Add intel_iommu=on
to GRUB_CMDLINE_LINUX_DEFAULT
variable in /etc/default/grub
file. And then update by running sudo update-grub
command.
The following script can be used to list groups and their devices.
bash -c '
for group in $(ls -1 /sys/kernel/iommu_groups); do
echo "group-${group}:"
for device in $(ls -1 /sys/kernel/iommu_groups/${group}/devices); do
echo " - $(lspci -nnks ${device})"
done
done
'
Example output:
group-0:
- 00:00.0 Host bridge [0600]: Intel Corporation 82G33/G31/P35/P31 Express DRAM Controller [8086:29c0]
Subsystem: Red Hat, Inc. QEMU Virtual Machine [1af4:1100]
group-1:
- 00:01.0 VGA compatible controller [0300]: Red Hat, Inc. QXL paravirtual graphic card [1b36:0100] (rev 04)
Subsystem: Red Hat, Inc. QEMU Virtual Machine [1af4:1100]
Kernel driver in use: qxl
Kernel modules: qxl
group-2:
- 00:02.0 PCI bridge [0604]: Red Hat, Inc. QEMU PCIe Root port [1b36:000c]
Kernel driver in use: pcieport
Kernel modules: shpchp
- 00:02.1 PCI bridge [0604]: Red Hat, Inc. QEMU PCIe Root port [1b36:000c]
Kernel driver in use: pcieport
Kernel modules: shpchp
- 00:02.2 PCI bridge [0604]: Red Hat, Inc. QEMU PCIe Root port [1b36:000c]
Kernel driver in use: pcieport
Kernel modules: shpchp
- 00:02.3 PCI bridge [0604]: Red Hat, Inc. QEMU PCIe Root port [1b36:000c]
Kernel driver in use: pcieport
Kernel modules: shpchp
- 00:02.4 PCI bridge [0604]: Red Hat, Inc. QEMU PCIe Root port [1b36:000c]
Kernel driver in use: pcieport
Kernel modules: shpchp
- 00:02.5 PCI bridge [0604]: Red Hat, Inc. QEMU PCIe Root port [1b36:000c]
Kernel driver in use: pcieport
Kernel modules: shpchp
- 01:00.0 PCI bridge [0604]: Red Hat, Inc. Device [1b36:000e]
Kernel driver in use: shpchp
Kernel modules: shpchp
- 02:01.0 Audio device [0403]: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) High Definition Audio Controller [8086:2668] (rev 01)
Subsystem: Red Hat, Inc. QEMU Virtual Machine [1af4:1100]
Kernel driver in use: snd_hda_intel
Kernel modules: snd_hda_intel
- 03:00.0 Ethernet controller [0200]: Red Hat, Inc. Virtio network device [1af4:1041] (rev 01)
Subsystem: Red Hat, Inc. Virtio network device [1af4:1100]
Kernel driver in use: virtio-pci
- 04:00.0 Communication controller [0780]: Red Hat, Inc. Virtio console [1af4:1043] (rev 01)
Subsystem: Red Hat, Inc. Virtio console [1af4:1100]
Kernel driver in use: virtio-pci
- 05:00.0 SCSI storage controller [0100]: Red Hat, Inc. Virtio block device [1af4:1042] (rev 01)
Subsystem: Red Hat, Inc. Virtio block device [1af4:1100]
Kernel driver in use: virtio-pci
- 06:00.0 Unclassified device [00ff]: Red Hat, Inc. Virtio memory balloon [1af4:1045] (rev 01)
Subsystem: Red Hat, Inc. Virtio memory balloon [1af4:1100]
Kernel driver in use: virtio-pci
group-3:
- 00:1d.0 USB controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #1 [8086:2934] (rev 03)
Subsystem: Red Hat, Inc. QEMU Virtual Machine [1af4:1100]
Kernel driver in use: uhci_hcd
- 00:1d.1 USB controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #2 [8086:2935] (rev 03)
Subsystem: Red Hat, Inc. QEMU Virtual Machine [1af4:1100]
Kernel driver in use: uhci_hcd
- 00:1d.2 USB controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #3 [8086:2936] (rev 03)
Subsystem: Red Hat, Inc. QEMU Virtual Machine [1af4:1100]
Kernel driver in use: uhci_hcd
- 00:1d.7 USB controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #1 [8086:293a] (rev 03)
Subsystem: Red Hat, Inc. QEMU Virtual Machine [1af4:1100]
Kernel driver in use: ehci-pci
group-4:
- 00:1f.0 ISA bridge [0601]: Intel Corporation 82801IB (ICH9) LPC Interface Controller [8086:2918] (rev 02)
Subsystem: Red Hat, Inc. QEMU Virtual Machine [1af4:1100]
Kernel driver in use: lpc_ich
Kernel modules: lpc_ich
- 00:1f.2 SATA controller [0106]: Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 6 port SATA Controller [AHCI mode] [8086:2922] (rev 02)
Subsystem: Red Hat, Inc. QEMU Virtual Machine [1af4:1100]
Kernel driver in use: ahci
Kernel modules: ahci
- 00:1f.3 SMBus [0c05]: Intel Corporation 82801I (ICH9 Family) SMBus Controller [8086:2930] (rev 02)
Subsystem: Red Hat, Inc. QEMU Virtual Machine [1af4:1100]
Kernel modules: i2c_i801