ci / test (push) Canceled after 0s
ci / mcdc (push) Canceled after 0s
ci / bench (push) Canceled after 0s
ci / bench (pull_request) Canceled after 0s
ci / qemu-tools (pull_request) Canceled after 0s
ci / quality (push) Canceled after 0s
ci / kernel-symbols (pull_request) Canceled after 0s
ci / badges (push) Canceled after 0s
ci / prune-artifacts (pull_request) Canceled after 0s
ci / badges (pull_request) Canceled after 0s
ci / qemu-tools (push) Canceled after 0s
ci / kernel-symbols (push) Canceled after 0s
ci / test (pull_request) Canceled after 0s
ci / patches-apply (push) Canceled after 0s
ci / mcdc (pull_request) Canceled after 0s
ci / prune-artifacts (push) Canceled after 0s
ci / kernel-build (push) Canceled after 0s
ci / patches-apply (pull_request) Canceled after 0s
ci / kernel-build (pull_request) Canceled after 0s
ci / quality (pull_request) Canceled after 0s
shellcheck 0.9 in the qemu-tools CI job reports SC2013 for `for w in $(cat /proc/cmdline)` and exits non-zero, which kept CI red on the M0 kernel branch since the warden.run entry was added. Read /proc/cmdline into a variable and loop over its words. Regression test: tests/qemu-init/run-init-shellcheck-tests.sh (run by the qemu-tools job) shellchecks the rootfs scripts and proves the old form red on a doctored copy. Fixes #18. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cxh2piVufTWbzKTmUafTkk
82 lines
3.2 KiB
Plaintext
Executable File
82 lines
3.2 KiB
Plaintext
Executable File
#!/bin/busybox sh
|
|
# shellcheck shell=dash
|
|
# WardenOS QEMU device sim: initramfs /init (PID 1).
|
|
#
|
|
# Phase-1 duty: prove the kernel booted on -M virt; print the sentinel the
|
|
# smoke test greps for, then power off (PSCI SYSTEM_OFF, so qemu exits).
|
|
# `warden.shell` on the kernel cmdline drops to an interactive shell instead.
|
|
|
|
/bin/busybox mount -t devtmpfs devtmpfs /dev 2>/dev/null
|
|
|
|
# The cpio archive carries no device nodes (it is built unprivileged, no
|
|
# mknod); reopen stdio on the real console now that devtmpfs is mounted.
|
|
exec </dev/console >/dev/console 2>&1
|
|
|
|
/bin/busybox --install -s /bin
|
|
mount -t proc proc /proc
|
|
mount -t sysfs sysfs /sys
|
|
|
|
echo "WARDEN-QEMU-BOOT-OK"
|
|
|
|
# Kernel contract (rebuild M0): every symbol of build/required-symbols.txt (staged
|
|
# as /etc/required-symbols.txt by mkinitramfs.sh) is in the running kernel's
|
|
# /proc/config.gz, the cgroup v2 controllers the platform limits with are there,
|
|
# and pressure stall information is on. boot-smoke.sh greps these markers.
|
|
if [ -r /etc/required-symbols.txt ]; then
|
|
if [ -e /proc/config.gz ] && zcat /proc/config.gz > /config.run 2>/dev/null; then
|
|
miss=""; nsym=0
|
|
while read -r line; do
|
|
case "$line" in
|
|
CONFIG_*=*)
|
|
nsym=$((nsym + 1))
|
|
grep -qxF "$line" /config.run || miss="$miss $line" ;;
|
|
"# CONFIG_"*" is not set")
|
|
sym="${line#\# }"; sym="${sym% is not set}"; nsym=$((nsym + 1))
|
|
grep -q "^$sym=" /config.run && miss="$miss ${sym}(set)" ;;
|
|
esac
|
|
done < /etc/required-symbols.txt
|
|
if [ -z "$miss" ]; then echo "WARDEN-QEMU-SYMBOLS-OK $nsym"
|
|
else echo "WARDEN-QEMU-SYMBOLS-MISSING$miss"; fi
|
|
else
|
|
echo "WARDEN-QEMU-SYMBOLS-MISSING /proc/config.gz"
|
|
fi
|
|
mkdir -p /sys/fs/cgroup
|
|
mount -t cgroup2 none /sys/fs/cgroup 2>/dev/null
|
|
echo "WARDEN-QEMU-CGROUP-CONTROLLERS $(cat /sys/fs/cgroup/cgroup.controllers 2>/dev/null)"
|
|
psi_missing=""
|
|
for f in cpu memory io; do [ -r "/proc/pressure/$f" ] || psi_missing="$psi_missing $f"; done
|
|
if [ -z "$psi_missing" ]; then echo "WARDEN-QEMU-PSI-OK"; else echo "WARDEN-QEMU-PSI-MISSING$psi_missing"; fi
|
|
fi
|
|
|
|
# warden.run=<path>: run a script that mkinitramfs.sh staged from EXTRA_DIR, then
|
|
# power off. Used by the M0 limit tests (tools/m0/limits-test.sh in flare-edge).
|
|
read -r CMDLINE < /proc/cmdline
|
|
for w in $CMDLINE; do
|
|
case "$w" in warden.run=*) RUN_SCRIPT="${w#warden.run=}" ;; esac
|
|
done
|
|
if [ -n "${RUN_SCRIPT:-}" ]; then
|
|
if [ -x "$RUN_SCRIPT" ]; then
|
|
echo "WARDEN-QEMU-RUN-BEGIN $RUN_SCRIPT"
|
|
"$RUN_SCRIPT"
|
|
echo "WARDEN-QEMU-RUN-END rc=$?"
|
|
else
|
|
echo "WARDEN-QEMU-RUN-MISSING $RUN_SCRIPT"
|
|
fi
|
|
poweroff -f
|
|
fi
|
|
|
|
# With a virtio disk attached, hand over to the stage-1 rc (by-name symlinks,
|
|
# slot select, switch_root). It only returns on failure; then fall through to
|
|
# the diskless shell/poweroff behavior below.
|
|
if [ -b /dev/vda ]; then
|
|
# shellcheck source=qemu/rootfs/etc/rc disable=SC1091
|
|
. /etc/rc
|
|
fi
|
|
|
|
if grep -qw warden.shell /proc/cmdline; then
|
|
echo "warden.shell: interactive shell (exit to power off)"
|
|
setsid cttyhack sh
|
|
fi
|
|
|
|
poweroff -f
|