Skip to content

Instantly share code, notes, and snippets.

@keizie
Created July 6, 2015 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keizie/43d2daa31f20c00e358c to your computer and use it in GitHub Desktop.
Save keizie/43d2daa31f20c00e358c to your computer and use it in GitHub Desktop.
vfio-bind that does not hang on trying to bind again
#!/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