joeknock90/Single-GPU-Passthrough

Host can't reattach gpu after vm shutdown

pziajski opened this issue · 1 comments

So simply running my start and end script from an ssh works fine, no errors. When i run my win10 vm, the start script works and everything boots and shows. But when i shutdown the vm, i get stuck with no display to my monitors. I tried to ssh into my pc after the vm shutdown and got this after running the end script manually

here is my startup

#!/bin/bash
set -x

source "/etc/libvirt/hooks/kvm.conf"

systemctl stop sddm.service

echo 0 > /sys/class/vtconsole/vtcon0/bind
echo 0 > /sys/class/vtconsole/vtcon1/bind

echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind

sleep 10

modprobe -r nvidia
modprobe -r nvidia_drm
modprobe -r nvidia_modeset
modprobe -r drm_kms_helper
modprobe -r i2c_nvidia_gpu
modprobe -r drm
modprobe -r nvidia_uvm

virsh nodedev-detach $VIRSH_GPU_VIDEO
virsh nodedev-detach $VIRSH_GPU_AUDIO
virsh nodedev-detach $VIRSH_GPU_USB
virsh nodedev-detach $VIRSH_GPU_USBC

modprobe vfio
modprobe vfio_pci
modprobe vfio_iommu_type1

here is my revert

#!/bin/bash
set -x

source "/etc/libvirt/hooks/kvm.conf"

modprobe -r vfio_pci
modprobe -r vfio_iommu_type1
modprobe -r vfio

virsh nodedev-reattach $VIRSH_GPU_VIDEO
virsh nodedev-reattach $VIRSH_GPU_AUDIO
virsh nodedev-reattach $VIRSH_GPU_USB
virsh nodedev-reattach $VIRSH_GPU_USBC

echo 1 > /sys/class/vtconsole/vtcon0/bind

nvidia-xconfig --query-gpu-info > /dev/null 2>&1

echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind

modprobe nvidia
modprobe nvidia_uvm
modprobe nvidia_drm
modprobe nvidia_modeset
modprobe drm_kms_helper
modprobe drm
modprobe i2c_nvidia_gpu

systemctl start sddm.service

let me know if you need anything else, like my vm settings or what not

edit: removed markdown styling
edit 2: code formatting

i guess i messed up somewhere along the way because i wiped everything and retried, and everything works now, other than a error 43 atleast...