Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save francoisjacques/89aad11e9f45c633eaf151c5a6ff639f to your computer and use it in GitHub Desktop.
Save francoisjacques/89aad11e9f45c633eaf151c5a6ff639f to your computer and use it in GitHub Desktop.
Qemu PCI pass-through
How to use 'pci pass-through' to run Linux in Qemu accessing real Ath9k adapter
===============================================================================
# Boot kernel with 'intel_iommu=on'
# Unbind driver from the device and bind 'pci-stub' to it
echo "168c 0030" > /sys/bus/pci/drivers/pci-stub/new_id
echo 0000:0b:00.0 > /sys/bus/pci/devices/0000:0b:00.0/driver/unbind
echo 0000:0b:00.0 > /sys/bus/pci/drivers/pci-stub/bind
# Then just run
sudo qemu-system-i386 -m 1024 \
-device pci-assign,host=0b:00.0,rombar=0 \
-enable-kvm \
-kernel $KERNEL \
-hda $DISK \
-boot c \
-append "root=/dev/sda rw"
# In case of
qemu-system-i386: -device pci-assign,host=0b:00.0: Failed to assign device "(null)" : Operation not permitted
qemu-system-i386: -device pci-assign,host=0b:00.0: Device initialization failed.
qemu-system-i386: -device pci-assign,host=0b:00.0: Device 'kvm-pci-assign' could not be initialized
dmesg | tail
[ 112.129138] kvm_iommu_map_guest: No interrupt remapping support, disallowing device assignment. Re-enble with "allow_unsafe_assigned_interrupts=1" module option.
# run
echo 1 > /sys/module/kvm/parameters/allow_unsafe_assigned_interrupts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment