Last active
July 17, 2019 03:16
-
-
Save qubitrenegade/2ff70cc63346a09c2374262e1075564c to your computer and use it in GitHub Desktop.
VFIO Setup Scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -u | |
for boot_vga in /sys/bus/pci/devices/*/boot_vga; do | |
echo "Found vga device: ${boot_vga}" | |
if [ $(<"${boot_vga}") -eq 0 ]; then | |
echo "Found Boot VGA Device - false: ${boot_vga}" | |
dir=$(dirname -- "${boot_vga}") | |
for dev in "${dir::-1}"*; do | |
echo "Registering Devices: ${dev}" | |
echo 'vfio-pci' > "${dev}/driver_override" | |
done | |
else | |
echo "Found Boot VGA Device - true: ${boot_vga}" | |
fi | |
done | |
modprobe -i vfio-pci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
grep='grep --color=always -i' | |
echo 'Looking for `iommu` messages' | |
dmesg | ${grep} -e iommu | |
printf '\n\n\nLooking for `vfio` messages\n' | |
dmesg | ${grep} -e vfio | |
printf '\n\n\nGrub commandline\n' | |
${grep} -e vfio -e iommu /proc/cmdline | |
printf '\n\n' | |
for boot_vga in /sys/bus/pci/devices/*/boot_vga; do | |
printf "\nFound VGA device: ${boot_vga}\n" | |
if [ $(<"${boot_vga}") -eq 0 ]; then | |
echo 'Found non-boot VGA device, dumping `lspci -nnks`' | |
dev_group=$(basename -- $(dirname -- "${boot_vga}")) | |
dev_group=${dev_group::-2} | |
echo "dev_group: ${dev_group}" | |
lspci -nnks "${dev_group}" | ${grep} -z 'Kernel driver in use:' | |
else | |
echo "Device ${boot_vga} not passed through" | |
fi | |
done | |
printf '\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
echo
statements invfio-pci-override.sh
are really unnecessary, but they do enable a user to run it and see what it's trying to do.