HOME
Setting up QVM with GPU Passthrough
Prerequisites
- Hardware Requirements:
- A CPU with virtualization support (Intel VT-x/AMD-V).
- A motherboard that supports IOMMU (Intel VT-d/AMD-Vi).
- A dedicated GPU for the host and a separate GPU for the guest (if using single GPU, you’ll need to rebind it after boot).
- BIOS/UEFI Settings:
- Enable Intel VT-x/AMD-V.
- Enable Intel VT-d/AMD-Vi.
- Enable UEFI boot (optional but recommended).
Step-by-Step Guide
Debian
- Install Necessary Packages:
sudo apt update sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager - Enable IOMMU:
- Edit the GRUB configuration file:
sudo nano /etc/default/grub - Add
intel_iommu=onfor Intel CPUs oramd_iommu=onfor AMD CPUs to theGRUB_CMDLINE_LINUXline:GRUB_CMDLINE_LINUX="... intel_iommu=on" # or for AMD GRUB_CMDLINE_LINUX="... amd_iommu=on" - Update GRUB:
sudo update-grub - Reboot your system:
sudo reboot
- Edit the GRUB configuration file:
- Verify IOMMU Groups:
- Check IOMMU groupings to ensure your hardware is correctly grouped:
find /sys/kernel/iommu_groups/ -type l
- Check IOMMU groupings to ensure your hardware is correctly grouped:
- Configure vfio-pci Driver:
- Identify your GPU and audio device IDs:
lspci -nn | grep -i vga lspci -nn | grep -i audio - Create a vfio-pci configuration file:
sudo nano /etc/modprobe.d/vfio.conf - Add the following lines, replacing
xxxx:yyyywith your GPU and audio device IDs:options vfio-pci ids=xxxx:yyyy,aaaa:bbbb - Update the initramfs:
sudo update-initramfs -u
- Identify your GPU and audio device IDs:
- Blacklist GPU Drivers:
- Create a blacklist configuration file:
sudo nano /etc/modprobe.d/blacklist.conf - Add your GPU drivers to the blacklist:
blacklist nouveau blacklist nvidia blacklist radeon blacklist amdgpu
- Create a blacklist configuration file:
- Configure QEMU/KVM:
- Use
virt-managerto create a new virtual machine and configure it to use the PCI device (your GPU):- Open
virt-manager. - Create a new VM and configure hardware settings.
- Add the PCI Host Device (your GPU).
- Open
- Use
- Start the VM:
- Ensure that your VM is configured correctly and start it using
virt-manager.
- Ensure that your VM is configured correctly and start it using
Arch
- Install Necessary Packages:
sudo pacman -Syu sudo pacman -S qemu libvirt virt-manager ovmf - Enable IOMMU:
- Edit the GRUB configuration file:
sudo nano /etc/default/grub - Add
intel_iommu=onfor Intel CPUs oramd_iommu=onfor AMD CPUs to theGRUB_CMDLINE_LINUXline:GRUB_CMDLINE_LINUX="... intel_iommu=on" # or for AMD GRUB_CMDLINE_LINUX="... amd_iommu=on" - Update GRUB:
sudo grub-mkconfig -o /boot/grub/grub.cfg - Reboot your system:
sudo reboot
- Edit the GRUB configuration file:
- Verify IOMMU Groups:
- Check IOMMU groupings to ensure your hardware is correctly grouped:
find /sys/kernel/iommu_groups/ -type l
- Check IOMMU groupings to ensure your hardware is correctly grouped:
- Configure vfio-pci Driver:
- Identify your GPU and audio device IDs:
lspci -nn | grep -i vga lspci -nn | grep -i audio - Create a vfio-pci configuration file:
sudo nano /etc/modprobe.d/vfio.conf - Add the following lines, replacing
xxxx:yyyywith your GPU and audio device IDs:options vfio-pci ids=xxxx:yyyy,aaaa:bbbb - Update the initramfs:
sudo mkinitcpio -p linux
- Identify your GPU and audio device IDs:
- Blacklist GPU Drivers:
- Create a blacklist configuration file:
sudo nano /etc/modprobe.d/blacklist.conf - Add your GPU drivers to the blacklist:
blacklist nouveau blacklist nvidia blacklist radeon blacklist amdgpu
- Create a blacklist configuration file:
- Configure QEMU/KVM:
- Use
virt-managerto create a new virtual machine and configure it to use the PCI device (your GPU):- Open
virt-manager. - Create a new VM and configure hardware settings.
- Add the PCI Host Device (your GPU).
- Open
- Use
- Start the VM:
- Ensure that your VM is configured correctly and start it using
virt-manager.
- Ensure that your VM is configured correctly and start it using
Tips and Troubleshooting
- BIOS/UEFI Settings: Make sure virtualization and IOMMU are enabled.
- Driver Issues: If the host binds to the GPU, ensure it’s blacklisted and vfio-pci is used.
- IOMMU Groups: Devices in the same group may interfere with passthrough. Consider hardware supporting better IOMMU isolation.
- Performance: Use hugepages for better VM performance.