diff options
author | 0x501D <mail@void.so> | 2021-02-26 11:41:56 +0300 |
---|---|---|
committer | 0x501D <mail@void.so> | 2021-02-26 11:41:56 +0300 |
commit | 3d529f80c48b28b5c4953d4316da6b218ddac941 (patch) | |
tree | 793744941239a48380b0c34e0eef1cd9280c809d | |
parent | 96c747c83830b37c20cdfa99c0271f417d9098b8 (diff) |
sh: add PCI passthrough example script
-rw-r--r-- | sh/pci_passthrough_example.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sh/pci_passthrough_example.sh b/sh/pci_passthrough_example.sh new file mode 100644 index 0000000..1f50af6 --- /dev/null +++ b/sh/pci_passthrough_example.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +VENDOR="8086 1520" +PCIID="0000:04:10.0" + +# do once at boot time: +echo 1 > /sys/module/vfio_iommu_type1/parameters/allow_unsafe_interrupts +# if using Single Root I/O Virtualization (SR-IOV) +# esure SR-IOV and VT-d are enabled in BIOS. +# Enable IOMMU in Linux by adding intel_iommu=on to the kernel parameters, +# I prefer CONFIG_INTEL_IOMMU_DEFAULT_ON=y in kernel config +# Then create VFs: +VFS_NUM=$(cat /sys/class/net/igb_sr1/device/sriov_totalvfs) +echo $VFS_NUM > /sys/class/net/igb_sr1/device/sriov_numvfs +# done + +echo ${PCIID} > /sys/bus/pci/devices/${PCIID}/driver/unbind +echo ${VENDOR} > /sys/bus/pci/drivers/vfio-pci/new_id +chown user /dev/vfio/20 + +# add extra arg to nEMU VM: +# -device vfio-pci,host=04:10.0 |