quickpassthrough/lib/get_GPU_GROUP.sh

65 lines
2 KiB
Bash
Raw Normal View History

2022-02-26 18:10:21 -05:00
#!/bin/bash
function get_GROUP () {
clear
2022-02-27 11:18:59 -05:00
# Get the config paths
source "$SCRIPTDIR/lib/paths.sh"
2022-02-26 18:10:21 -05:00
printf "
For this card to be passthrough-able, it must contain only:
* The GPU/Graphic card
* The GPU Audio Controller
Optionally it may also include:
* GPU USB Host Controller
* GPU Serial Port
* GPU USB Type-C UCSI Controller
"
echo "#------------------------------------------#"
exec "$SCRIPTDIR/utils/ls-iommu" | grep -i "group $1" | cut -d " " -f 1-4,8- | perl -pe "s/\[[0-9a-f]{4}\]: //"
echo "#------------------------------------------#"
2022-02-28 14:30:08 -05:00
printf "
To use any of these devices for passthrough ALL of them has to be passed through to the VMs\
2022-02-26 18:10:21 -05:00
To return to the previous page just press ENTER without typing in anything.
2022-02-26 18:10:21 -05:00
"
2022-02-28 14:30:08 -05:00
read -p "Do you want to use these devices for passthrough? [y/N]: " YESNO
2022-02-26 18:10:21 -05:00
2022-02-28 14:30:08 -05:00
case "${YESNO}" in
[Yy]*)
# Get the hardware ids from the selected group
local GPU_DEVID=$($SCRIPTDIR/utils/ls-iommu | grep -i "group $1" | perl -pe "s/.+\[([0-9a-f]{4}:[0-9a-f]{4})\].+/\1/" | perl -pe "s/\n/,/" | perl -pe "s/,$/\n/")
2022-02-28 14:30:08 -05:00
# Get the PCI ids
local PCI_ID=$($SCRIPTDIR/utils/ls-iommu | grep -i "group $1" | cut -d " " -f 4 | perl -pe "s/\n/ /" | perl -pe "s/\s$//")
2022-02-26 18:10:21 -05:00
2022-02-28 14:30:08 -05:00
# Write the GPU_PCI_IDs to the config that quickemu might make use of in the future
printf "GPU_PCI_ID=($PCI_ID)
USB_CTL_ID=()
2022-02-27 13:06:07 -05:00
" > "$SCRIPTDIR/$QUICKEMU/qemu-vfio_vars.conf"
2022-02-27 11:18:59 -05:00
2022-02-28 14:30:08 -05:00
# Get the PCI_ID
local ROM_PCI_ID=$($SCRIPTDIR/utils/ls-iommu | grep -i "vga" | grep -i "group $1" | cut -d " " -f 4)
2022-02-26 18:10:21 -05:00
2022-02-28 14:30:08 -05:00
# Get the GPU ROM
"$SCRIPTDIR/lib/get_GPU_ROM.sh" "$ROM_PCI_ID"
# Start setting up modules
exec "$SCRIPTDIR/lib/set_MODULES.sh" $GPU_DEVID
;;
*)
exec "$SCRIPTDIR/lib/get_GPU.sh"
;;
esac
2022-02-26 18:10:21 -05:00
}
function main () {
2022-02-27 11:18:59 -05:00
SCRIPTDIR=$(dirname `which $0` | perl -pe "s/\/\.\.\/lib//")
2022-02-26 18:10:21 -05:00
SCRIPTDIR="$SCRIPTDIR/.."
2022-02-27 11:18:59 -05:00
2022-02-26 18:10:21 -05:00
get_GROUP $1
}
main $1