You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
644 B
Plaintext

4 years ago
#!/bin/bash
#sudo rmmod vfio-pci
4 years ago
for dev in "$@"; do
vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
device=$(cat /sys/bus/pci/devices/$dev/device)
echo "Removing ${dev} from vfio-pci id list"
echo "${vendor} ${device}" | sudo tee /sys/bus/pci/drivers/vfio-pci/remove_id
4 years ago
sleep 0.1
echo "Remove PCI device"
echo 1 | sudo tee /sys/bus/pci/devices/${dev}/remove
4 years ago
while [[ -e "/sys/bus/pci/devices/${dev}" ]]; do
sleep 0.1
done
echo "Rescanning..."
echo 1 | sudo tee /sys/bus/pci/rescan
4 years ago
while [[ ! -e "/sys/bus/pci/devices/${dev}" ]]; do
sleep 0.1
done
done
sudo rmmod vfio-pci