diff --git a/README.md b/README.md index 5cc27fe..b10f01e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ # Single GPU Passthrough Scripts -Scripts for passing a Polaris GPU from a linux host to a windows VM and back. \ No newline at end of file +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 + diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..80f2505 --- /dev/null +++ b/install.sh @@ -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 diff --git a/qemu b/qemu index 5310869..9426d70 100755 --- a/qemu +++ b/qemu @@ -1,12 +1,13 @@ -#!/bin/sh +#!/bin/bash # Script for win10 if [[ $1 == "win10" ]]; 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 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 + diff --git a/polaris-vfio-startup.sh b/vfio-startup.sh similarity index 89% rename from polaris-vfio-startup.sh rename to vfio-startup.sh index 5cd2197..d488739 100755 --- a/polaris-vfio-startup.sh +++ b/vfio-startup.sh @@ -37,37 +37,41 @@ stop_display_manager_if_running gdm.service stop_display_manager_if_running lightdm.service stop_display_manager_if_running lxdm.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 if test -e "/sys/class/vtconsole/vtcon0/bind" ; then echo 0 > /sys/class/vtconsole/vtcon0/bind - sleep "${long_delay}" fi if test -e "/sys/class/vtconsole/vtcon1/bind" ; then echo 0 > /sys/class/vtconsole/vtcon1/bind - sleep "${long_delay}" fi #Unbind EFI-Framebuffer if currently bound if test -e "/sys/bus/platform/drivers/efi-framebuffer/unbind" ; then echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind - sleep "${medium_delay}" else echo "Could not find framebuffer to unload!" fi +sleep "${long_delay}" + # Unload loaded GPU drivers if test -e "/tmp/vfio-loaded-gpu-modules" ; then rm -f /tmp/vfio-loaded-gpu-modules fi +unload_module_if_loaded amdgpu-pro unload_module_if_loaded amdgpu unload_module_if_loaded nvidia_drm unload_module_if_loaded nvidia_modeset unload_module_if_loaded nvidia_uvm unload_module_if_loaded nvidia unload_module_if_loaded ipmi_devintf - +unload_module_if_loaded nouveau +unload_module_if_loaded i915 # Unbind the GPU from display driver virsh nodedev-detach pci_0000_01_00_0 @@ -76,4 +80,4 @@ virsh nodedev-detach pci_0000_01_00_1 # Load VFIO kernel module modprobe vfio-pci -echo "End of startup!" \ No newline at end of file +echo "End of startup!" diff --git a/polaris-vfio-teardown.sh b/vfio-teardown.sh similarity index 100% rename from polaris-vfio-teardown.sh rename to vfio-teardown.sh