40 lines
1.1 KiB
Bash
40 lines
1.1 KiB
Bash
#!/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
|