KVM PCI Passthrough Error — Quick Fix
In this tutorial, you'll learn about KVM PCI Passthrough Error. We cover key concepts, practical examples, and best practices.
The Problem
Attempting to pass a PCI device (GPU, NVMe, or network card) to a KVM VM fails. The VM cannot start, or the device shows as unusable inside the guest. The IOMMU groups may not be properly configured, or the host driver may still be bound to the device.
Error example:
Device 0000:01:00.0 is in use by driver nvidia
Failed to assign device: Device or resource busy
VFIO group is not viable: Group is not viable
The Fix
Step 1: Verify IOMMU is enabled
WRONG — trying to pass through devices without IOMMU support:
# IOMMU must be enabled in the kernel boot parameters
# Without it, PCI passthrough is impossible
RIGHT — check IOMMU is enabled:
# Check kernel boot parameters
cat /proc/cmdline
Output should include:
intel_iommu=on
or
amd_iommu=on
Verify IOMMU groups exist:
ls -l /sys/kernel/iommu_groups/
If the directory is empty or missing, add intel_iommu=on iommu=pt to the GRUB boot parameters in /etc/default/grub and run update-grub.
Step 2: Bind the device to vfio-pci
WRONG — assigning a device that is still bound to the host driver:
# The host driver claims the device and VFIO cannot access it
RIGHT — bind the device to vfio-pci:
# Find the device IDs
lspci -nn | grep -i nvidia
# Add to the vfio-pci driver
echo "options vfio-pci ids=10de:1e87,10de:10f0" > /etc/modprobe.d/vfio.conf
# Rebuild initramfs
update-initramfs -u
# Reboot
Use DodaTech's PCI Passthrough Validator to verify IOMMU groups, driver binding, and interrupt remapping before configuring VM passthrough.
Prevention Tips
- Always enable ACS (Access Control Services) on PCIe switches for better IOMMU group isolation
- Verify the GPU has a UEFI-capable VBIOS for UEFI guest boot
- Reserve the PCI device early in the boot process using the vfio-pci driver override
- For NVIDIA GPUs, ensure the guest has the correct NVIDIA drivers installed
- Use DodaTech's Device Compatibility Checker to validate passthrough feasibility
Common Mistakes with pci passthrough
- Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
- Using
headandtailinstead of pattern matching, causing runtime errors on empty lists - Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
These mistakes appear frequently in real-world KVM code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Related: DodaTech's GPU Passthrough Automation Suite simplifies the configuration process with automatic IOMMU group analysis and driver binding scripts.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro