Commit ae2932c9 authored by Karol Latecki's avatar Karol Latecki Committed by Daniel Verkamp
Browse files

test/vhost: change vm_kill_all to vm_shutdown_all



Change killing VMs with SIGKILL to proper shutdown.

Change-Id: I3547f1b57e33dc5ecd7613d7600e9feeadd44283
Signed-off-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.gerrithub.io/366087


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 8912fc19
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+32 −7
Original line number Diff line number Diff line
@@ -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
	set +e
	vm_ssh $1 "nohup sh -c 'shutdown -h -P now'"
	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
}

# 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()