qemu: start the device bus when the payload carries a broker #28

Merged
noah merged 1 commits from rb/lf-rig-bus into rebuild 2026-10-26 16:00:21 -06:00
Owner

Stage-2 init starts the panel's device bus when the payload carries a broker. This is the first step of the rig half of flare-edge #1754 and #1050.

A panel runs one mosquitto on /run/warden/bus/bus.sock (flare-edge S10bus), and every daemon and the UI talk over it. The rig had no broker, so the Rust warden-modbus and the UI's bus client had nothing to dial. With this change, warden_rig_bus (qemu/rootfs/etc/warden-lib.sh) runs before the payload daemon loop:

  • It does nothing when /usr/bin/mosquitto is absent. Today's flare-edge payload has no broker, so this PR changes no boot.
  • It uses the panel's paths: the socket at sock/bus.sock with the bus.sock link, and a fresh 0400 credential file per bus user at cred/<user>. The users are the panel's users and bundled-users. A client reads its file at every CONNECT, as on the panel.
  • The broker settings are the panel's, minus the password file, ACL and retain plugin. The rig broker takes any user: the rig is a test instrument and everything in it runs as root. A static broker cannot load plugins anyway.
  • It waits for the socket (10 s bound) so the daemons find it on their first dial. If the broker exits or never listens, the console says so, then the boot goes on.

The flare-edge side comes in a later PR: the payload ships the static armhf broker from tools/mosquitto-build.sh armhf, and the submodule pin moves to this commit.

Tests

qemu/tests/init-rig-bus-test.sh (new CI step, run under sh and busybox sh) checks these cases:

  • no broker: nothing is created and the function stays silent
  • a listening stub broker: the layout, file modes, 64-hex secrets that differ per user, and a config with no password file, ACL or plugin
  • a broker that exits, or never listens: the failure is reported, within the bound
  • a user name holding a slash, or starting with a dot: no file is written
  • init order: the bus starts before the payload daemons

WARDEN_TEST_MOSQUITTO_DIR adds a real mosquitto 2.0.22 run: one message goes from modbus to ui, and both log in with their credential files.

$ lane-remote LF <worktree> -- WARDEN_TEST_MOSQUITTO_DIR=~/.cache/warden-mosquitto/host-2.0.22/bin bash qemu/tests/init-rig-bus-test.sh
22 x [PASS] ... PASS: rig bus (rc=0)
$ ... WARDEN_TEST_SH="busybox sh" (same, real broker included): PASS: rig bus (rc=0)
$ ... without the real broker: [SKIP] real broker, PASS: rig bus
init-daemon-order-test rc=0, init-power-signals-test rc=0, ctl-bridge-test rc=0
$ shellcheck -x qemu/tests/init-rig-bus-test.sh qemu/rootfs/etc/warden-lib.sh qemu/rootfs/sbin/init   (0.10.0): rc=0

Refs flare-edge #1754, #1050.

Generated with Claude Code
https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG

Stage-2 init starts the panel's device bus when the payload carries a broker. This is the first step of the rig half of flare-edge #1754 and #1050. A panel runs one mosquitto on `/run/warden/bus/bus.sock` (flare-edge `S10bus`), and every daemon and the UI talk over it. The rig had no broker, so the Rust warden-modbus and the UI's bus client had nothing to dial. With this change, `warden_rig_bus` (qemu/rootfs/etc/warden-lib.sh) runs before the payload daemon loop: - It does nothing when `/usr/bin/mosquitto` is absent. Today's flare-edge payload has no broker, so this PR changes no boot. - It uses the panel's paths: the socket at `sock/bus.sock` with the `bus.sock` link, and a fresh 0400 credential file per bus user at `cred/<user>`. The users are the panel's `users` and `bundled-users`. A client reads its file at every CONNECT, as on the panel. - The broker settings are the panel's, minus the password file, ACL and retain plugin. The rig broker takes any user: the rig is a test instrument and everything in it runs as root. A static broker cannot load plugins anyway. - It waits for the socket (10 s bound) so the daemons find it on their first dial. If the broker exits or never listens, the console says so, then the boot goes on. The flare-edge side comes in a later PR: the payload ships the static armhf broker from `tools/mosquitto-build.sh armhf`, and the submodule pin moves to this commit. ## Tests `qemu/tests/init-rig-bus-test.sh` (new CI step, run under sh and busybox sh) checks these cases: - no broker: nothing is created and the function stays silent - a listening stub broker: the layout, file modes, 64-hex secrets that differ per user, and a config with no password file, ACL or plugin - a broker that exits, or never listens: the failure is reported, within the bound - a user name holding a slash, or starting with a dot: no file is written - init order: the bus starts before the payload daemons `WARDEN_TEST_MOSQUITTO_DIR` adds a real mosquitto 2.0.22 run: one message goes from `modbus` to `ui`, and both log in with their credential files. ``` $ lane-remote LF <worktree> -- WARDEN_TEST_MOSQUITTO_DIR=~/.cache/warden-mosquitto/host-2.0.22/bin bash qemu/tests/init-rig-bus-test.sh 22 x [PASS] ... PASS: rig bus (rc=0) $ ... WARDEN_TEST_SH="busybox sh" (same, real broker included): PASS: rig bus (rc=0) $ ... without the real broker: [SKIP] real broker, PASS: rig bus init-daemon-order-test rc=0, init-power-signals-test rc=0, ctl-bridge-test rc=0 $ shellcheck -x qemu/tests/init-rig-bus-test.sh qemu/rootfs/etc/warden-lib.sh qemu/rootfs/sbin/init (0.10.0): rc=0 ``` Refs flare-edge #1754, #1050. Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG
noah added 1 commit 2026-10-26 15:33:43 -06:00
qemu: start the device bus when the payload carries a broker
ci / test (push) Successful in 28s
ci / prune-artifacts (push) Skipped
ci / patches-apply (push) Successful in 1m2s
ci / mcdc (push) Successful in 29s
ci / bench (push) Successful in 12s
ci / mcdc (pull_request) Successful in 11s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / kernel-build (push) Skipped
ci / quality (push) Successful in 27s
ci / badges (push) Skipped
ci / qemu-tools (pull_request) Successful in 1m9s
ci / patches-apply (pull_request) Successful in 57s
ci / test (pull_request) Successful in 26s
ci / bench (pull_request) Successful in 16s
ci / quality (pull_request) Successful in 1m29s
ci / kernel-symbols (pull_request) Successful in 6m50s
ci / qemu-tools (push) Successful in 2m15s
ci / kernel-symbols (push) Successful in 4m42s
ci / badges (pull_request) Skipped
5494b87dc3
A panel runs one mosquitto on /run/warden/bus/bus.sock (flare-edge S10bus)
and every daemon and the UI talk over it; the rig had no broker, so the
Rust warden-modbus and the UI's bus client could not run there (flare-edge
#1754, the #1050 QEMU half). Stage-2 init now starts the broker before the
payload daemons when the payload carries a static mosquitto, with the
panel's paths: the socket under sock/ with the bus.sock link, and a fresh
0400 credential file per bus user under cred/. The rig broker takes any
user and loads no plugin (the rig is a test instrument; a static broker
loads none). A payload without a broker boots as before.

qemu/tests/init-rig-bus-test.sh covers no broker, a listening broker (layout,
modes, config), a broker that exits or never listens, bad user names and the
init order, under sh and busybox sh; with WARDEN_TEST_MOSQUITTO_DIR a real
mosquitto carries a message between two users logged in by credential file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG
noah merged commit eeb779b41b into rebuild 2026-10-26 16:00:21 -06:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: blueflare/bfe-core1106-sdk#28