From a4bbfbd83be53cc4f8ec374edf072fa4aef358c2 Mon Sep 17 00:00:00 2001 From: BFE Engineering Date: Wed, 28 Oct 2026 10:35:29 -0600 Subject: [PATCH] qemu: boot the UI through the panel's shipped init chain (flare-edge#2210) The rig's stage-2 init starts /usr/bin/warden-ui directly as root, so it never ran S03warden-accounts, S99lvgl or warden-ui-run: no privilege drop, respawn loop or safe mode was exercised, and the BusyBox setpriv bug of flare-edge #1903 left every rebuild image without a UI while CI was green. - mkimage.sh: ROOTFS_OVERLAY lays a directory of panel files over the rootfs of both slots, modes kept. Only etc/ and usr/ at its top, no symlinks; a refused overlay writes no image. - sbin/init: with warden.initchain on the command line it runs /etc/init.d/S00-S09 before the bus and S10-S99 after the payload daemons, in place of the direct UI start (warden_init_chain in warden-lib.sh). The splash handover is marked done and warden-ui-run gets "-b fbdev". A chain boot without scripts prints WARDEN-QEMU-INITCHAIN-EMPTY and starts no UI. - warden_rig_bus_owners: when the accounts exist, cred/ui belongs to warden-ui and the cred directory to group warden-bus, as S10bus does. - Tests: init-chain-test.sh (19 checks, also under busybox sh) and rootfs-overlay.sh (17 scenarios, images read back with debugfs), both in CI. Refs flare-edge#2210 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG --- .github/workflows/ci.yml | 12 +++ qemu/README.md | 14 +++ qemu/mkimage.sh | 25 ++++++ qemu/rootfs/etc/warden-lib.sh | 61 +++++++++++++ qemu/rootfs/sbin/init | 30 ++++++- qemu/tests/init-chain-test.sh | 124 +++++++++++++++++++++++++++ qemu/tests/rootfs-overlay.sh | 155 ++++++++++++++++++++++++++++++++++ 7 files changed, 419 insertions(+), 2 deletions(-) create mode 100755 qemu/tests/init-chain-test.sh create mode 100755 qemu/tests/rootfs-overlay.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a516cc..935a84f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -170,6 +170,18 @@ jobs: if command -v busybox >/dev/null; then WARDEN_TEST_SH="busybox sh" bash qemu/tests/ctl-bridge-test.sh fi + - name: rig init boots through the shipped init chain (flare-edge#2210) + # warden_init_chain against stub scripts and the warden.initchain + # wiring in sbin/init; once more under busybox sh, the rig's own shell. + run: | + bash qemu/tests/init-chain-test.sh + if command -v busybox >/dev/null; then + WARDEN_TEST_SH="busybox sh" bash qemu/tests/init-chain-test.sh + fi + - name: mkimage.sh ROOTFS_OVERLAY regression test (flare-edge#2210) + # The panel's scripts land in both slots with their modes; an overlay + # reaching outside etc/ and usr/, or holding a symlink, writes no image. + run: bash qemu/tests/rootfs-overlay.sh - name: mkimage.sh SEED_DIR regression test # Only ui-drive.sh --seed (a real VM boot) exercises this hook # otherwise; this builds the same unprivileged mkfs.ext4 image and diff --git a/qemu/README.md b/qemu/README.md index 1958847..c240ad7 100644 --- a/qemu/README.md +++ b/qemu/README.md @@ -95,6 +95,18 @@ does on a panel instead of rejecting every attempt. `qemu_stage_rootfs()` the executable bit, so the checked-out source file's own mode depends on the checking-out umask and cannot be trusted to arrive non-world-readable. +`--append warden.initchain` boots the UI the way a panel does (flare-edge +#2210). The caller lays the panel's own scripts over the rootfs with +`ROOTFS_OVERLAY= mkimage.sh` (only `etc/` and `usr/` at its top, no +symlinks). Stage-2 init then starts `/etc/init.d/S00`-`S09` with `start` +before the bus (S03warden-accounts creates the platform accounts, and the +bus hands `cred/ui` to `warden-ui`), and `S10`-`S99` after the payload +daemons in place of its direct root start of `warden-ui`. S99lvgl then runs +`warden-ui-run`, which drops the UI to its account and respawns it. Rig +differences: the splash handover is marked done (no S09splash) and +warden-ui-run passes `-b fbdev`, not the panel's `-b drm`. A chain boot +with no script prints `WARDEN-QEMU-INITCHAIN-EMPTY` and starts no UI. + A flow seed may contain `qemu-flow-setup.sh`. Stage-2 init runs it inside the disposable guest after mounting userdata and before starting daemons or the UI. A nonzero exit stops the boot. Use it only for test devices and commands @@ -116,6 +128,8 @@ All take the virt-fragment ``; `FLARE_EDGE=` where noted. | `ui-drive.sh