test/vhost: Attempt to read qemu.log uppon exiting

This gives a chance to quickly see why qemu might have failed, i.e.,
why the .pid file has not been found.

Change-Id: Ia1a5ae417164c865eede07cdb6dd4df1edc0b0b9
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2005
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Michal Berger 2020-05-04 10:57:37 +02:00 committed by Tomasz Zawadzki
parent 08f0abebb4
commit d9d62e1103

View File

@ -776,27 +776,30 @@ function vm_setup()
notice "Saving to $vm_dir/run.sh"
cat <<-RUN >"$vm_dir/run.sh"
#!/bin/bash
qemu_log () {
echo "=== qemu.log ==="
[[ -s $vm_dir/qemu.log ]] && cat $vm_dir/qemu.log
echo "=== qemu.log ==="
}
if [[ \$EUID -ne 0 ]]; then
echo "Go away user come back as root"
exit 1
fi
qemu_cmd=($(printf '%s\n' "${cmd[@]}"))
trap "qemu_log" EXIT
qemu_cmd=($(printf '%s\n' "${cmd[@]}"))
chmod +r $vm_dir/*
echo "Running VM in $vm_dir"
rm -f $qemu_pid_file
"\${qemu_cmd[@]}"
echo "Waiting for QEMU pid file"
sleep 1
[[ ! -f $qemu_pid_file ]] && sleep 1
[[ ! -f $qemu_pid_file ]] && echo "ERROR: no qemu pid file found" && exit 1
chmod +r $vm_dir/*
echo "=== qemu.log ==="
cat $vm_dir/qemu.log
echo "=== qemu.log ==="
exit 0
# EOF
RUN
chmod +x $vm_dir/run.sh