#!/bin/sh
#

# Load VFIO driver
modprobe vfio
modprobe vfio_iommu_type1
modprobe vfio_pci

# Stop X11 temporarily
systemctl stop sddm.service

# Unload NVIDIA driver
modprobe -r nvidia_uvm
modprobe -r nvidia-drm 
modprobe -r nvidia-modeset 
modprobe -r nvidia 
modprobe -r i2c_nvidia_gpu  

virsh nodedev-detach pci_0000_01_00_0 # Detach GPU
virsh nodedev-detach pci_0000_01_00_1 # Detach GPU - Audio
virsh nodedev-detach pci_0000_01_00_2 # Detach GPU - USB
virsh nodedev-detach pci_0000_01_00_3 # Detach GPU - Serial

# Restart X11 for use
systemctl start sddm.service
