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 "#------------------------------------------#" echo "#------------------------------------------#"
printf " 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\" To use any of these devices for passthrough ALL of them has to be passed through to the VMs\
NOTE: The device ID is the part inside the last [] brackets, example: [1002:aaf0]
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 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 # 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$//") 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 # Write the GPU_PCI_IDs to the config that quickemu might make use of in the future
printf "GPU_PCI_ID=($PCI_ID) printf "GPU_PCI_ID=($PCI_ID)
USB_CTL_ID=\"\" USB_CTL_ID=()
" > "$SCRIPTDIR/$QUICKEMU/qemu-vfio_vars.conf" " > "$SCRIPTDIR/$QUICKEMU/qemu-vfio_vars.conf"
# Get the PCI_ID # Get the PCI_ID
local ROM_PCI_ID=$($SCRIPTDIR/utils/ls-iommu | grep -i "vga" | grep -i "group $1" | cut -d " " -f 4) local ROM_PCI_ID=$($SCRIPTDIR/utils/ls-iommu | grep -i "vga" | grep -i "group $1" | cut -d " " -f 4)
# Get the GPU ROM
"$SCRIPTDIR/lib/get_GPU_ROM.sh" "$ROM_PCI_ID" "$SCRIPTDIR/lib/get_GPU_ROM.sh" "$ROM_PCI_ID"
# Start setting up modules
exec "$SCRIPTDIR/lib/set_MODULES.sh" $GPU_DEVID exec "$SCRIPTDIR/lib/set_MODULES.sh" $GPU_DEVID
else else
exec "$SCRIPTDIR/lib/get_GPU.sh" exec "$SCRIPTDIR/lib/get_GPU.sh"

View file

@ -7,6 +7,8 @@ function get_USB_CTL_GROUP () {
printf " printf "
For this USB controller device to be passthrough-able, it must be the ONLY device in this group! For this USB controller device to be passthrough-able, it must be the ONLY device in this group!
Passing through more than just the USB controller can in some cases cause system issues
if you do not know what you are doing.
" "
echo "#------------------------------------------#" echo "#------------------------------------------#"
@ -14,20 +16,19 @@ For this USB controller device to be passthrough-able, it must be the ONLY devic
echo "#------------------------------------------#" echo "#------------------------------------------#"
printf " printf "
To use this device for passthrough please type in the device id in the format (without brackets or quotes) --> \"xxxx:yyyy\" To use any of the devices shown for passthrough, all of them have to be passed through
NOTE: The device ID is the part inside the last [] brackets, example: [1002:aaf0]
To return to the previous page just press ENTER without typing in any ids To return to the previous page just press ENTER.
" "
read -p "Enter the id for the device you want to passthrough: " USB_CTL_DEVID read -p "Do you want to use the displayed devices for passthrough? [y/N]: " YESNO
if [[ $USB_CTL_DEVID =~ : ]]; if [[ ${YESNO} =~ [Yy]* ]];
then then
# Get the PCI ids # Get the PCI ids
local PCI_ID=$($SCRIPTDIR/utils/ls-iommu | grep -i "group $1" | cut -d " " -f 4) local PCI_ID=$($SCRIPTDIR/utils/ls-iommu | grep -i "group $1" | cut -d " " -f 4 | perl -pe "s/\n/ /" | perl -pe "s/\s$//")
# Replace the blank USB_CTL_ID with the PCI_ID for the usb controller the user wants to pass through # Replace the blank USB_CTL_ID with the PCI_ID for the usb controller the user wants to pass through
perl -pi -e "s/USB_CTL_ID=\"\"/USB_CTL_ID=\"$PCI_ID\"/" "$SCRIPTDIR/$QUICKEMU/qemu-vfio_vars.conf" perl -pi -e "s/USB_CTL_ID=\(\)/USB_CTL_ID=\($PCI_ID\)/" "$SCRIPTDIR/$QUICKEMU/qemu-vfio_vars.conf"
exec "$SCRIPTDIR/lib/set_CMDLINE.sh" exec "$SCRIPTDIR/lib/set_CMDLINE.sh"
else else
exec "$SCRIPTDIR/lib/get_USB_CTL.sh" exec "$SCRIPTDIR/lib/get_USB_CTL.sh"