fix: Display QEMU output (#558)

This commit is contained in:
Kroese 2024-01-13 18:16:17 +01:00 committed by GitHub
parent a3d6e3740c
commit 3a507f5bf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 19 deletions

View File

@ -22,11 +22,12 @@ if [[ "$CONSOLE" == [Yy]* ]]; then
exec qemu-system-x86_64 ${ARGS:+ $ARGS} exec qemu-system-x86_64 ${ARGS:+ $ARGS}
fi fi
[[ "$DEBUG" == [Yy1]* ]] && info "$VERS" && set -x [[ "$DEBUG" == [Yy1]* ]] && info "$VERS" && echo "Arguments: $ARGS" && echo
msg=$(qemu-system-x86_64 ${ARGS:+ $ARGS}) { qemu-system-x86_64 ${ARGS:+ $ARGS} >"$QEMU_OUT" 2>"$QEMU_LOG"; rc=$?; } || :
(( rc != 0 )) && error "$(cat "$QEMU_LOG")" && exit 15
{ set +x; } 2>/dev/null && terminal "$msg" terminal
tail -fn +0 "$QEMU_LOG" 2>/dev/null & tail -fn +0 "$QEMU_LOG" 2>/dev/null &
cat "$QEMU_TERM" 2>/dev/null & wait $! || true cat "$QEMU_TERM" 2>/dev/null & wait $! || :
sleep 1 && finish 0 sleep 1 && finish 0

View File

@ -12,6 +12,7 @@ QEMU_PORT=7100
QEMU_TIMEOUT=50 QEMU_TIMEOUT=50
QEMU_PID="/run/qemu.pid" QEMU_PID="/run/qemu.pid"
QEMU_LOG="/run/qemu.log" QEMU_LOG="/run/qemu.log"
QEMU_OUT="/run/qemu.out"
QEMU_END="/run/qemu.end" QEMU_END="/run/qemu.end"
if [[ "$KVM" == [Nn]* ]]; then if [[ "$KVM" == [Nn]* ]]; then
@ -19,9 +20,6 @@ if [[ "$KVM" == [Nn]* ]]; then
QEMU_TIMEOUT=$(( QEMU_TIMEOUT*2 )) QEMU_TIMEOUT=$(( QEMU_TIMEOUT*2 ))
fi fi
rm -f "$QEMU_PID"
rm -f "$QEMU_LOG"
rm -f "$QEMU_END"
touch "$QEMU_LOG" touch "$QEMU_LOG"
_trap() { _trap() {
@ -62,15 +60,25 @@ finish() {
terminal() { terminal() {
local msg=$1 local dev=""
if [[ "${msg,,}" != "char"* || "$msg" != *"serial0)" ]]; then if [ -f "$QEMU_OUT" ]; then
echo "$msg"
local msg
msg="$(cat "$QEMU_OUT")"
if [ -n "$msg" ]; then
if [[ "${msg,,}" != "char"* || "$msg" != *"serial0)" ]]; then
echo "$msg"
fi
dev="${msg#*/dev/p}"
dev="/dev/p${dev%% *}"
fi
fi fi
local dev="${msg#*/dev/p}"
dev="/dev/p${dev%% *}"
if [ ! -c "$dev" ]; then if [ ! -c "$dev" ]; then
dev=$(echo 'info chardev' | nc -q 1 -w 1 localhost "$QEMU_PORT" | tr -d '\000') dev=$(echo 'info chardev' | nc -q 1 -w 1 localhost "$QEMU_PORT" | tr -d '\000')
dev="${dev#*serial0}" dev="${dev#*serial0}"

View File

@ -36,10 +36,7 @@ STORAGE="/storage"
# Cleanup files # Cleanup files
rm -f /run/dsm.url rm -f /run/dsm.url
rm -f /run/qemu.ip rm -f /run/qemu.*
rm -f /run/qemu.log
rm -f /run/qemu.pid
rm -f /run/qemu.end
# Cleanup dirs # Cleanup dirs