From 64b0d1cc646f793e219d5a8f974a9b09e8fc05c7 Mon Sep 17 00:00:00 2001 From: Jakub Filo Date: Thu, 9 Sep 2021 21:13:20 +0000 Subject: [PATCH] Add 'examples/shell/qemu/prepareintelgpupassthrough.sh' --- .../shell/qemu/prepareintelgpupassthrough.sh | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 examples/shell/qemu/prepareintelgpupassthrough.sh diff --git a/examples/shell/qemu/prepareintelgpupassthrough.sh b/examples/shell/qemu/prepareintelgpupassthrough.sh new file mode 100644 index 0000000..2a7ebf2 --- /dev/null +++ b/examples/shell/qemu/prepareintelgpupassthrough.sh @@ -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