Merge "SRIOV: Limit number of vfs to n-1 created by default"

This commit is contained in:
Zuul 2018-10-01 07:25:40 +00:00 committed by Gerrit Code Review
commit 0f6b734946
1 changed files with 13 additions and 1 deletions

View File

@ -22,7 +22,19 @@ set -ex
if [ "x{{ $sriov.num_vfs }}" != "x" ]; then
echo "{{ $sriov.num_vfs }}" > /sys/class/net/{{ $sriov.device }}/device/sriov_numvfs
else
NUM_VFS=$(cat /sys/class/net/{{ $sriov.device }}/device/sriov_totalvfs)
#NOTE(portdirect): Many NICs have difficulty creating more than n-1 over their
# claimed limit, by default err on the side of caution and account for this
# limitation.
TOT_NUM_VFS=$(cat /sys/class/net/{{ $sriov.device }}/device/sriov_totalvfs)
if [[ "$TOT_NUM_VFS" -le "0" ]]; then
NUM_VFS="$TOT_NUM_VFS"
else
if [[ "$((TOT_NUM_VFS - 1 ))" -le "1" ]]; then
NUM_VFS=1
else
NUM_VFS="$((TOT_NUM_VFS - 1 ))"
fi
fi
echo "${NUM_VFS}" > /sys/class/net/{{ $sriov.device }}/device/sriov_numvfs
fi
{{- if $sriov.mtu }}