Skip to content

Instantly share code, notes, and snippets.

@cspicer
cspicer / vfio-bind
Last active September 19, 2022 23:02
vfio-bind for KVM passthrough
#!/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 2>/dev/null
fi