summaryrefslogtreecommitdiffstats
path: root/scripts/vfio-bind
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2016-12-31 01:22:49 +0100
committerNao Pross <naopross@thearcway.org>2016-12-31 01:22:49 +0100
commit0f1ff9fa2e101be45b55303e21e3ace65b0a48c2 (patch)
treebd513996463fee14c8e0264153ebcc3beb75f09e /scripts/vfio-bind
downloadvfio-build-0f1ff9fa2e101be45b55303e21e3ace65b0a48c2.tar.gz
vfio-build-0f1ff9fa2e101be45b55303e21e3ace65b0a48c2.zip
first commit
Diffstat (limited to '')
-rwxr-xr-xscripts/vfio-bind12
1 files changed, 12 insertions, 0 deletions
diff --git a/scripts/vfio-bind b/scripts/vfio-bind
new file mode 100755
index 0000000..f87f9c2
--- /dev/null
+++ b/scripts/vfio-bind
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+modprobe vfio-pci
+
+for dev in "$@"; do
+ 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