#!/bin/bash
# shellcheck disable=SC2002,SC2164

# Get the scripts directory
SCRIPTDIR=$(dirname "$(which "$0")")
cd "$SCRIPTDIR"

# If there is a config generated, then $SCRIPTDIR/config/kernel_args
# should exist, which contains all the info we need
if [ -f "$SCRIPTDIR/config/kernel_args" ];
then
    echo "#------------------------------------------#"
    # List info about the vfio gpu and what kernel driver is being used
    "$SCRIPTDIR/utils/ls-iommu" -g -r -k
    echo "#------------------------------------------#"

    printf "
If the \"Kernel driver in use\" for the passed through devices are \"vfio-pci\", then VFIO has been successfully enabled!
GPU Devices using \"pcieport\" can be ignored.

NOTE: If your system freezes when starting a VM that uses your VFIO enabled card..
consider adding the below line to your bootloaders kernel arguments:
vfio_pci.disable_vga=1

That will disable video output from the card while it is connected to the Linux host.
"

else
    # Tell user to run the setup first if the kernel_args file is not found
    echo "Please run \"$SCRIPTDIR/vfio-setup\" first!"

fi