Merge minimal scripts

This commit is contained in:
Risingprism
2020-12-22 03:14:44 +00:00
parent fc2769db05
commit 4d9866cc15
2 changed files with 44 additions and 110 deletions
+13 -36
View File
@@ -3,15 +3,16 @@ set -x
echo "Beginning of teardown!"
# Unload VFIO-PCI Kernel Driver
modprobe -r vfio-pci
modprobe -r vfio_iommu_type1
modprobe -r vfio
# Re-Bind GPU to AMD Driver
input="/tmp/vfio-virsh-ids"
while read virshId; do
virsh nodedev-reattach "$virshId"
# Restart Display Manager
input="/tmp/vfio-store-display-manager"
while read displayManager; do
if command -v systemctl; then
systemctl start "$displayManager.service"
else
if command -v sv; then
sv start $displayManager
fi
fi
done < "$input"
# Rebind VT consoles (adapted from https://www.kernel.org/doc/Documentation/fb/fbcon.txt)
@@ -26,33 +27,9 @@ while read consoleNumber; do
fi
done < "$input"
# Hack that magically makes nvidia gpus work :)
if command -v nvidia-xconfig ; then
nvidia-xconfig --query-gpu-info > /dev/null 2>&1
# Rebind framebuffer for nvidia
if test -e "/tmp/vfio-is-nvidia" ; then
echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind
fi
# According to kernel documentation (https://www.kernel.org/doc/Documentation/fb/fbcon.txt),
# specifically unbinding efi-framebuffer is not necessary after all consoles
# are unbound (and often times harmful in my experience), so it was omitted here
# I leave it here for reference in case anyone needs it.
# Re-Bind EFI-Framebuffer
# if test -e "/sys/bus/platform/drivers/efi-framebuffer/bind" ; then
# echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind
# else
# echo "Could not find framebuffer to bind!"
# fi
#Load amd driver
input="/tmp/vfio-loaded-gpu-modules"
while read gpuModule; do
modprobe "$gpuModule"
done < "$input"
# Restart Display Manager
input="/tmp/vfio-store-display-manager"
while read displayManager; do
systemctl start "$displayManager"
done < "$input"
echo "End of teardown!"