Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
VFIO Setup Scripts
#!/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
#!/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'
@qubitrenegade

This comment has been minimized.

Copy link
Owner Author

@qubitrenegade qubitrenegade commented Jul 17, 2019

The echo statements in vfio-pci-override.sh are really unnecessary, but they do enable a user to run it and see what it's trying to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment