Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # This script executes the virtual machine defined by a configuration
- # script in a passthrough environment.
- #
- #pci = [ '01:00.0','01:00.1','00:1b.0','00:1a.0','00:1d.0' ]
- # The name of the script defining the virtual machine to run.
- declare VMscript;
- # The list of PCI devices to be passed through.
- declare -r PCIdevices="0000:01:00.0 0000:01:00.1 0000:00:1a.0 0000:00:1d.0";
- # The list of PCI devices which are to be re-enabled.
- declare -r EnableDevices="0000:01:00.0 0000:01:00.1";
- # The list of PCI drivers which are to be re-bound and the devices which
- # they are to be bound to.
- declare -r PCIdrivers="ehci_hcd";
- declare -r ehci_hcd="0000:00:1a.0";
- #
- # This function is responsible for unbinding and attaching the PCI
- # devices to be passed through to the pciback driver.
- #
- function unbind_devices() {
- local dev;
- for dev in $PCIdevices;
- do
- [ ! -e /sys/bus/pci/devices/$dev/driver/unbind ] || \
- echo -n $dev > /sys/bus/pci/devices/$dev/driver/unbind;
- echo -n $dev > /sys/bus/pci/drivers/pciback/new_slot;
- echo -n $dev > /sys/bus/pci/drivers/pciback/bind;
- done;
- return;
- }
- #
- # Main program starts here.
- #
- if [ -z "$1" ]; then
- echo "No virtual machine script specified.";
- exit 1;
- fi;
- VMscript="$1";
- #
- # Unbind devices and start the virtual machine.
- #
- unbind_devices;
- sleep 1s;
- xl -f create $VMscript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement