From 2fc17f530a6fe38c27776fca6c88bf45903d17e4 Mon Sep 17 00:00:00 2001 From: Shital Savekar Date: Wed, 7 Jun 2017 13:54:30 +0000 Subject: [PATCH] Update: A temporary workaround for SRIOV on Ubuntu. --- TestLibs/LISALibrary.psm1 | 18 +++++++++++++++++- remote-scripts/ConfigureSRIOV-workaround.sh | 13 +++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 remote-scripts/ConfigureSRIOV-workaround.sh diff --git a/TestLibs/LISALibrary.psm1 b/TestLibs/LISALibrary.psm1 index 0062c0e..6767dd7 100644 --- a/TestLibs/LISALibrary.psm1 +++ b/TestLibs/LISALibrary.psm1 @@ -366,6 +366,7 @@ function EnableSRIOVInAllVMs($allVMData) $packageInstallJobs = @() $sriovDetectedCount = 0 $vmCount = 0 + foreach ( $vmData in $allVMData ) { $vmCount += 1 @@ -375,7 +376,22 @@ function EnableSRIOVInAllVMs($allVMData) $pciDevices = RunLinuxCmd -ip $vmData.PublicIP -port $vmData.SSHPort -username $user -password $password -command "lspci" -runAsSudo if ( $pciDevices -imatch "Mellanox") { - LogMsg "Mellanox Adapter detected in $($vmData.RoleName). Now executing $scriptName ..." + LogMsg "Mellanox Adapter detected in $($vmData.RoleName)." + #SRIOV-Workaround for Ubuntu. + RemoteCopy -uploadTo $vmData.PublicIP -port $vmData.SSHPort -files ".\remote-scripts\ConfigureSRIOV-workaround.sh" -username $user -password $password -upload + $out = RunLinuxCmd -ip $vmData.PublicIP -port $vmData.SSHPort -username $user -password $password -command "chmod +x ConfigureSRIOV-workaround.sh" -runAsSudo + $isRestartNeeded="" + $isRestartNeeded= RunLinuxCmd -ip $vmData.PublicIP -port $vmData.SSHPort -username $user -password $password -command "./ConfigureSRIOV-workaround.sh" -runAsSudo + if ($isRestartNeeded -imatch "SYSTEM_RESTART_REQUIRED") + { + LogMsg "SRIOV workaround applied for $($vmData.RoleName). Restart required." + $restartStatus = RestartAllDeployments -allVMData $vmData + } + else + { + LogMsg "SRIOV workaround is not needed." + } + LogMsg "Now executing $scriptName ..." $jobID = RunLinuxCmd -ip $vmData.PublicIP -port $vmData.SSHPort -username $user -password $password -command "/home/$user/$scriptName" -runAsSudo $sriovDetectedCount += 1 } diff --git a/remote-scripts/ConfigureSRIOV-workaround.sh b/remote-scripts/ConfigureSRIOV-workaround.sh new file mode 100644 index 0000000..396a492 --- /dev/null +++ b/remote-scripts/ConfigureSRIOV-workaround.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +DISTRO=`grep -ihs "buntu\|Suse\|Fedora\|Debian\|CentOS\|Red Hat Enterprise Linux" /etc/{issue,*release,*version}` +if [[ $DISTRO =~ "Ubuntu" ]]; +then + #A temporary workaround for SRIOV issue. + macAddr=`cat /sys/class/net/eth0/address` + echo "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"hv_netvsc\", ATTR{address}==\"${macAddr}\", NAME=\"eth0\"" > /etc/udev/rules.d/70-persistent-net.rules + echo "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"mlx4_core\", ATTR{address}==\"${macAddr}\", NAME=\"vf0\"" >> /etc/udev/rules.d/70-persistent-net.rules + #sed -i '/rename*/c\vf0' /etc/network/interfaces + echo "SYSTEM_RESTART_REQUIRED" +fi +exit 0 \ No newline at end of file