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.
- #
- export PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/sbin:/usr/local/bin:$PATH
- # 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:00:01.0 0000:00:01.1 0000:00:12.0 0000:00:12.2";
- # The list of PCI devices which are to be re-enabled.
- declare -r EnableDevices="0000:00:01.0 0000:00:01.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="";
- #
- # 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.
- #
- VMscript="/etc/xen/orthowin.cfg";
- #
- # Unbind devices and start the virtual machine.
- #
- unbind_devices;
- #sleep 10s;
- xl -f create $VMscript ;
- exit;
- # xl create /etc/xen/$VMscript
- # Wait for the virtual machine to exit;
- while [ "$VMdone" != "true" ];
- do
- # xm domid Windows >/dev/null 2>&1
- xl domid mercury-xen11 2>&1
- if [ $? -ne 0 ]; then
- VMdone="true";
- else
- #sleep 1m;
- fi;
- done;
- #
- # Unbind drivers from pciback.
- #
- for dev in $PCIdevices;
- do
- echo $dev >| /sys/bus/pci/drivers/pciback/unbind;
- done;
- #sleep 10s;
- #
- # Re-bind drivers.
- #
- for driver in $PCIdrivers;
- do
- eval device=\$$driver;
- for dev in $device;
- do
- echo $dev >| /sys/bus/pci/drivers/$driver/bind;
- done;
- done;
- #sleep 10s;
- #
- # Re-enable PCI devices
- #
- for dev in $EnableDevices;
- do
- echo 1 >| /sys/bus/pci/devices/$dev/enable;
- done;
- #sleep 10s;
- #
- # Re-initialize video.
- #
- /usr/sbin/vbetool post;
- #sleep 10s
- echo;
- exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement