Skip to content

Improve QEMU execution - #382

Open
henrybear327 wants to merge 3 commits into
sysprog21:mainfrom
henrybear327:conf/qemu-runner
Open

henrybear327 wants to merge 3 commits into
sysprog21:mainfrom
henrybear327:conf/qemu-runner

Conversation

@henrybear327

@henrybear327 henrybear327 commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Improve error reporting from qemu execution, in preparation for conformance test failed runs.


Summary by cubic

Improves qemu-runner.sh lifecycle handling and diagnostics so a VM can be started and stopped from different shells without risking cleanup of a recycled PID. It also centralizes the test VM's SSH options and adds no-VM regression coverage.

  • start --state-file PATH records the port, key, and pidfile; stop --state-file PATH validates process identity before signaling and preserves state if SIGKILL fails.
  • Failed boots and guest /tmp setup now report the serial console and QEMU output before cleanup.
  • Both QEMU lanes share one SSH option list (their keep-alive settings had drifted), and IdentitiesOnly=yes limits offers to the VM key so agent-held keys can't trip the guest dropbear's 15-query cap.
  • Sourcing the script no longer replaces the caller's EXIT trap, and test-qemu-runner.sh covers start/stop with stand-ins in the check lane.

Migration

  • Pass --state-file PATH to both start and stop for cross-shell use; without it, stop cannot find the VM.

Written for commit f920b8b. Summary will update on new commits.

Review in cubic

qemu-runner.sh and test-matrix.sh each spelled the ssh option list for
the test VM, and the copies had drifted: the runner kept the peer alive
for 10 s x 6 and the matrix for 15 s x 4. tests/lib/qemu-ssh.sh now
holds the one list. qemu_ssh_opts fills QEMU_SSH_OPTS at call time so a
caller can still wrap its ssh in timeout(1), which cannot wrap a shell
function. Both lanes keep the 60 s dead-peer budget.
@henrybear327
henrybear327 requested a review from jserv September 14, 2026 16:36
@henrybear327 henrybear327 self-assigned this Sep 14, 2026
cubic-dev-ai[bot]

This comment was marked as resolved.

Comment thread tests/test-qemu-runner.sh Outdated
@henrybear327
henrybear327 force-pushed the conf/qemu-runner branch 2 times, most recently from a886dd0 to b6de30c Compare September 16, 2026 09:39
Run as separate commands, start stopped its VM on exit and stop had no
record of it. start --state-file now keeps the VM and records its port
and key for a later shell and its pidfile for stop --state-file, which
signals the pid only while its argv still names that pidfile, since the
pid may have been reused. A pid that survives SIGKILL keeps its pidfile
and state file so a later stop can retry.

The trap 'qemu_stop' EXIT set when sourcing qemu-runner.sh replaced
test-matrix.sh's cleanup trap, so only start and exec set it now;
test-matrix.sh marks the VM active before qemu_start so its own trap
covers the boot.

A failed start now prints the tail of qemu's output and serial console
before removing the run directory, so the caller can see why the VM did
not come up.

Add tests/test-qemu-runner.sh to make check.
ssh offers every identity its agent holds before a -i key the agent
lacks. The fixture guest's Dropbear v2024.86 never counts a rejected
public-key query, but dropbear 2026.90 caps them at MAX_PUBKEY_QUERIES
(15), so a host agent holding that many keys would fail every
qemu_exec and run_qemu call once the Alpine fixture moves past it.
IdentitiesOnly=yes limits the offer to QEMU_SSH_KEY.
@henrybear327
henrybear327 requested a review from jserv September 16, 2026 14:23
Comment thread tests/qemu-runner.sh
if ! (echo > /dev/tcp/127.0.0.1/"$QEMU_PORT") 2> /dev/null; then
echo "qemu-runner: VM did not boot within ${QEMU_BOOT_TIMEOUT}s" >&2
qemu_stop
qemu_fail_start "VM did not boot within ${QEMU_BOOT_TIMEOUT}s"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When qemu exits right away (hvf unavailable, a bad -cpu, a missing kernel), this loop still waits the full QEMU_BOOT_TIMEOUT (90s by default) and then reports "did not boot", while the real cause is already in qemu.log, which this change starts capturing. Keep qemu_pid=$! after the launch and fail early inside the wait loop, before its sleep 1: kill -0 "$qemu_pid" 2> /dev/null || { qemu_fail_start "qemu exited before the guest booted"; return 1; }.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants