Files
dasandClaude Opus 5.5 a2bffc7fe9
build / build (push) Successful in 38m26s
Terminal: Das prompt, dprompt and dbanner (0.9.1)
- das-shell 0.1.0: the Das two-line bash prompt by default (replaces the
  PS1 of Void's skel .bashrc once), dprompt (Textual prompt builder with
  presets and live preview) and dbanner (SSH login banner editor: canvas
  tools, fields with values, widgets, das-banner service for cached ones,
  Das OS logo and tryzub pictures). Python tests in make test.
- das-server 0.3.0 depends on das-shell; the server installer mentions
  dprompt and dbanner; the desktop image includes it.
- run-qemu.sh forwards the guest's SSH to localhost:2222.
- Hardware fixes: Ventoy menu icon, boot menu titles "Das OS <version>".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 09:17:10 +03:00

88 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Boots a Das OS ISO in QEMU (KVM when available).
#
# Usage: scripts/run-qemu.sh [--bios] [--disk] [--serial] [path/to/image.iso]
# --bios boot with legacy BIOS instead of UEFI
# --disk attach out/qemu/disk.qcow2 (20 GB, created on first use) to test installing
# --serial no window: the serial console in this terminal (server ISO), Ctrl-A X quits
# Without a path the newest desktop ISO in out/iso is used (server ISO with --serial).
# The guest's SSH is on localhost:2222 (DASOS_SSH_PORT changes it): ssh -p 2222 user@localhost
set -euo pipefail
root=$(cd "$(dirname "$0")/.." && pwd)
state=$root/out/qemu
firmware=uefi
disk=false
serial=false
ssh_port=${DASOS_SSH_PORT:-2222}
iso=""
die() {
echo "run-qemu: $*" >&2
exit 1
}
for arg in "$@"; do
case $arg in
--bios) firmware=bios ;;
--disk) disk=true ;;
--serial) serial=true ;;
-h | --help)
sed -n '2,9s/^# \{0,1\}//p' "$0"
exit 0
;;
-*) die "unknown option: $arg" ;;
*) iso=$arg ;;
esac
done
if [[ -z $iso ]]; then
pattern="dasos-[0-9]*.iso"
[[ $serial == true ]] && pattern="dasos-server-*.iso"
iso=$(ls -t "$root"/out/iso/$pattern 2>/dev/null | head -n 1) || true
fi
[[ -n $iso && -f $iso ]] || die "no ISO found, run 'make iso' first"
args=(
-machine q35 -smp 4 -m 4096
-device virtio-net-pci,netdev=net0 -netdev "user,id=net0,hostfwd=tcp:127.0.0.1:${ssh_port}-:22"
-cdrom "$iso" -boot order=d
)
if [[ $serial == true ]]; then
# The guest's ttyS0 and the QEMU monitor share this terminal
args+=(-nographic -serial mon:stdio)
else
args+=(-device virtio-vga -display gtk,zoom-to-fit=on -device qemu-xhci -device usb-tablet)
fi
if [[ -w /dev/kvm ]]; then
args+=(-accel kvm -cpu host)
else
echo "run-qemu: /dev/kvm is not accessible, falling back to slow emulation" >&2
args+=(-accel tcg -cpu max)
fi
mkdir -p "$state"
if [[ $firmware == uefi ]]; then
code=""
# Debian/Ubuntu/Mint, then Arch, then Fedora file names
for candidate in /usr/share/OVMF/OVMF_CODE_4M.fd /usr/share/edk2/x64/OVMF_CODE.4m.fd /usr/share/edk2/ovmf/OVMF_CODE.fd; do
[[ -f $candidate ]] && code=$candidate && break
done
[[ -n $code ]] || die "UEFI firmware (OVMF) not found, install the ovmf package or use --bios"
vars_template=$(dirname "$code")/$(basename "$code" | sed 's/CODE/VARS/')
[[ -f $state/OVMF_VARS.fd ]] || cp "$vars_template" "$state/OVMF_VARS.fd"
args+=(
-drive "if=pflash,format=raw,readonly=on,file=$code"
-drive "if=pflash,format=raw,file=$state/OVMF_VARS.fd"
)
fi
if [[ $disk == true ]]; then
[[ -f $state/disk.qcow2 ]] || qemu-img create -f qcow2 "$state/disk.qcow2" 20G
args+=(-drive "file=$state/disk.qcow2,if=virtio,format=qcow2")
fi
exec qemu-system-x86_64 "${args[@]}"