mirror of
https://gitlab.com/risingprismtv/single-gpu-passthrough.git
synced 2024-12-22 13:45:22 +00:00
Systemd no sleep
This commit is contained in:
parent
c3d42f3a01
commit
432715a83c
@ -2,9 +2,12 @@
|
|||||||
|
|
||||||
Scripts for passing a single GPU from a Linux host to a Windows VM and back.
|
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.
|
1. Change the VM name in qemu if not already win10
|
||||||
2. Change the VM name in qemu if not already win10
|
2. Run the install_hooks.sh script as root
|
||||||
3. Run the install.sh script as root
|
|
||||||
|
Note the PCI ids and display manager should be detected automatically. If you are using an unsupported display manager that is not listed in the hooks/vfio-startup.sh script, feel free to contact us on the Discord server and we shall add your display manager.
|
||||||
|
|
||||||
|
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 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
|
||||||
|
|
||||||
|
20
hooks/qemu
Executable file
20
hooks/qemu
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
OBJECT="$1"
|
||||||
|
OPERATION="$2"
|
||||||
|
|
||||||
|
if [[ $OBJECT == "win10" ]]; then
|
||||||
|
case "$OPERATION" in
|
||||||
|
"prepare")
|
||||||
|
systemctl start libvirt-nosleep@"$OBJECT" 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")
|
||||||
|
systemctl stop libvirt-nosleep@"$OBJECT" 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
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
13
install.sh
13
install.sh
@ -1,13 +0,0 @@
|
|||||||
#!/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-teardown.sh
|
|
||||||
chmod +x /etc/libvirt/hooks/qemu
|
|
22
install_hooks.sh
Executable file
22
install_hooks.sh
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
if test -e /etc/libvirt/hooks/qemu then
|
||||||
|
mv /etc/libvirt/hooks/qemu /etc/libvirt/hooks/qemu_last_backup
|
||||||
|
fi
|
||||||
|
if test -e /bin/vfio-startup.sh then
|
||||||
|
mv /bin/vfio-startup.sh /bin/vfio-startup.sh.bkp
|
||||||
|
fi
|
||||||
|
if test -e /bin/vfio-teardown.sh then
|
||||||
|
mv /bin/vfio-teardown.sh /bin/vfio-teardown.sh.bkp
|
||||||
|
fi
|
||||||
|
if test -e /etc/systemd/system/libvirt-nosleep@.service then
|
||||||
|
rm /etc/systemd/system/libvirt-nosleep@.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp systemd-no-sleep/libvirt-nosleep@.service /etc/systemd/system/libvirt-nosleep@.service
|
||||||
|
cp hooks/vfio-startup.sh /bin/vfio-startup.sh
|
||||||
|
cp hooks/vfio-teardown.sh /bin/vfio-teardown.sh
|
||||||
|
cp hooks/qemu /etc/libvirt/hooks/qemu
|
||||||
|
|
||||||
|
chmod +x /bin/vfio-startup.sh
|
||||||
|
chmod +x /bin/vfio-teardown.sh
|
||||||
|
chmod +x /etc/libvirt/hooks/qemu
|
13
qemu
13
qemu
@ -1,13 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Script for win10
|
|
||||||
if [[ $1 == "win10" ]]; then
|
|
||||||
if [[ $2 == "prepare" ]]; then
|
|
||||||
/bin/vfio-startup.sh 2>&1 | tee -a /var/log/libvirt/custom_hooks.log
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $2 == "release" ]]; then
|
|
||||||
/bin/vfio-teardown.sh 2>&1 | tee -a /var/log/libvirt/custom_hooks.log
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
6
systemd-no-sleep/libvirt-nosleep@.service
Executable file
6
systemd-no-sleep/libvirt-nosleep@.service
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Preventing sleep while libvirt domain "%i" is running
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/bin/systemd-inhibit --what=sleep --why="Libvirt domain \"%i\" is running" --who=%U --mode=block sleep infinity
|
Loading…
Reference in New Issue
Block a user