-# Copyright (c) 2018 Cisco and/or its affiliates.
+# Copyright (c) 2019 Cisco and/or its affiliates.
# 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:
function clean_environment () {
- # Cleanup environment by removing topology containers and binding
- # interfaces back to original driver.
+ # Cleanup environment by removing topology containers and shared volumes
+ # and binding interfaces back to original driver.
#
# Variables read:
# - DCR_UUIDS - Docker Container UUIDs.
# Kill docker containers.
docker rm --force "${DCR_UUIDS[@]}" || die "Cleanup containers failed!"
+ # Check if there are some leftover containers and remove all. Command will
+ # not fail in case there are no containers to remove.
+ docker rm --force $(docker ps -q --filter name=${DCR_UUIDS[dut1]}) || {
+ warn "Failed to remove hanged containers or nothing to remove!"
+ }
+
# Rebind interfaces back to kernel drivers.
for ADDR in ${TG_PCIDEVS[@]}; do
DRIVER="${TG_DRIVERS[0]}"
# Add Intel Corporation 82545EM Gigabit Ethernet Controller to the
# whitelist.
pci_id="0x100f"
- tg_netdev=(eth1 eth2)
- dut1_netdev=(eth3 eth4)
+ tg_netdev=(enpTGa enpTGb)
+ dut1_netdev=(enpSUTa enpSUTb)
;;
*)
die "Unknown specification: ${case_text}!"
fi
done
- for netdev in "${tg_side[@]::2}"; do
- TG_NETDEVS+=(${netdev})
- done
- for netdev in "${dut1_side[@]::2}"; do
- DUT1_NETDEVS+=(${netdev})
- done
+ case "${case_text}" in
+ "1n_skx")
+ # Pick up first two DUT1 interfaces binded to i40evf.
+ for netdev in "${dut1_side[@]::2}"; do
+ DUT1_NETDEVS+=(${netdev})
+ done
+ # Corresponding TG interfaces will be same ID.SUB_ID, but on
+ # opposite linked device.
+ for netdev in "${DUT1_NETDEVS[@]}"; do
+ TG_NETDEVS+=(${netdev/$dut1_netdev/$tg_netdev})
+ done
+ ;;
+ *)
+ for netdev in "${tg_side[@]::2}"; do
+ TG_NETDEVS+=(${netdev})
+ done
+ for netdev in "${dut1_side[@]::2}"; do
+ DUT1_NETDEVS+=(${netdev})
+ done
+ esac
for NETDEV in "${TG_NETDEVS[@]}"; do
get_pci_addr
# Mount vfio to be able to bind to see binded interfaces. We cannot use
# --device=/dev/vfio as this does not see newly binded interfaces.
dcr_stc_params+="--volume /dev/vfio:/dev/vfio "
+ # Mount nested_vm image to be able to run VM tests.
+ dcr_stc_params+="--volume /var/lib/vm/vhost-nested.img:/var/lib/vm/vhost-nested.img "
+ # Mount docker.sock to be able to use docker deamon of the host.
+ dcr_stc_params+="--volume /var/run/docker.sock:/var/run/docker.sock "
# Docker Container UUIDs.
declare -gA DCR_UUIDS