Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- if [ "$2" == "prepare" ]; then
- if [ "$1" == "win10-vgpu" ]; then
- virsh nodedev-start mdev_d5e23cdc_7dfd_4bf7_8446_7da1b011cc71_0000_06_00_0
- elif [ "$1" == "win10-school-vgpu" ]; then
- virsh nodedev-start mdev_54f0bb75_cdef_4718_b45f_8640f6504789_0000_06_00_0
- elif [ "$1" == "win7-vgpu" ]; then
- virsh nodedev-start mdev_8a5f743b_aa48_41e5_a2cb_627c880de856_0000_06_00_0
- fi
- fi
- if [[ "$1" == *-dgpu ]] && [ "$2" == "prepare" ]; then
- echo "nvidia kill" >> /log.txt
- virsh destroy win10-vgpu || true
- virsh destroy win10-school-vgpu || true
- sleep 2s
- virsh nodedev-destroy mdev_8a5f743b_aa48_41e5_a2cb_627c880de856_0000_06_00_0
- virsh nodedev-destroy mdev_54f0bb75_cdef_4718_b45f_8640f6504789_0000_06_00_0
- virsh nodedev-destroy mdev_d5e23cdc_7dfd_4bf7_8446_7da1b011cc71_0000_06_00_0
- sleep 3s
- systemctl stop nvidia-vgpu{d,-mgr}
- sleep 1s
- rmmod nvidia_vgpu_vfio
- systemctl stop lightdm
- sleep 1s
- rmmod nvidia_drm nvidia_modeset nvidia_uvm
- sleep 1s
- rmmod nvidia
- sleep 1s
- fi
- if [[ $(basename -s "-vgpu" $(basename -s "-dgpu" "$1")) =~ ^(win10|win10-school|win7)$ ]] && [ "$2" == "prepare" ]; then
- echo "memory drop" >> /log.txt
- swapoff --all
- echo 1 > /proc/sys/vm/drop_caches
- echo 2 > /proc/sys/vm/drop_caches
- echo 3 > /proc/sys/vm/drop_caches
- echo 1 > /proc/sys/vm/compact_memory
- sleep 4s
- swapon --all
- fi
- if [ "$2" == "prepare" ]; then
- echo "allocate hugepages" >> /log.txt
- sysctl -e vm.nr_hugepages=4096
- if [[ "$1" =~ ^(win10-vgpu,win7-vgpu)$ ]]; then
- echo "cpu pin vgpu" >> /log.txt
- systemctl set-property --runtime -- user.slice AllowedCPUs=0-4,9-16
- systemctl set-property --runtime -- system.slice AllowedCPUs=0-4,9-16
- systemctl set-property --runtime -- init.scope AllowedCPUs=0-4,9-16
- elif [[ "$1" =~ ^(win10-dgpu,win7-dgpu)$ ]]; then
- echo "cpu pin dgpu" >> /log.txt
- systemctl set-property --runtime -- user.slice AllowedCPUs=0-4
- systemctl set-property --runtime -- system.slice AllowedCPUs=0-4
- systemctl set-property --runtime -- init.scope AllowedCPUs=0-4
- fi
- fi
- if [[ "$1" == *-vgpu ]]; then
- if [ "$2" == "prepare" ]; then
- echo "create lg ivshmem" >> /log.txt
- touch "/dev/shm/looking-glass-$1" || true
- chown samicrusader:kvm "/dev/shm/looking-glass-$1"
- chmod 660 "/dev/shm/looking-glass-$1"
- elif [ "$2" == "started" ]; then
- if [ ${1%"-vgpu"} == "win10" ]; then
- export title="Kurome (Windows 10)"
- elif [ ${1%"-vgpu"} == "win10-school" ]; then
- export title="School (Windows 10)"
- elif [ ${1%"-vgpu"} == "win7" ]; then
- export title="Uzume (Windows 7)"
- fi
- echo "start lg $title" >> /log.txt
- export $(xpub); su "$XUSER" -c "screen -dmL -Logfile /home/samicrusader/lg.log looking-glass-client app:shmFile=\"/dev/shm/looking-glass-$1\" win:title=\"$title\" win:autoResize=yes win:keepAspect=yes win:dontUpscale=yes win:shrinkOnUpscale=no win:autoScreensaver=yes win:quickSplash=yes win:uiFont=\"Koruri\" win:uiSize=12 input:escapeKey=KEY_INSERT input:rawMouse=yes spice:host=\"/tmp/$1.sock\" spice:port=0 spice:alwaysShowCursor=yes spice:showCursorDot=no" || true
- fi
- fi
- if [ "$2" == "release" ]; then
- echo "unallocate hugepages" >> /log.txt
- sysctl -e vm.nr_hugepages=0
- echo "release cpu" >> /log.txt
- systemctl set-property --runtime -- user.slice AllowedCPUs=0-23
- systemctl set-property --runtime -- system.slice AllowedCPUs=0-23
- systemctl set-property --runtime -- init.scope AllowedCPUs=0-23
- if [ "$1" == "win10-vgpu" ]; then
- virsh nodedev-destroy mdev_d5e23cdc_7dfd_4bf7_8446_7da1b011cc71_0000_06_00_0
- elif [ "$1" == "win10-school-vgpu" ]; then
- virsh nodedev-destroy mdev_54f0bb75_cdef_4718_b45f_8640f6504789_0000_06_00_0
- elif [ "$1" == "win7-vgpu" ]; then
- virsh nodedev-destroy mdev_8a5f743b_aa48_41e5_a2cb_627c880de856_0000_06_00_0
- fi
- if [[ "$1" == *-dgpu ]]; then
- echo "release nvidia" >> /log.txt
- modprobe nvidia
- sleep 1s
- modprobe nvidia_drm nvidia_modeset nvidia_uvm
- sleep 3s
- modprobe nvidia_vgpu_vfio
- sleep 2s
- systemctl start nvidia-vgpu{d,-mgr}
- systemctl start lightdm
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement