setup.sh: replace username param with TARGET_USER env variable

Make it configurable the same way as other options.
setup.sh will configure hugepages and vfio for the
current user by default. To specify other user,
set TARGET_USER variable.

Change-Id: Ib98178a70a007bec761f7465689c2150e8844ffb
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/394806
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2018-01-15 20:08:37 +01:00 committed by Jim Harris
parent 4041ab04fb
commit da7e3bb880

View File

@ -39,8 +39,8 @@ function linux_bind_driver() {
iommu_group=$(basename $(readlink -f /sys/bus/pci/devices/$bdf/iommu_group)) iommu_group=$(basename $(readlink -f /sys/bus/pci/devices/$bdf/iommu_group))
if [ -e "/dev/vfio/$iommu_group" ]; then if [ -e "/dev/vfio/$iommu_group" ]; then
if [ "$username" != "" ]; then if [ -z "$TARGET_USER" ]; then
chown "$username" "/dev/vfio/$iommu_group" chown "$TARGET_USER" "/dev/vfio/$iommu_group"
fi fi
fi fi
} }
@ -192,8 +192,8 @@ function configure_linux {
fi fi
if [ "$driver_name" = "vfio-pci" ]; then if [ "$driver_name" = "vfio-pci" ]; then
if [ "$username" != "" ]; then if [ -z "$TARGET_USER" ]; then
chown "$username" "$hugetlbfs_mount" chown "$TARGET_USER" "$hugetlbfs_mount"
chmod g+w "$hugetlbfs_mount" chmod g+w "$hugetlbfs_mount"
fi fi
@ -371,30 +371,24 @@ function reset_freebsd {
fi fi
} }
username=$1 mode=$1
mode=$2
if [ "$username" = "reset" -o "$username" = "config" -o "$username" = "status" ]; then if [ -z "$mode" ]; then
mode="$username"
username=""
fi
if [ "$mode" == "" ]; then
mode="config" mode="config"
fi fi
if [ "$username" = "" ]; then
username="$SUDO_USER"
if [ "$username" = "" ]; then
username=`logname 2>/dev/null` || true
fi
fi
: ${HUGEMEM:=2048} : ${HUGEMEM:=2048}
: ${SKIP_PCI:=0} : ${SKIP_PCI:=0}
: ${NVME_WHITELIST:=""} : ${NVME_WHITELIST:=""}
declare -a NVME_WHITELIST=(${NVME_WHITELIST}) declare -a NVME_WHITELIST=(${NVME_WHITELIST})
if [ -z "$TARGET_USER" ]; then
TARGET_USER="$SUDO_USER"
if [ -z "$TARGET_USER" ]; then
TARGET_USER=`logname 2>/dev/null` || true
fi
fi
if [ `uname` = Linux ]; then if [ `uname` = Linux ]; then
HUGEPGSZ=$(( `grep Hugepagesize /proc/meminfo | cut -d : -f 2 | tr -dc '0-9'` )) HUGEPGSZ=$(( `grep Hugepagesize /proc/meminfo | cut -d : -f 2 | tr -dc '0-9'` ))
HUGEPGSZ_MB=$(( $HUGEPGSZ / 1024 )) HUGEPGSZ_MB=$(( $HUGEPGSZ / 1024 ))