Add 'examples/shell/qemu/prepareintelgpupassthrough.sh'

This commit is contained in:
Jakub Filo 2021-09-09 21:13:20 +00:00
parent c6bf016745
commit 64b0d1cc64

View File

@ -0,0 +1,40 @@
#!/bin/bash
set -e
function stopvt() {
echo "Stopping virtual terminals"
for i in /sys/class/vtconsole/*/bind
do
echo 0 >$i
done
}
function stopsound() {
echo "Stopping Intel HDA sound"
for i in /sys/module/snd_hda_intel/drivers/pci\:snd_hda_intel/*/remove
do
echo 1 >$i
done
}
function removemod() {
echo "Waiting for everything to settle down"
sleep 0.5
echo "Removing modules"
rmmod snd_hda_intel
rmmod i915
}
function probepci() {
devicestring="$(lspci -nn | grep "VGA compatible")"
pciid="$(echo "$devicestring" | grep -o "8086:....")"
pciaddr="$(echo "$devicestring" | cut -f 1 -d " ")"
modprobe vfio-pci ids=$pciid
echo "Probed: $devicestring"
echo "run qemu with -device vfio-pci,host=$pciaddr"
}
stopvt
stopsound
removemod
probepci