QEMU rig init ignores reboot/poweroff/halt requests #5

Closed
opened 2026-09-28 11:13:30 -06:00 by noah · 0 comments
Owner

The QEMU rig's stage-2 init (qemu/rootfs/sbin/init) is a busybox sh script running as PID 1. Busybox reboot, poweroff and halt work by signalling PID 1 (SIGTERM, SIGUSR2, SIGUSR1), and the kernel drops any signal PID 1 has no handler for. So on the rig a plain reboot does nothing, while a panel's busybox init honours it.

Found writing blueflare/flare-edge#96's flow: Settings > System > Reboot calls warden_reboot(), which runs system("reboot") and falls back to reboot -f only if that fails. Sending the signal succeeds, so on the rig nothing happens and the flow's expect_reboot times out ("no reboot within 60s"; the console shows no restart line). flared's BOOTSLOT path passed on the same rig only because it always follows up with reboot -f.

Also: the init idles in while :; do sleep 3600; done, so even a trap would run only after the current sleep returns.

Fix

Trap TERM/USR2/USR1 in the init and perform the matching -f action after a sync, and idle with sleep & wait so the trap runs at once. Regression test: a qemu test that runs a plain reboot in the guest and expects the orderly restart.

The QEMU rig's stage-2 init (`qemu/rootfs/sbin/init`) is a busybox `sh` script running as PID 1. Busybox `reboot`, `poweroff` and `halt` work by signalling PID 1 (SIGTERM, SIGUSR2, SIGUSR1), and the kernel drops any signal PID 1 has no handler for. So on the rig a plain `reboot` does nothing, while a panel's busybox init honours it. Found writing blueflare/flare-edge#96's flow: Settings > System > Reboot calls `warden_reboot()`, which runs `system("reboot")` and falls back to `reboot -f` only if that fails. Sending the signal succeeds, so on the rig nothing happens and the flow's `expect_reboot` times out ("no reboot within 60s"; the console shows no restart line). flared's BOOTSLOT path passed on the same rig only because it always follows up with `reboot -f`. Also: the init idles in `while :; do sleep 3600; done`, so even a trap would run only after the current sleep returns. ## Fix Trap TERM/USR2/USR1 in the init and perform the matching `-f` action after a sync, and idle with `sleep & wait` so the trap runs at once. Regression test: a qemu test that runs a plain `reboot` in the guest and expects the orderly restart.
noah closed this issue 2026-09-28 13:07:22 -06:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: blueflare/bfe-core1106-sdk#5