diff --git a/lib/get_GPU_GROUP.sh b/lib/get_GPU_GROUP.sh index 1f0e05b..dc051b1 100755 --- a/lib/get_GPU_GROUP.sh +++ b/lib/get_GPU_GROUP.sh @@ -20,38 +20,39 @@ Optionally it may also include: exec "$SCRIPTDIR/utils/ls-iommu" | grep -i "group $1" | cut -d " " -f 1-4,8- | perl -pe "s/\[[0-9a-f]{4}\]: //" echo "#------------------------------------------#" -printf " + printf " 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 anything. " -read -p "Do you want to use these devices for passthrough? [y/N]: " YESNO + read -p "Do you want to use these devices for passthrough? [y/N]: " YESNO -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/") + 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/") - # 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$//") + # 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) + # 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=() " > "$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) - - # 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" -fi + # Get the PCI_ID + 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" + + # Start setting up modules + exec "$SCRIPTDIR/lib/set_MODULES.sh" $GPU_DEVID + ;; + *) + exec "$SCRIPTDIR/lib/get_GPU.sh" + ;; + esac } function main () { diff --git a/lib/get_USB_CTL_GROUP.sh b/lib/get_USB_CTL_GROUP.sh index ca7d2f9..b6999e3 100755 --- a/lib/get_USB_CTL_GROUP.sh +++ b/lib/get_USB_CTL_GROUP.sh @@ -20,20 +20,21 @@ To use any of the devices shown for passthrough, all of them have to be passed t To return to the previous page just press ENTER. " -read -p "Do you want to use the displayed devices for passthrough? [y/N]: " YESNO - -if [[ ${YESNO} =~ [Yy]* ]]; -then - # 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$//") - - # 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" - exec "$SCRIPTDIR/lib/set_CMDLINE.sh" -else - exec "$SCRIPTDIR/lib/get_USB_CTL.sh" -fi + read -p "Do you want to use the displayed devices for passthrough? [y/N]: " YESNO + case "${YESNO}" in + [Yy]*) + # 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$//") + + # 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" + exec "$SCRIPTDIR/lib/set_CMDLINE.sh" + ;; + *) + exec "$SCRIPTDIR/lib/get_USB_CTL.sh" + ;; + esac } function main () {