experiment-x/scripts/vfio-group.sh
Dhiru Kholia ca219f57e5 OSX-KVM - March 2021 - Batch Update 1
Changes:

- Upgrade to OpenCore 0.6.7-RELEASE

- Big Sur image building script updates (Nick)
  - See https://github.com/kholia/OSX-KVM/pull/169 for details.

- Removed history to reduce repository size
2021-04-16 19:15:29 +05:30

32 lines
865 B
Bash
Executable file

#!/bin/sh
# mafferri (https://bbs.archlinux.org)
if [ ! -e /sys/kernel/iommu_groups/$1 ]; then
echo "IOMMU group $1 not found"
exit 1
fi
if [ ! -e /sys/bus/pci/drivers/vfio-pci ]; then
sudo modprobe vfio-pci
fi
for i in $(ls /sys/kernel/iommu_groups/$1/devices/); do
if [ -e /sys/kernel/iommu_groups/$1/devices/$i/driver ]; then
if [ "$(basename $(readlink -f \
/sys/kernel/iommu_groups/$1/devices/$i/driver))" != \
"pcieport" ]; then
echo $i | sudo tee \
/sys/kernel/iommu_groups/$1/devices/$i/driver/unbind
fi
fi
done
for i in $(ls /sys/kernel/iommu_groups/$1/devices/); do
if [ ! -e /sys/kernel/iommu_groups/$1/devices/$i/driver ]; then
VEN=$(cat /sys/kernel/iommu_groups/$1/devices/$i/vendor)
DEV=$(cat /sys/kernel/iommu_groups/$1/devices/$i/device)
echo $VEN $DEV | sudo tee \
/sys/bus/pci/drivers/vfio-pci/new_id
fi
done