-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathqemu
executable file
·63 lines (47 loc) · 1.18 KB
/
qemu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# Define virtual machine names here
gpu_domains=(
gpu
)
function gpu_begin {
set -x
device=$(lspci -nnD | grep "VGA compatible controller" | grep Intel)
# Stop display manager
systemctl stop display-manager.service
# Unbind vtconsole
for i in /sys/class/vtconsole/*/bind; do
echo 0 > "$i"
done
# Kill pulseaudio
killall pulseaudio
# Unbind GPU
echo "$device" | cut -d' ' -f1 > /sys/module/i915/drivers/pci:i915/unbind
# Unload modules
rmmod snd_hda_intel
rmmod i915
# Load vfio
modprobe vfio-pci ids="$(echo "$device" | grep -o 8086:....)"
}
function gpu_end {
set -x
# Unload vfio
rmmod vfio_pci
# Load modules
modprobe snd_hda_intel
modprobe i915
# Rebind vtconsole
for i in /sys/class/vtconsole/*/bind; do
echo 1 > "$i"
done
# Start display manager
systemctl start display-manager.service
}
# Run only for gpu_domains
for d in "${gpu_domains[@]}"; do
[ "$d" = "$1" ] && gpu_domain=true
done
if [ "$gpu_domain" = true ]; then
[ "$2" = prepare ] && [ "$3" = begin ] && gpu_begin
[ "$2" = release ] && [ "$3" = end ] && gpu_end
fi
true