Advertisement
Guest User

Script to start domU

a guest
Oct 27th, 2013
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.49 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #
  4. # This script executes the virtual machine defined by a configuration
  5. # script in a passthrough environment.
  6. #
  7.  
  8. #pci  = [ '01:00.0','01:00.1','00:1b.0','00:1a.0','00:1d.0' ]
  9.  
  10. # The name of the script defining the virtual machine to run.
  11. declare VMscript;
  12.  
  13. # The list of PCI devices to be passed through.
  14. declare -r PCIdevices="0000:01:00.0 0000:01:00.1 0000:00:1a.0 0000:00:1d.0";
  15.  
  16. # The list of PCI devices which are to be re-enabled.
  17. declare -r EnableDevices="0000:01:00.0 0000:01:00.1";
  18.  
  19. # The list of PCI drivers which are to be re-bound and the devices which
  20. # they are to be bound to.
  21. declare -r PCIdrivers="ehci_hcd";
  22. declare -r ehci_hcd="0000:00:1a.0";
  23.  
  24.  
  25. #
  26. # This function is responsible for unbinding and attaching the PCI
  27. # devices to be passed through to the pciback driver.
  28. #
  29.  
  30. function unbind_devices() {
  31.  
  32.         local dev;
  33.  
  34.         for dev in $PCIdevices;
  35.         do
  36.                 [ ! -e /sys/bus/pci/devices/$dev/driver/unbind ] || \
  37.                         echo -n $dev > /sys/bus/pci/devices/$dev/driver/unbind;
  38.                 echo -n $dev > /sys/bus/pci/drivers/pciback/new_slot;
  39.                 echo -n $dev > /sys/bus/pci/drivers/pciback/bind;
  40.         done;
  41.  
  42.         return;
  43.    
  44. }
  45.  
  46. #
  47. # Main program starts here.
  48. #
  49. if [ -z "$1" ]; then
  50.         echo "No virtual machine script specified.";
  51.         exit 1;
  52. fi;
  53. VMscript="$1";
  54.  
  55.  
  56. #
  57. # Unbind devices and start the virtual machine.
  58. #
  59. unbind_devices;
  60. sleep 1s;
  61.  
  62. xl -f create $VMscript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement