This commit is contained in:
2026-03-20 09:24:01 +01:00
parent 5ba3b8d723
commit 6e046a505d

View File

@@ -873,46 +873,52 @@ if [ "$QUICK_MODE" = false ] && [ -n "${OVMF_PATH:-}" ] && [ -f "${ISO}" ]; then
HAS_KERNEL=false
[ -f "${PROJECT_ROOT}/kernel/vmlinuz" ] && HAS_KERNEL=true
INITRD_FLAGS=""
[ -f "${PROJECT_ROOT}/src/iso/initramfs.cpio.gz" ] && \
INITRD_FLAGS="-initrd ${PROJECT_ROOT}/src/iso/initramfs.cpio.gz"
# Build QEMU command as an array for correct quoting
QEMU_CMD=(qemu-system-x86_64)
[ -n "$KVM_FLAG" ] && QEMU_CMD+=($KVM_FLAG)
QEMU_CMD+=(-m 2G -smp 2)
if [ "$HAS_KERNEL" = true ]; then
echo " Using direct kernel boot (kernel + initramfs)..."
timeout 60 qemu-system-x86_64 \
${KVM_FLAG} \
-m 2G \
-smp 2 \
-kernel "${PROJECT_ROOT}/kernel/vmlinuz" \
${INITRD_FLAGS} \
-append "console=ttyS0,115200n8" \
-cdrom "$ISO" \
-drive file="$QEMU_DISK",format=qcow2,if=virtio \
-nographic \
-serial mon:stdio \
-no-reboot \
2>"${LOG_DIR}/qemu-stderr.log" | head -200 > "${LOG_DIR}/qemu-output.log" &
QEMU_PID=$!
QEMU_CMD+=(-kernel "${PROJECT_ROOT}/kernel/vmlinuz")
if [ -f "${PROJECT_ROOT}/src/iso/initramfs.cpio.gz" ]; then
QEMU_CMD+=(-initrd "${PROJECT_ROOT}/src/iso/initramfs.cpio.gz")
fi
QEMU_CMD+=(-append "console=ttyS0,115200n8 loglevel=7")
else
echo " Using UEFI ISO boot (no compiled kernel found)..."
timeout 60 qemu-system-x86_64 \
${KVM_FLAG} \
-m 2G \
-smp 2 \
${OVMF_FLAGS} \
-cdrom "$ISO" \
-drive file="$QEMU_DISK",format=qcow2,if=virtio \
-nographic \
-serial mon:stdio \
-no-reboot \
2>"${LOG_DIR}/qemu-stderr.log" | head -200 > "${LOG_DIR}/qemu-output.log" &
QEMU_PID=$!
QEMU_CMD+=(${OVMF_FLAGS})
fi
sleep 60
kill $QEMU_PID 2>/dev/null
QEMU_CMD+=(-cdrom "$ISO")
QEMU_CMD+=(-drive "file=$QEMU_DISK,format=qcow2,if=virtio")
QEMU_CMD+=(-nographic -no-reboot)
# Debug: show the QEMU command
echo " QEMU: ${QEMU_CMD[*]}" >&2
# Run QEMU with timeout, capture serial output directly to file
# -nographic routes serial to stdio automatically
timeout 30 "${QEMU_CMD[@]}" > "${LOG_DIR}/qemu-output.log" 2>"${LOG_DIR}/qemu-stderr.log" &
QEMU_PID=$!
# Wait for QEMU to finish (timeout handles the time limit)
wait $QEMU_PID 2>/dev/null
# Debug: dump log sizes and first/last lines
echo " Output log: $(wc -l < "${LOG_DIR}/qemu-output.log" 2>/dev/null || echo 0) lines, $(wc -c < "${LOG_DIR}/qemu-output.log" 2>/dev/null || echo 0) bytes" >&2
echo " Stderr log: $(wc -l < "${LOG_DIR}/qemu-stderr.log" 2>/dev/null || echo 0) lines" >&2
if [ -s "${LOG_DIR}/qemu-output.log" ]; then
echo " First 3 lines of output:" >&2
head -3 "${LOG_DIR}/qemu-output.log" >&2
echo " Last 3 lines of output:" >&2
tail -3 "${LOG_DIR}/qemu-output.log" >&2
else
echo " WARNING: qemu-output.log is empty!" >&2
echo " Stderr:" >&2
head -10 "${LOG_DIR}/qemu-stderr.log" >&2
fi
# Check if we got kernel boot messages
if grep -qi "linux version\|darkforge\|kernel" "${LOG_DIR}/qemu-output.log" 2>/dev/null; then
record_test "qemu.kernel_boots" "pass"