Guest User

vfio1

a guest
Jan 13th, 2022
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. #!/bin/bash
  2. # Helpful to read output when debugging
  3. set -x
  4.  
  5. long_delay=10
  6. medium_delay=5
  7. short_delay=1
  8. echo "Beginning of startup!"
  9.  
  10. function stop_display_manager_if_running {
  11. # Stop dm using systemd
  12. if command -v systemctl; then
  13. if systemctl is-active --quiet "$1.service" ; then
  14. echo $1 >> /tmp/vfio-store-display-manager
  15. systemctl stop "$1.service"
  16. fi
  17.  
  18. while systemctl is-active --quiet "$1.service" ; do
  19. sleep "${short_delay}"
  20. done
  21.  
  22. return
  23. fi
  24.  
  25. # Stop dm using runit
  26. if command -v sv; then
  27. if sv status $1 ; then
  28. echo $1 >> /tmp/vfio-store-display-manager
  29. sv stop $1
  30. fi
  31. fi
  32. }
  33.  
  34.  
  35. # Stop currently running display manager
  36. if test -e "/tmp/vfio-store-display-manager" ; then
  37. rm -f /tmp/vfio-store-display-manager
  38. fi
  39.  
  40. stop_display_manager_if_running sddm
  41. stop_display_manager_if_running gdm
  42. stop_display_manager_if_running lightdm
  43. stop_display_manager_if_running lxdm
  44. stop_display_manager_if_running xdm
  45. stop_display_manager_if_running mdm
  46. stop_display_manager_if_running display-manager
  47.  
  48. # Unbind VTconsoles if currently bound (adapted from https://www.kernel.org/doc/Documentation/fb/fbcon.txt)
  49. if test -e "/tmp/vfio-bound-consoles" ; then
  50. rm -f /tmp/vfio-bound-consoles
  51. fi
  52. for (( i = 0; i < 16; i++))
  53. do
  54. if test -x /sys/class/vtconsole/vtcon${i}; then
  55. if [ `cat /sys/class/vtconsole/vtcon${i}/name | grep -c "frame buffer"` \
  56. = 1 ]; then
  57. echo 0 > /sys/class/vtconsole/vtcon${i}/bind
  58. echo "Unbinding console ${i}"
  59. echo $i >> /tmp/vfio-bound-consoles
  60. fi
  61. fi
  62. done
  63.  
  64. # Unbind EFI-Framebuffer
  65. if test -e "/tmp/vfio-is-nvidia" ; then
  66. rm -f /tmp/vfio-is-nvidia
  67. fi
  68.  
  69. if lsmod | grep "nvidia" &> /dev/null ; then
  70. echo "true" >> /tmp/vfio-is-nvidia
  71. echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
  72. fi
  73.  
  74. echo "End of startup!"
Advertisement
Add Comment
Please, Sign In to add comment