test/vhost: change vm_kill_all to vm_shutdown_all

Change killing VMs with SIGKILL to proper shutdown.

Change-Id: I3547f1b57e33dc5ecd7613d7600e9feeadd44283
Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.gerrithub.io/366087
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Karol Latecki 2017-06-19 13:19:51 +02:00 committed by Daniel Verkamp
parent 8912fc193f
commit ae2932c9b4
2 changed files with 33 additions and 8 deletions

View File

@ -265,7 +265,7 @@ if ! $no_shutdown; then
echo "==============="
echo "INFO: APP EXITING"
echo "INFO: killing all VMs"
vm_kill_all
vm_shutdown_all
echo "INFO: waiting 2 seconds to let all VMs die"
sleep 2
if [[ $test_type == "spdk_vhost" ]]; then

View File

@ -328,14 +328,13 @@ function vm_shutdown()
return 0
fi
# Temporarily disabling exit flag for next ssh command, since it will
# "fail" due to shutdown
echo "Shutting down virtual machine $vm_dir"
if vm_ssh $1 "nohup sh -c 'shutdown -h -P now'; exit 0"; then
echo "INFO: VM$1 is shutting down - wait a while to complete"
return 0
else
error "VM$1 shutting FAILED"
return 1
fi
set +e
vm_ssh $1 "nohup sh -c 'shutdown -h -P now'"
echo "INFO: VM$1 is shutting down - wait a while to complete"
set -e
}
# Kill given VM
@ -380,6 +379,32 @@ function vm_shutdown_all()
for vm in $VM_BASE_DIR/[0-9]*; do
vm_shutdown $(basename $vm)
done
echo "INFO: Waiting for VMs to shutdown..."
timeo=10
while [[ $timeo -gt 0 ]]; do
all_vms_down=1
for vm in $VM_BASE_DIR/[0-9]*; do
if /bin/kill -0 "$(cat $vm/qemu.pid)"; then
all_vms_down=0
break
fi
done
if [[ $all_vms_down == 1 ]]; then
echo "INFO: All VMs successfully shut down"
return 0
fi
((timeo-=1))
sleep 1
done
echo "ERROR: VMs were NOT shutdown properly - sending SIGKILL"
for vm in $VM_BASE_DIR/[0-9]*; do
/bin/kill -KILL "$(cat $vm/qemu.pid)"
done
return 1
}
function vm_setup()