wip
This commit is contained in:
@@ -873,46 +873,52 @@ if [ "$QUICK_MODE" = false ] && [ -n "${OVMF_PATH:-}" ] && [ -f "${ISO}" ]; then
|
|||||||
HAS_KERNEL=false
|
HAS_KERNEL=false
|
||||||
[ -f "${PROJECT_ROOT}/kernel/vmlinuz" ] && HAS_KERNEL=true
|
[ -f "${PROJECT_ROOT}/kernel/vmlinuz" ] && HAS_KERNEL=true
|
||||||
|
|
||||||
INITRD_FLAGS=""
|
# Build QEMU command as an array for correct quoting
|
||||||
[ -f "${PROJECT_ROOT}/src/iso/initramfs.cpio.gz" ] && \
|
QEMU_CMD=(qemu-system-x86_64)
|
||||||
INITRD_FLAGS="-initrd ${PROJECT_ROOT}/src/iso/initramfs.cpio.gz"
|
[ -n "$KVM_FLAG" ] && QEMU_CMD+=($KVM_FLAG)
|
||||||
|
QEMU_CMD+=(-m 2G -smp 2)
|
||||||
|
|
||||||
if [ "$HAS_KERNEL" = true ]; then
|
if [ "$HAS_KERNEL" = true ]; then
|
||||||
echo " Using direct kernel boot (kernel + initramfs)..."
|
echo " Using direct kernel boot (kernel + initramfs)..."
|
||||||
timeout 60 qemu-system-x86_64 \
|
QEMU_CMD+=(-kernel "${PROJECT_ROOT}/kernel/vmlinuz")
|
||||||
${KVM_FLAG} \
|
if [ -f "${PROJECT_ROOT}/src/iso/initramfs.cpio.gz" ]; then
|
||||||
-m 2G \
|
QEMU_CMD+=(-initrd "${PROJECT_ROOT}/src/iso/initramfs.cpio.gz")
|
||||||
-smp 2 \
|
fi
|
||||||
-kernel "${PROJECT_ROOT}/kernel/vmlinuz" \
|
QEMU_CMD+=(-append "console=ttyS0,115200n8 loglevel=7")
|
||||||
${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=$!
|
|
||||||
else
|
else
|
||||||
echo " Using UEFI ISO boot (no compiled kernel found)..."
|
echo " Using UEFI ISO boot (no compiled kernel found)..."
|
||||||
timeout 60 qemu-system-x86_64 \
|
QEMU_CMD+=(${OVMF_FLAGS})
|
||||||
${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=$!
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sleep 60
|
QEMU_CMD+=(-cdrom "$ISO")
|
||||||
kill $QEMU_PID 2>/dev/null
|
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
|
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
|
# Check if we got kernel boot messages
|
||||||
if grep -qi "linux version\|darkforge\|kernel" "${LOG_DIR}/qemu-output.log" 2>/dev/null; then
|
if grep -qi "linux version\|darkforge\|kernel" "${LOG_DIR}/qemu-output.log" 2>/dev/null; then
|
||||||
record_test "qemu.kernel_boots" "pass"
|
record_test "qemu.kernel_boots" "pass"
|
||||||
|
|||||||
Reference in New Issue
Block a user