Advertisement
Guest User

Untitled

a guest
Jul 11th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 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. export PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/sbin:/usr/local/bin:$PATH
  8.  
  9. # The name of the script defining the virtual machine to run.
  10. declare VMscript;
  11.  
  12. # The list of PCI devices to be passed through.
  13. declare -r PCIdevices="0000:00:01.0 0000:00:01.1 0000:00:12.0 0000:00:12.2";
  14.  
  15. # The list of PCI devices which are to be re-enabled.
  16. declare -r EnableDevices="0000:00:01.0 0000:00:01.1";
  17.  
  18. # The list of PCI drivers which are to be re-bound and the devices which
  19. # they are to be bound to.
  20. declare -r PCIdrivers="ehci_hcd";
  21. declare -r ehci_hcd="";
  22.  
  23.  
  24. #
  25. # This function is responsible for unbinding and attaching the PCI
  26. # devices to be passed through to the pciback driver.
  27. #
  28.  
  29. function unbind_devices() {
  30.  
  31. local dev;
  32.  
  33. for dev in $PCIdevices;
  34. do
  35. [ ! -e /sys/bus/pci/devices/$dev/driver/unbind ] || \
  36. echo -n $dev > /sys/bus/pci/devices/$dev/driver/unbind;
  37. echo -n $dev > /sys/bus/pci/drivers/pciback/new_slot;
  38. echo -n $dev > /sys/bus/pci/drivers/pciback/bind;
  39. done;
  40.  
  41. return;
  42.  
  43. }
  44.  
  45. #
  46. # Main program starts here.
  47. #
  48. VMscript="/etc/xen/orthowin.cfg";
  49.  
  50.  
  51. #
  52. # Unbind devices and start the virtual machine.
  53. #
  54. unbind_devices;
  55. #sleep 10s;
  56.  
  57. xl -f create $VMscript ;
  58.  
  59. exit;
  60. # xl create /etc/xen/$VMscript
  61.  
  62.  
  63. # Wait for the virtual machine to exit;
  64. while [ "$VMdone" != "true" ];
  65. do
  66. # xm domid Windows >/dev/null 2>&1
  67. xl domid mercury-xen11 2>&1
  68. if [ $? -ne 0 ]; then
  69. VMdone="true";
  70. else
  71. #sleep 1m;
  72. fi;
  73. done;
  74.  
  75.  
  76. #
  77. # Unbind drivers from pciback.
  78. #
  79. for dev in $PCIdevices;
  80. do
  81. echo $dev >| /sys/bus/pci/drivers/pciback/unbind;
  82. done;
  83. #sleep 10s;
  84.  
  85.  
  86. #
  87. # Re-bind drivers.
  88. #
  89. for driver in $PCIdrivers;
  90. do
  91. eval device=\$$driver;
  92. for dev in $device;
  93. do
  94. echo $dev >| /sys/bus/pci/drivers/$driver/bind;
  95. done;
  96. done;
  97. #sleep 10s;
  98.  
  99.  
  100. #
  101. # Re-enable PCI devices
  102. #
  103. for dev in $EnableDevices;
  104. do
  105. echo 1 >| /sys/bus/pci/devices/$dev/enable;
  106. done;
  107. #sleep 10s;
  108.  
  109.  
  110. #
  111. # Re-initialize video.
  112. #
  113. /usr/sbin/vbetool post;
  114. #sleep 10s
  115. echo;
  116.  
  117. exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement