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" notice "Saving to $vm_dir/run.sh"
cat <<-RUN >"$vm_dir/run.sh" cat <<-RUN >"$vm_dir/run.sh"
#!/bin/bash #!/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 if [[ \$EUID -ne 0 ]]; then
echo "Go away user come back as root" echo "Go away user come back as root"
exit 1 exit 1
fi 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" echo "Running VM in $vm_dir"
rm -f $qemu_pid_file rm -f $qemu_pid_file
"\${qemu_cmd[@]}" "\${qemu_cmd[@]}"
echo "Waiting for QEMU pid file" echo "Waiting for QEMU pid file"
sleep 1 sleep 1
[[ ! -f $qemu_pid_file ]] && sleep 1 [[ ! -f $qemu_pid_file ]] && sleep 1
[[ ! -f $qemu_pid_file ]] && echo "ERROR: no qemu pid file found" && exit 1 [[ ! -f $qemu_pid_file ]] && echo "ERROR: no qemu pid file found" && exit 1
exit 0
chmod +r $vm_dir/*
echo "=== qemu.log ==="
cat $vm_dir/qemu.log
echo "=== qemu.log ==="
# EOF # EOF
RUN RUN
chmod +x $vm_dir/run.sh chmod +x $vm_dir/run.sh