diff --git a/src/cmdlib.sh b/src/cmdlib.sh index 48a678baca..37041a27b4 100755 --- a/src/cmdlib.sh +++ b/src/cmdlib.sh @@ -733,6 +733,9 @@ runvm() { # and include all GPG keys find /etc/pki/rpm-gpg/ -type f >> "${vmpreparedir}/hostfiles" + local cmdoutput + cmdoutput=${tmp_builddir}/cmd-output.txt + # the reason we do a heredoc here is so that the var substition takes # place immediately instead of having to proxy them through to the VM cat > "${vmpreparedir}/init" <> "${tmp_builddir}"/cmd.sh done - touch "${runvm_console}" + touch "${runvm_console}" "${cmdoutput}" + setpriv --pdeathsig SIGTERM -- tail -qF "${cmdoutput}" --pid $$ & + local tail_pid=$! # There seems to be some false positives in shellcheck # https://github.com/koalaman/shellcheck/issues/2217 @@ -821,9 +826,7 @@ EOF if [ -z "${RUNVM_SHELL:-}" ]; then if ! "${kola_args[@]}" -- "${base_qemu_args[@]}" \ - -device virtserialport,chardev=virtioserial0,name=cosa-cmdout \ - -chardev stdio,id=virtioserial0 \ - "${qemu_args[@]}" <&-; then # the <&- here closes stdin otherwise qemu waits forever + "${qemu_args[@]}"; then cat "${runvm_console}" fatal "Failed to run 'kola qemuexec'" fi @@ -842,6 +845,9 @@ EOF fi rc="$(cat "${rc_file}")" + # cleanup tail before nuking dir containing file it's following + kill "$tail_pid" + if [ -n "${cleanup_tmpdir:-}" ]; then rm -rf "${tmp_builddir}" unset tmp_builddir