summaryrefslogtreecommitdiffstats
path: root/scripts/qemu.sh
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-08-27 18:35:59 +0200
committersalmonik <salmonik@tuta.io>2026-08-27 18:35:59 +0200
commitacd0fe1bc38746f36fff24a7497041e5c5010977 (patch)
tree5db6335b732409c7f180f8514196c52a7b88f434 /scripts/qemu.sh
parentGUI: fire-and-forget spawn for /bin/gui binaries (diff)
downloadrs-dos-acd0fe1bc38746f36fff24a7497041e5c5010977.tar.gz
rs-dos-acd0fe1bc38746f36fff24a7497041e5c5010977.zip
scripts: migrate all QEMU/test scripts to single system image
boot.sh: replace esp/ + DISK_IMG with single SYSTEM_IMG on ide.0 (hooks into mksystem.sh --force for auto-staging). boot-image.sh: delegate to mksystem.sh --chain (build-image.sh deleted). build-image-release.sh: delegate to mksystem.sh --chain --gpt. qemu.sh: flexible launcher uses SYSTEM_IMG; --chain flag for full-chain build. test-disk.sh: drop ESP_DIR (mksystem.sh stages everything). test-fault.sh: boot system.img on ide.0 + CRASHLOG stick on ide.1; replace deleted mkdisk.sh with inline mkfs.fat. test-gfx.sh: system.img on ide.0, stage via mksystem.sh. test-mouse.sh: system.img on ide.0, stage via mksystem.sh. test-msg.sh: system.img on ide.0, stage via mksystem.sh. Makefile: remove stale build-image.sh/mkdisk.sh references from help; image target delegates to mksystem.sh --chain. All scripts syntax-checked (bash -n). build-image.sh and mkdisk.sh no longer referenced anywhere.
Diffstat (limited to '')
-rwxr-xr-xscripts/qemu.sh90
1 files changed, 45 insertions, 45 deletions
diff --git a/scripts/qemu.sh b/scripts/qemu.sh
index b8997ba..eeaf4de 100755
--- a/scripts/qemu.sh
+++ b/scripts/qemu.sh
@@ -1,28 +1,32 @@
1#!/usr/bin/env bash 1#!/usr/bin/env bash
2# ============================================================================= 2# =============================================================================
3# tools/qemu.sh — Run raisernics in QEMU with various options 3# scripts/qemu.sh — flexible QEMU launcher for rs-dos
4# 4#
5# Usage: 5# Usage:
6# ./tools/qemu.sh # serial console (no graphics) 6# ./scripts/qemu.sh # serial console (no graphics)
7# ./tools/qemu.sh --gui # graphical window 7# ./scripts/qemu.sh --gui # graphical window
8# ./tools/qemu.sh --debug # GDB stub on :1234 8# ./scripts/qemu.sh --debug # GDB stub on :1234
9# ./tools/qemu.sh --image foo.img # boot from raw disk image 9# ./scripts/qemu.sh --chain # full boot chain (firmware → rsboot → rsnix)
10# ./tools/qemu.sh --bios /path/to.fd # custom OVMF 10# ./scripts/qemu.sh --bios /path/to.fd # custom OVMF
11# ./tools/qemu.sh --mem 512M # memory size 11# ./scripts/qemu.sh --mem 512M # memory size
12# ./tools/qemu.sh --smp 2 # SMP cores 12# ./scripts/qemu.sh --smp 2 # SMP cores
13#
14# One image, one drive — the system image contains kernel + ESP + data.
13# ============================================================================= 15# =============================================================================
14set -euo pipefail 16set -euo pipefail
15 17
16SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)" 18SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
17cd "$SCRIPT_DIR" 19PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
20cd "$PROJECT_DIR"
18 21
19# Defaults 22# Defaults
20GUI_FLAG="" 23GUI_FLAG=""
21DEBUG_FLAG="" 24DEBUG_FLAG=""
22DRIVE_ARGS=(-drive file=fat:rw:esp,format=raw) 25CHAIN_FLAG=""
23OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" 26OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}"
24MEM="${MEM:-256M}" 27MEM="${MEM:-256M}"
25SMP="${SMP:-1}" 28SMP="${SMP:-1}"
29SYSTEM_IMG="${SYSTEM_IMG:-/tmp/system.img}"
26 30
27# Pre-build 31# Pre-build
28make all 32make all
@@ -38,12 +42,13 @@ while [ $# -gt 0 ]; do
38 DEBUG_FLAG="-s -S" 42 DEBUG_FLAG="-s -S"
39 shift 43 shift
40 ;; 44 ;;
45 --chain | -c)
46 CHAIN_FLAG=1
47 SYSTEM_IMG="${SYSTEM_IMG:-rs-dos.img}"
48 shift
49 ;;
41 --image | -i) 50 --image | -i)
42 _img_file="$(printf -- '-drive file=%s,format=raw,if=none,id=hd' "$2")" 51 SYSTEM_IMG="$2"
43 # Explicit buses: data disk -> ide.0 (port 0), ESP -> ide.1.
44 DRIVE_ARGS=("$_img_file" '-device' 'ide-hd,drive=hd,bus=ide.0'
45 '-drive' 'file=fat:rw:esp,format=raw,if=none,id=esp'
46 '-device' 'ide-hd,drive=esp,bus=ide.1')
47 shift 2 52 shift 2
48 ;; 53 ;;
49 --bios | -b) 54 --bios | -b)
@@ -58,42 +63,37 @@ while [ $# -gt 0 ]; do
58 SMP="$2" 63 SMP="$2"
59 shift 2 64 shift 2
60 ;; 65 ;;
61 --help | -h)
62 head -20 "$0" | grep "^# " | sed 's/^# //'
63 exit 0
64 ;;
65 *) 66 *)
66 echo "Unknown option: $1" 67 echo "unknown: $1"
67 exit 1 68 exit 1
68 ;; 69 ;;
69 esac 70 esac
70done 71done
71 72
72QEMU_CMD=( 73# Stage system image if needed
73 qemu-system-x86_64 74if [ -n "$CHAIN_FLAG" ]; then
74 -bios "$OVMF" 75 ./scripts/mksystem.sh --chain --gpt "$SYSTEM_IMG"
75 "${DRIVE_ARGS[@]}" 76else
76 -serial stdio 77 ./scripts/mksystem.sh "$SYSTEM_IMG"
77 -m "$MEM"
78 -machine q35
79 -cpu qemu64
80 -no-reboot
81 -smp "$SMP"
82)
83
84[ -n "$GUI_FLAG" ] && QEMU_CMD+=("$GUI_FLAG")
85if [ -n "$DEBUG_FLAG" ]; then
86 # Split the flag string safely into words
87 read -ra dbg <<<"$DEBUG_FLAG"
88 QEMU_CMD+=("${dbg[@]}")
89fi 78fi
90 79
91echo " OVMF : $OVMF" 80echo ""
92echo " Drive : ${DRIVE_ARGS[*]}" 81echo "=== Booting ==="
93echo " Mem : $MEM" 82echo " image: $SYSTEM_IMG"
94echo " SMP : $SMP" 83echo " ovmf: $OVMF"
95echo " GDB : $([ -n "$DEBUG_FLAG" ] && echo ':1234' || echo 'off')" 84echo " mem: $MEM smp: $SMP"
96echo " GUI : $([ -n "$GUI_FLAG" ] && echo 'yes' || echo 'no')" 85echo " gui: $([ -n "$GUI_FLAG" ] && echo yes || echo no)"
86echo " gdb: $([ -n "$DEBUG_FLAG" ] && echo ':1234' || echo off)"
97echo "" 87echo ""
98 88
99exec "${QEMU_CMD[@]}" 89exec qemu-system-x86_64 \
90 -bios "$OVMF" \
91 -drive "file=$SYSTEM_IMG,format=raw,if=none,id=hd" \
92 -device ide-hd,drive=hd \
93 -serial stdio \
94 -m "$MEM" \
95 -machine q35 \
96 -cpu qemu64 \
97 -no-reboot \
98 -smp "$SMP" \
99 $GUI_FLAG $DEBUG_FLAG