Merge branch 'soviet' into 'master'

Soviet

See merge request risingprismtv/single-gpu-passthrough!4
This commit is contained in:
Risingprism 2020-10-08 19:40:52 +00:00
commit a4a2bf80aa
5 changed files with 34 additions and 9 deletions

View File

@ -1,3 +1,10 @@
# Single GPU Passthrough Scripts # Single GPU Passthrough Scripts
Scripts for passing a Polaris GPU from a linux host to a windows VM and back. Scripts for passing a single GPU from a Linux host to a Windows VM and back.
1. Change PCI ids in the vfio-startup and teardown script.
2. Change the VM name in qemu if not already win10
3. Run the install.sh script as root
For suggestions or support, join us on Discord at: https://discord.gg/bh4maVc

13
install.sh Normal file
View File

@ -0,0 +1,13 @@
#!/bin/sh
mv /etc/libvirt/hooks/qemu /etc/libvirt/hooks/qemu_last_backup
mv /bin/vfio-startup.sh /bin/vfio-startup.sh.bkp
mv /bin/vfio-teardown.sh /bin/vfio-teardown.sh.bkp
cp vfio-startup.sh /bin/vfio-startup.sh
cp vfio-teardown.sh /bin/vfio-teardown.sh
cp qemu /etc/libvirt/hooks/qemu
chmod +x /bin/vfio-startup.sh
chmod +x /bin/vfio-teardonw/sh
chmod +x /etc/libvirt/hooks/qemu

7
qemu
View File

@ -1,12 +1,13 @@
#!/bin/sh #!/bin/bash
# Script for win10 # Script for win10
if [[ $1 == "win10" ]]; then if [[ $1 == "win10" ]]; then
if [[ $2 == "prepare" ]]; then if [[ $2 == "prepare" ]]; then
/bin/polaris-vfio-startup.sh /bin/vfio-startup.sh 2>&1 | tee -a /var/log/libvirt/custom_hooks.log
fi fi
if [[ $2 == "release" ]]; then if [[ $2 == "release" ]]; then
/bin/polaris-vfio-teardown.sh /bin/vfio-teardown.sh 2>&1 | tee -a /var/log/libvirt/custom_hooks.log
fi fi
fi fi

View File

@ -37,37 +37,41 @@ stop_display_manager_if_running gdm.service
stop_display_manager_if_running lightdm.service stop_display_manager_if_running lightdm.service
stop_display_manager_if_running lxdm.service stop_display_manager_if_running lxdm.service
stop_display_manager_if_running xdm.service stop_display_manager_if_running xdm.service
stop_display_manager_if_running mdm.service
stop_display_manager_if_running display-manager.service
# Unbind VTconsoles if currently bound # Unbind VTconsoles if currently bound
if test -e "/sys/class/vtconsole/vtcon0/bind" ; then if test -e "/sys/class/vtconsole/vtcon0/bind" ; then
echo 0 > /sys/class/vtconsole/vtcon0/bind echo 0 > /sys/class/vtconsole/vtcon0/bind
sleep "${long_delay}"
fi fi
if test -e "/sys/class/vtconsole/vtcon1/bind" ; then if test -e "/sys/class/vtconsole/vtcon1/bind" ; then
echo 0 > /sys/class/vtconsole/vtcon1/bind echo 0 > /sys/class/vtconsole/vtcon1/bind
sleep "${long_delay}"
fi fi
#Unbind EFI-Framebuffer if currently bound #Unbind EFI-Framebuffer if currently bound
if test -e "/sys/bus/platform/drivers/efi-framebuffer/unbind" ; then if test -e "/sys/bus/platform/drivers/efi-framebuffer/unbind" ; then
echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
sleep "${medium_delay}"
else else
echo "Could not find framebuffer to unload!" echo "Could not find framebuffer to unload!"
fi fi
sleep "${long_delay}"
# Unload loaded GPU drivers # Unload loaded GPU drivers
if test -e "/tmp/vfio-loaded-gpu-modules" ; then if test -e "/tmp/vfio-loaded-gpu-modules" ; then
rm -f /tmp/vfio-loaded-gpu-modules rm -f /tmp/vfio-loaded-gpu-modules
fi fi
unload_module_if_loaded amdgpu-pro
unload_module_if_loaded amdgpu unload_module_if_loaded amdgpu
unload_module_if_loaded nvidia_drm unload_module_if_loaded nvidia_drm
unload_module_if_loaded nvidia_modeset unload_module_if_loaded nvidia_modeset
unload_module_if_loaded nvidia_uvm unload_module_if_loaded nvidia_uvm
unload_module_if_loaded nvidia unload_module_if_loaded nvidia
unload_module_if_loaded ipmi_devintf unload_module_if_loaded ipmi_devintf
unload_module_if_loaded nouveau
unload_module_if_loaded i915
# Unbind the GPU from display driver # Unbind the GPU from display driver
virsh nodedev-detach pci_0000_01_00_0 virsh nodedev-detach pci_0000_01_00_0