remove the need to manually type in hardware ids, just grab all hardware ids in the IOMMU group

This commit is contained in:
HikariKnight 2022-02-28 19:28:06 +01:00
parent 6943718542
commit 0127f0bc86
No known key found for this signature in database
GPG key ID: E8B239063B022F5A
2 changed files with 20 additions and 14 deletions

View file

@ -21,27 +21,32 @@ Optionally it may also include:
echo "#------------------------------------------#"
printf "
To use these devices for passthrough please type in ALL their device ids in the format (without brackets or quotes) --> \"xxxx:yyyy,xxxx:yyyy\"
NOTE: The device ID is the part inside the last [] brackets, example: [1002:aaf0]
To use any of these devices for passthrough ALL of them has to be passed through to the VMs\
To return to the previous page just press ENTER without typing in any ids
To return to the previous page just press ENTER without typing in anything.
"
read -p "Enter the ids for all devices you want to passthrough: " GPU_DEVID
read -p "Do you want to use these devices for passthrough? [y/N]: " YESNO
if [[ $GPU_DEVID =~ : ]];
if [[ ${YESNO} =~ [Yy]* ]];
then
# 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/")
# 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$//")
# 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=\"\"
USB_CTL_ID=()
" > "$SCRIPTDIR/$QUICKEMU/qemu-vfio_vars.conf"
# Get the PCI_ID
local ROM_PCI_ID=$($SCRIPTDIR/utils/ls-iommu | grep -i "vga" | grep -i "group $1" | cut -d " " -f 4)
"$SCRIPTDIR/lib/get_GPU_ROM.sh" "$ROM_PCI_ID"
# 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
else
exec "$SCRIPTDIR/lib/get_GPU.sh"