Created
July 6, 2015 22:06
-
-
Save keizie/43d2daa31f20c00e358c to your computer and use it in GitHub Desktop.
vfio-bind that does not hang on trying to bind again
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
modprobe vfio-pci | |
for dev in "$@"; do | |
if [ -e /sys/bus/pci/drivers/vfio-pci/$dev ]; then | |
continue | |
fi | |
vendor=$(cat /sys/bus/pci/devices/$dev/vendor) | |
device=$(cat /sys/bus/pci/devices/$dev/device) | |
if [ -e /sys/bus/pci/devices/$dev/driver ]; then | |
echo $dev > /sys/bus/pci/devices/$dev/driver/unbind | |
fi | |
echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment