Skip to content

Commit

Permalink
cmdlib.sh: go back to using tail -F for command output
Browse files Browse the repository at this point in the history
This is more or less a revert of 4eb19f4.

It seems like QEMU v8.2.2 (in Fedora 40) is hitting issues when
combining virtio-serial ports and the stdio character device. When the
guest writes to the virtio-serial port, it sometimes hangs.

We can look at reverting this patch if it works again in a future
version.
  • Loading branch information
jlebon committed May 1, 2024
1 parent 65a1155 commit 79b15c8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/cmdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" <<EOF
Expand All @@ -752,7 +755,7 @@ rc=0
# - Use a subshell because otherwise init will use workdir as its cwd and we won't
# be able to unmount the virtiofs mount cleanly. This leads to consistency issues.
if [ -z "${RUNVM_SHELL:-}" ]; then
(cd ${workdir}; bash ${tmp_builddir}/cmd.sh |& tee /dev/virtio-ports/cosa-cmdout) || rc=\$?
(cd ${workdir}; bash ${tmp_builddir}/cmd.sh |& tee ${cmdoutput}) || rc=\$?
else
(cd ${workdir}; bash)
fi
Expand Down Expand Up @@ -786,7 +789,9 @@ EOF
printf '%q ' "$arg" >> "${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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 79b15c8

Please sign in to comment.