X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=ta%2Fcaas-danm.git;a=blobdiff_plain;f=docker-build%2Fsriovdp%2Finit.sh;fp=docker-build%2Fsriovdp%2Finit.sh;h=e19ce37683e1e0cb4a860e06f025194f51b52d07;hp=0000000000000000000000000000000000000000;hb=e8fc0ecf1b3b3dd90d306fad208e2e2f7f243ba6;hpb=4b2ffa5ec4e454939b7e887f30f11c8aa6c52a82 diff --git a/docker-build/sriovdp/init.sh b/docker-build/sriovdp/init.sh new file mode 100755 index 0000000..e19ce37 --- /dev/null +++ b/docker-build/sriovdp/init.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Copyright 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +while true; do + date + err=0 + + rootdevs=`jq -r .resourceList[].rootDevices[] /dev/null` + if [[ -n "$rootdevs" ]]; then + for pci in $rootdevs; do + vf=`cat /sys/bus/pci/devices/0000:$pci/sriov_numvfs` + echo "$pci: $vf VFs" + if [[ -z "$vf" || "$vf" == "0" ]]; then + echo "No VFs found -> SR-IOV DP cannot be started" + err=1 + fi + done + else + echo "No SR-IOV designated PF found -> SR-IOV DP cannot be started" + err=1 + fi + + if [ $err -eq 0 ]; then + exit 0 + else + echo "Error happened -> sleep 10 -> retry" + sleep 10 + fi +done