Files
LithosAnanke/demo/qemu-args.sh
T
Claude 171b3947dd
Build / Image RASPI (push) Canceled after 0s
Build / Image PC (push) Canceled after 0s
Build / Image MILKV (push) Canceled after 0s
Build / v4 tests (32- and 64-bit cells) (push) Canceled after 0s
Acceptance / Acceptance (pull_request) Canceled after 0s
demo: two guests of 384 MiB, and a busy message for the rest (#116)
Captain Bob, 2026-11-07: 'Limit guests and have a Busy, try back in a few
minutes.' start-session.sh takes one of DEMO_MAX_GUESTS slots (default 2),
a lock it holds for the session's life (flock -n: two visitors cannot both
take the last one; QEMU and the bridge are started without its descriptor);
with every slot taken, the visitor's terminal says every machine is busy and
to try back in a few minutes, and the session ends without a machine. The
service: DEMO_MAX_GUESTS=2, RuntimeDirectory for the locks, ttyd's
--max-clients 6 so a visitor over the limit reaches the message. The guest:
384 MiB (v4 boots from 256 MiB, refuses at 128; measured, #116). Tested
here: every slot held -> the busy message; slot 1 held -> slot 2 taken.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GE3SDvQn5EoxdGufk84zz2
2026-11-07 23:18:40 +00:00

40 lines
1.9 KiB
Bash

# qemu-args.sh -- the demo machine, sourced by make-snapshot.sh and start-session.sh.
#
# A session resumes a machine saved by make-snapshot.sh, and QEMU can resume a saved machine only
# into the same machine: the same board, CPU, memory, firmware and devices. Both scripts build the
# command line here, so they cannot drift apart. It is the machine `make -f kernel/Makefile
# ARCH=amd64 qemu` boots (q35, TCG, OVMF, the ISO as a CD) -- in 384 MiB, not its 1 GiB: v4 boots
# to Zuse's prompt from 256 MiB, refuses at 128 ("no memory for the block chain"), measured
# 2026-11-07 (#116) -- less what a visitor must not have: no network device, no Artemis disk, no
# display, and QEMU's seccomp sandbox on.
#
# demo_qemu_args <state-dir> <vars.fd> -> fills the array QEMU_ARGS
#
# <state-dir>/StarshipOS.iso is the image; <state-dir>/identity.img, if there, is the identity
# drive every session gets (issue #111), attached with its writes discarded.
OVMF_CODE=${OVMF_CODE:-/usr/share/OVMF/OVMF_CODE_4M.fd}
demo_qemu_args() {
local dir=$1 vars=$2
QEMU_ARGS=(
-machine q35,accel=tcg
-cpu qemu64,+rdrand
-m 384 # v4 boots from 256 MiB; 384 leaves room (#116)
-smp 1
-drive "if=pflash,format=raw,readonly=on,file=$OVMF_CODE"
-drive "if=pflash,format=raw,file=$vars"
-drive "if=none,id=cd,media=cdrom,readonly=on,file=$dir/StarshipOS.iso"
-device ide-cd,drive=cd,bootindex=0
-device qemu-xhci,id=xhci0,p2=16,p3=16 # kernel/Makefile XHCI_PORTS
-nic none
-display none
-no-reboot
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny
)
if [ -f "$dir/identity.img" ]; then
QEMU_ARGS+=(-drive "if=none,id=ident,format=raw,snapshot=on,file=$dir/identity.img"
-device usb-storage,bus=xhci0.0,port=1,drive=ident)
fi
}