Skip to content

Commit 086bce2

Browse files
committed
smoke: use hw ports in grout namespace
Since commits 4d5fa1c and 4853d4d grout is running in it's own namespace. When tests are using hardware ports we should ensure that the ports are accessible from that namespace. Signed-off-by: Roman Safronov <[email protected]>
1 parent 4e3e474 commit 086bce2

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

smoke/_init.sh

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,27 @@
33

44
set -e -o pipefail
55

6+
: "${use_hardware_ports:=false}"
7+
# Usage example
8+
# export NET_INTERFACES="eno12399v1 eno12409v1"
9+
# export VFIO_PCI_PORTS="0000:8a:01.0 0000:8a:11.0"
10+
if [ -n "$NET_INTERFACES" ] && [ -n "$VFIO_PCI_PORTS" ]; then
11+
net_interfaces=($NET_INTERFACES)
12+
vfio_pci_ports=($VFIO_PCI_PORTS)
13+
if [ "${#net_interfaces[@]}" -ne "${#vfio_pci_ports[@]}" ]; then
14+
echo "error: NET_INTERFACES and VFIO_PCI_PORTS must have equal length" >&2
15+
exit 1
16+
fi
17+
use_hardware_ports=true
18+
fi
619
if [ -z "$(ip netns identify)" ]; then
720
set -x
821
ip netns add grout 2>/dev/null || :
22+
if [ $use_hardware_ports = true ]; then
23+
for i in ${net_interfaces[@]}; do
24+
ip link set $i netns grout
25+
done
26+
fi
927
exec ip netns exec grout "$0" "$@"
1028
fi
1129

@@ -23,20 +41,6 @@ else
2341
run_grout=true
2442
fi
2543

26-
: "${use_hardware_ports:=false}"
27-
# Usage example
28-
# export NET_INTERFACES="eno12399v1 eno12409v1"
29-
# export VFIO_PCI_PORTS="0000:8a:01.0 0000:8a:11.0"
30-
if [ -n "$NET_INTERFACES" ] && [ -n "$VFIO_PCI_PORTS" ]; then
31-
net_interfaces=($NET_INTERFACES)
32-
vfio_pci_ports=($VFIO_PCI_PORTS)
33-
if [ "${#net_interfaces[@]}" -ne "${#vfio_pci_ports[@]}" ]; then
34-
echo "error: NET_INTERFACES and VFIO_PCI_PORTS must have equal length" >&2
35-
exit 1
36-
fi
37-
use_hardware_ports=true
38-
fi
39-
4044
cleanup() {
4145
status="$?"
4246
set +e
@@ -53,7 +57,7 @@ cleanup() {
5357
while read -r name _; do
5458
grcli interface del "$name"
5559
done
56-
[ -s $tmp/restore_interfaces ] && sh -x $tmp/restore_interfaces
60+
[ -s $tmp/restore_interfaces ] && nsenter -t 1 -n sh -x $tmp/restore_interfaces
5761

5862
kill %?grcli
5963
wait %?grcli

0 commit comments

Comments
 (0)