5 changed files with 34 additions and 36 deletions
-2
View File
@@ -9,7 +9,5 @@ Note the PCI ids and display manager should be detected automatically. If you ar
If using startx, add a line `killall -u user_name` to qemu/vfio-startup.sh script towards the beginning and you can add a line to vfio-teardown.sh to start your window manager/ desktop environment again. Don't just add startx because it will be run as root. Instead add `su -s /bin/bash -c "/usr/bin/startx" -g username username` replacing username with your username to the end of the vfio-teardown.sh script. If using startx, add a line `killall -u user_name` to qemu/vfio-startup.sh script towards the beginning and you can add a line to vfio-teardown.sh to start your window manager/ desktop environment again. Don't just add startx because it will be run as root. Instead add `su -s /bin/bash -c "/usr/bin/startx" -g username username` replacing username with your username to the end of the vfio-teardown.sh script.
For a detailled guide on how to use these scripts, [check out the the wiki of this repo.](https://gitlab.com/risingprismtv/single-gpu-passthrough/-/wikis/home)
For suggestions or support, join us on Discord at: https://discord.gg/bh4maVc For suggestions or support, join us on Discord at: https://discord.gg/bh4maVc
+2 -2
View File
@@ -7,12 +7,12 @@ if [[ $OBJECT == "win10" ]]; then
case "$OPERATION" in case "$OPERATION" in
"prepare") "prepare")
systemctl start libvirt-nosleep@"$OBJECT" 2>&1 | tee -a /var/log/libvirt/custom_hooks.log systemctl start libvirt-nosleep@"$OBJECT" 2>&1 | tee -a /var/log/libvirt/custom_hooks.log
/usr/local/bin/vfio-startup 2>&1 | tee -a /var/log/libvirt/custom_hooks.log /bin/vfio-startup.sh 2>&1 | tee -a /var/log/libvirt/custom_hooks.log
;; ;;
"release") "release")
systemctl stop libvirt-nosleep@"$OBJECT" 2>&1 | tee -a /var/log/libvirt/custom_hooks.log systemctl stop libvirt-nosleep@"$OBJECT" 2>&1 | tee -a /var/log/libvirt/custom_hooks.log
/usr/local/bin/vfio-teardown 2>&1 | tee -a /var/log/libvirt/custom_hooks.log /bin/vfio-teardown.sh 2>&1 | tee -a /var/log/libvirt/custom_hooks.log
;; ;;
esac esac
fi fi
+14 -14
View File
@@ -15,7 +15,7 @@
## Void for testing and helping out in general ## ## ## ## Void for testing and helping out in general ## ## ##
## .Chris. for testing and helping out in general ## ## Run this command ## ## .Chris. for testing and helping out in general ## ## Run this command ##
## WORMS for helping out with testing ## ## if you dont have ## ## WORMS for helping out with testing ## ## if you dont have ##
##################################################### ## names in you're ## ##################################################### ## names in your ##
## The VFIO community for using the scripts and ## ## lspci feedback ## ## The VFIO community for using the scripts and ## ## lspci feedback ##
## testing them for us! ## ## in your terminal ## ## testing them for us! ## ## in your terminal ##
##################################################### ####################### ##################################################### #######################
@@ -23,21 +23,21 @@
################################# Variables ################################# ################################# Variables #################################
## Adds current time to var for use in echo for a cleaner log and script ## ## Adds current time to var for use in echo for a cleaner log and script ##
DATE=$(date +"%m/%d/%Y %R:%S :") DATETIME=$(date +"%m/%d/%Y %R:%S :")
## Sets dispmgr var as null ## ## Sets dispmgr var as null ##
DISPMGR="null" DISPMGR="null"
################################## Script ################################### ################################## Script ###################################
echo "$DATE Beginning of Startup!" echo "$DATETIME Beginning of Startup!"
function stop_display_manager_if_running { function stop_display_manager_if_running {
## Get display manager on systemd based distros ## ## Get display manager on systemd based distros ##
if [[ -x /run/systemd/system ]] && echo "$DATE Distro is using Systemd"; then if [[ -x /run/systemd/system ]] && echo "$DATETIME Distro is using Systemd"; then
DISPMGR="$(grep 'ExecStart=' /etc/systemd/system/display-manager.service | awk -F'/' '{print $(NF-0)}')" DISPMGR="$(grep 'ExecStart=' /etc/systemd/system/display-manager.service | awk -F'/' '{print $(NF-0)}')"
echo "$DATE Display Manager = $DISPMGR" echo "$DATETIME Display Manager = $DISPMGR"
## Stop display manager using systemd ## ## Stop display manager using systemd ##
if systemctl is-active --quiet "$DISPMGR.service"; then if systemctl is-active --quiet "$DISPMGR.service"; then
@@ -58,7 +58,7 @@ function stop_display_manager_if_running {
function kde-clause { function kde-clause {
echo "$DATE Display Manager = display-manager" echo "$DATETIME Display Manager = display-manager"
## Stop display manager using systemd ## ## Stop display manager using systemd ##
if systemctl is-active --quiet "display-manager.service"; then if systemctl is-active --quiet "display-manager.service"; then
@@ -81,10 +81,10 @@ function kde-clause {
#################################################################################################################### ####################################################################################################################
if pgrep -l "plasma" | grep "plasmashell"; then if pgrep -l "plasma" | grep "plasmashell"; then
echo "$DATE Display Manager is KDE, running KDE clause!" echo "$DATETIME Display Manager is KDE, running KDE clause!"
kde-clause kde-clause
else else
echo "$DATE Display Manager is not KDE!" echo "$DATETIME Display Manager is not KDE!"
stop_display_manager_if_running stop_display_manager_if_running
fi fi
@@ -109,7 +109,7 @@ do
if test -x /sys/class/vtconsole/vtcon"${i}"; then if test -x /sys/class/vtconsole/vtcon"${i}"; then
if [ "$(grep -c "frame buffer" /sys/class/vtconsole/vtcon"${i}"/name)" = 1 ]; then if [ "$(grep -c "frame buffer" /sys/class/vtconsole/vtcon"${i}"/name)" = 1 ]; then
echo 0 > /sys/class/vtconsole/vtcon"${i}"/bind echo 0 > /sys/class/vtconsole/vtcon"${i}"/bind
echo "$DATE Unbinding Console ${i}" echo "$DATETIME Unbinding Console ${i}"
echo "$i" >> /tmp/vfio-bound-consoles echo "$i" >> /tmp/vfio-bound-consoles
fi fi
fi fi
@@ -118,7 +118,7 @@ done
sleep "1" sleep "1"
if lspci -nn | grep -e VGA | grep -s NVIDIA ; then if lspci -nn | grep -e VGA | grep -s NVIDIA ; then
echo "$DATE System has an NVIDIA GPU" echo "$DATETIME System has an NVIDIA GPU"
grep -qsF "true" "/tmp/vfio-is-nvidia" || echo "true" >/tmp/vfio-is-nvidia grep -qsF "true" "/tmp/vfio-is-nvidia" || echo "true" >/tmp/vfio-is-nvidia
echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
@@ -131,11 +131,11 @@ if lspci -nn | grep -e VGA | grep -s NVIDIA ; then
modprobe -r drm_kms_helper modprobe -r drm_kms_helper
modprobe -r drm modprobe -r drm
echo "$DATE NVIDIA GPU Drivers Unloaded" echo "$DATETIME NVIDIA GPU Drivers Unloaded"
fi fi
if lspci -nn | grep -e VGA | grep -s AMD ; then if lspci -nn | grep -e VGA | grep -s AMD ; then
echo "$DATE System has an AMD GPU" echo "$DATETIME System has an AMD GPU"
grep -qsF "true" "/tmp/vfio-is-amd" || echo "true" >/tmp/vfio-is-amd grep -qsF "true" "/tmp/vfio-is-amd" || echo "true" >/tmp/vfio-is-amd
echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
@@ -145,7 +145,7 @@ if lspci -nn | grep -e VGA | grep -s AMD ; then
modprobe -r radeon modprobe -r radeon
modprobe -r drm modprobe -r drm
echo "$DATE AMD GPU Drivers Unloaded" echo "$DATETIME AMD GPU Drivers Unloaded"
fi fi
## Load VFIO-PCI driver ## ## Load VFIO-PCI driver ##
@@ -153,4 +153,4 @@ modprobe vfio
modprobe vfio_pci modprobe vfio_pci
modprobe vfio_iommu_type1 modprobe vfio_iommu_type1
echo "$DATE End of Startup!" echo "$DATETIME End of Startup!"
+10 -10
View File
@@ -15,7 +15,7 @@
## Void for testing and helping out in general ## ## ## ## Void for testing and helping out in general ## ## ##
## .Chris. for testing and helping out in general ## ## Run this command ## ## .Chris. for testing and helping out in general ## ## Run this command ##
## WORMS for helping out with testing ## ## if you dont have ## ## WORMS for helping out with testing ## ## if you dont have ##
##################################################### ## names in you're ## ##################################################### ## names in your ##
## The VFIO community for using the scripts and ## ## lspci feedback ## ## The VFIO community for using the scripts and ## ## lspci feedback ##
## testing them for us! ## ## in your terminal ## ## testing them for us! ## ## in your terminal ##
##################################################### ####################### ##################################################### #######################
@@ -23,11 +23,11 @@
################################# Variables ################################# ################################# Variables #################################
## Adds current time to var for use in echo for a cleaner log and script ## ## Adds current time to var for use in echo for a cleaner log and script ##
DATE=$(date +"%m/%d/%Y %R:%S :") DATETIME=$(date +"%m/%d/%Y %R:%S :")
################################## Script ################################### ################################## Script ###################################
echo "$DATE Beginning of Teardown!" echo "$DATETIME Beginning of Teardown!"
## Unload VFIO-PCI driver ## ## Unload VFIO-PCI driver ##
modprobe -r vfio_pci modprobe -r vfio_pci
@@ -37,7 +37,7 @@ modprobe -r vfio
if grep -q "true" "/tmp/vfio-is-nvidia" ; then if grep -q "true" "/tmp/vfio-is-nvidia" ; then
## Load NVIDIA drivers ## ## Load NVIDIA drivers ##
echo "$DATE Loading NVIDIA GPU Drivers" echo "$DATETIME Loading NVIDIA GPU Drivers"
modprobe drm modprobe drm
modprobe drm_kms_helper modprobe drm_kms_helper
@@ -47,20 +47,20 @@ if grep -q "true" "/tmp/vfio-is-nvidia" ; then
modprobe nvidia_drm modprobe nvidia_drm
modprobe nvidia_uvm modprobe nvidia_uvm
echo "$DATE NVIDIA GPU Drivers Loaded" echo "$DATETIME NVIDIA GPU Drivers Loaded"
fi fi
if grep -q "true" "/tmp/vfio-is-amd" ; then if grep -q "true" "/tmp/vfio-is-amd" ; then
## Load NVIDIA drivers ## ## Load NVIDIA drivers ##
echo "$DATE Loading AMD GPU Drivers" echo "$DATETIME Loading AMD GPU Drivers"
modprobe drm modprobe drm
modprobe amdgpu modprobe amdgpu
modprobe radeon modprobe radeon
modprobe drm_kms_helper modprobe drm_kms_helper
echo "$DATE AMD GPU Drivers Loaded" echo "$DATETIME AMD GPU Drivers Loaded"
fi fi
## Restart Display Manager ## ## Restart Display Manager ##
@@ -69,7 +69,7 @@ while read -r DISPMGR; do
if command -v systemctl; then if command -v systemctl; then
## Make sure the variable got collected ## ## Make sure the variable got collected ##
echo "$DATE Var has been collected from file: $DISPMGR" echo "$DATETIME Var has been collected from file: $DISPMGR"
systemctl start "$DISPMGR.service" systemctl start "$DISPMGR.service"
@@ -89,11 +89,11 @@ while read -r consoleNumber; do
if test -x /sys/class/vtconsole/vtcon"${consoleNumber}"; then if test -x /sys/class/vtconsole/vtcon"${consoleNumber}"; then
if [ "$(grep -c "frame buffer" "/sys/class/vtconsole/vtcon${consoleNumber}/name")" \ if [ "$(grep -c "frame buffer" "/sys/class/vtconsole/vtcon${consoleNumber}/name")" \
= 1 ]; then = 1 ]; then
echo "$DATE Rebinding console ${consoleNumber}" echo "$DATETIME Rebinding console ${consoleNumber}"
echo 1 > /sys/class/vtconsole/vtcon"${consoleNumber}"/bind echo 1 > /sys/class/vtconsole/vtcon"${consoleNumber}"/bind
fi fi
fi fi
done < "$input" done < "$input"
echo "$DATE End of Teardown!" echo "$DATETIME End of Teardown!"
+8 -8
View File
@@ -8,13 +8,13 @@ if test -e /etc/libvirt/hooks/qemu;
then then
mv /etc/libvirt/hooks/qemu /etc/libvirt/hooks/qemu_last_backup mv /etc/libvirt/hooks/qemu /etc/libvirt/hooks/qemu_last_backup
fi fi
if test -e /usr/local/bin/vfio-startup; if test -e /bin/vfio-startup.sh;
then then
mv /usr/local/bin/vfio-startup /usr/local/bin/vfio-startup.bkp mv /bin/vfio-startup.sh /bin/vfio-startup.sh.bkp
fi fi
if test -e /usr/local/bin/vfio-teardown; if test -e /bin/vfio-teardown.sh;
then then
mv /usr/local/bin/vfio-teardown /usr/local/bin/vfio-teardown.bkp mv /bin/vfio-teardown.sh /bin/vfio-teardown.sh.bkp
fi fi
if test -e /etc/systemd/system/libvirt-nosleep@.service; if test -e /etc/systemd/system/libvirt-nosleep@.service;
then then
@@ -22,10 +22,10 @@ then
fi fi
cp systemd-no-sleep/libvirt-nosleep@.service /etc/systemd/system/libvirt-nosleep@.service cp systemd-no-sleep/libvirt-nosleep@.service /etc/systemd/system/libvirt-nosleep@.service
cp hooks/vfio-startup /usr/local/bin/vfio-startup cp hooks/vfio-startup.sh /bin/vfio-startup.sh
cp hooks/vfio-teardown /usr/local/bin/vfio-teardown cp hooks/vfio-teardown.sh /bin/vfio-teardown.sh
cp hooks/qemu /etc/libvirt/hooks/qemu cp hooks/qemu /etc/libvirt/hooks/qemu
chmod +x /usr/local/bin/vfio-startup chmod +x /bin/vfio-startup.sh
chmod +x /usr/local/bin/vfio-teardown chmod +x /bin/vfio-teardown.sh
chmod +x /etc/libvirt/hooks/qemu chmod +x /etc/libvirt/hooks/qemu