Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #check for variable existence in case script was runned independently
- if ${VIRSH_GPU+"false"}
- then
- source config
- fi
- # Unload the vfio module. I am lazy, this leaves the GPU without drivers
- modprobe -r vfio-pci
- modprobe -r vfio_iommu_type1
- modprobe -r vfio
- # Reload the kernel modules. This loads the drivers for the GPU
- modprobe snd_hda_intel
- modprobe amdgpu
- virsh nodedev-reattach $VIRSH_GPU_AUDIO
- virsh nodedev-reattach $VIRSH_GPU
- virsh nodedev-reattach $VIRSH_USB
- # Bind the usb
- sh -c "echo $usbid > /sys/bus/pci/drivers/xhci_hcd/new_id"
- sh -c "echo $usbbusid > /sys/bus/pci/devices/$usbbusid/driver/unbind"
- sh -c "echo $usbbusid > /sys/bus/pci/drivers/xhci_hcd/bind"
- sh -c "echo $usbid > /sys/bus/pci/drivers/xhci_hcd/remove_id"
- ls -la /sys/bus/pci/devices/$usbbusid/
- # Re-Bind EFI-Framebuffer and Re-bind to virtual consoles
- # [Source] [https://github.com/joeknock90/Single-GPU-Passthrough/blob/master/README.md#vm-stop-script]
- echo 1 > /sys/class/vtconsole/vtcon0/bind
- sleep 1
- echo 1 > tee /sys/class/vtconsole/vtcon1/bind
- sleep 1
- # Reload the Display Manager to access X
- systemctl start lightdm
- sleep 2
- # Restore the Frame Buffer
- echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/bind
- sleep 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement