diff --git a/xen-dom0-pci-hide.sh b/xen-dom0-pci-hide.sh new file mode 100644 index 0000000..83d0fa6 --- /dev/null +++ b/xen-dom0-pci-hide.sh @@ -0,0 +1,39 @@ +#!/bin/sh -e + +DEVICES="0000:00:0b.0 0000:00:0b.1 0000:01:06.0" + +# check for xen pci backend +[ -d /sys/bus/pci/drivers/pciback ] || exit + +for dev in $DEVICES; do + echo "Hiding pci-device [$dev] from dom0" + + if [ -d /sys/bus/pci/devices/$dev/driver ]; then + driver=$(basename `readlink /sys/bus/pci/devices/$dev/driver`) + if [ "x$driver" = "xpciback" ]; then + echo " already hidden" + continue; + fi + + echo -n " already bound to a driver ($driver), trying to unbind:" + echo -n $dev > /sys/bus/pci/devices/$dev/driver/unbind + + count=5 + while [ -d /sys/bus/pci/devices/$dev/driver ]; do + echo -n "." + echo -n $dev > /sys/bus/pci/devices/$dev/driver/unbind + sleep 1 + + count=$[$count -1] + [ "$count" = "0" ] && break; + done + + if [ "$count" = "0" ]; then + echo " failed" + continue; + fi + fi + echo " ok" + echo -n $dev > /sys/bus/pci/drivers/pciback/new_slot + echo -n $dev > /sys/bus/pci/drivers/pciback/bind +done