X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fbash%2Ffunction%2Fdevice.sh;h=7d175a9ac323d018584dcf8e30c93cd9d6699f83;hb=22ff475dae7f9f09e8b3b7c899731803752761c0;hp=7363dc0df6b385fd9b88641a297ade287e267ab5;hpb=5f809dd2414d50fd6f229fc2ba2ff42d66df5dde;p=csit.git diff --git a/resources/libraries/bash/function/device.sh b/resources/libraries/bash/function/device.sh index 7363dc0df6..7d175a9ac3 100644 --- a/resources/libraries/bash/function/device.sh +++ b/resources/libraries/bash/function/device.sh @@ -108,8 +108,8 @@ function bind_interfaces_to_driver () { 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. @@ -124,6 +124,12 @@ function clean_environment () { # 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]}" @@ -519,6 +525,8 @@ function start_topology_containers () { 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