Improve QEMU execution - #382
henrybear327 wants to merge 2 commits into
Conversation
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.
There was a problem hiding this comment.
3 issues found across 5 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/test-qemu-runner.sh">
<violation number="1" location="tests/test-qemu-runner.sh:94">
P2: The `kill -0`-based `alive()` reports a killed-but-unreaped child as "alive": `$own` is a child of this test script, killed by the separate `bash $RUNNER stop` subprocess, so it stays a zombie until the script reaps it and `kill -0` keeps returning success. The assertion `... dead "$(alive "$own")"` therefore always fails (verified: the runner reports `(got alive, want dead) [ FAIL ]` and exits 1), which fails the `test-qemu-runner` lane wired into `make check`. Reap the child before asserting liveness.</violation>
<violation number="2" location="tests/test-qemu-runner.sh:122">
P3: The failed-start case does not verify run-directory cleanup: `qemu_write_state` is never reached, so the state-file check passes regardless of whether `qemu_fail_start` removes the generated directory. Make the stub create or record `-pidfile`, then assert that its run directory is gone.</violation>
</file>
<file name="tests/lib/qemu-ssh.sh">
<violation number="1" location="tests/lib/qemu-ssh.sh:21">
P2: On hosts whose `ssh-agent` contains several identities, `-i` does not restrict authentication to `QEMU_SSH_KEY`; Dropbear can exhaust its authentication attempts before trying the VM key, causing every QEMU SSH command to fail. Add `IdentitiesOnly=yes` to this shared option list.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| -o ConnectTimeout=10 | ||
| -o ServerAliveInterval=10 | ||
| -o ServerAliveCountMax=6 | ||
| -i "$QEMU_SSH_KEY" |
There was a problem hiding this comment.
P2: On hosts whose ssh-agent contains several identities, -i does not restrict authentication to QEMU_SSH_KEY; Dropbear can exhaust its authentication attempts before trying the VM key, causing every QEMU SSH command to fail. Add IdentitiesOnly=yes to this shared option list.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/lib/qemu-ssh.sh, line 21:
<comment>On hosts whose `ssh-agent` contains several identities, `-i` does not restrict authentication to `QEMU_SSH_KEY`; Dropbear can exhaust its authentication attempts before trying the VM key, causing every QEMU SSH command to fail. Add `IdentitiesOnly=yes` to this shared option list.</comment>
<file context>
@@ -0,0 +1,24 @@
+ -o ConnectTimeout=10
+ -o ServerAliveInterval=10
+ -o ServerAliveCountMax=6
+ -i "$QEMU_SSH_KEY"
+ -p "$QEMU_PORT"
+ )
</file context>
| rc=0 | ||
| bash "$RUNNER" stop --state-file "$state" > /dev/null 2>&1 || rc=$? | ||
| check "stop returns 0 for the run's own process" 0 "$rc" | ||
| check "the run's own process is terminated" dead "$(alive "$own")" |
There was a problem hiding this comment.
P2: The kill -0-based alive() reports a killed-but-unreaped child as "alive": $own is a child of this test script, killed by the separate bash $RUNNER stop subprocess, so it stays a zombie until the script reaps it and kill -0 keeps returning success. The assertion ... dead "$(alive "$own")" therefore always fails (verified: the runner reports (got alive, want dead) [ FAIL ] and exits 1), which fails the test-qemu-runner lane wired into make check. Reap the child before asserting liveness.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/test-qemu-runner.sh, line 94:
<comment>The `kill -0`-based `alive()` reports a killed-but-unreaped child as "alive": `$own` is a child of this test script, killed by the separate `bash $RUNNER stop` subprocess, so it stays a zombie until the script reaps it and `kill -0` keeps returning success. The assertion `... dead "$(alive "$own")"` therefore always fails (verified: the runner reports `(got alive, want dead) [ FAIL ]` and exits 1), which fails the `test-qemu-runner` lane wired into `make check`. Reap the child before asserting liveness.</comment>
<file context>
@@ -0,0 +1,125 @@
+rc=0
+bash "$RUNNER" stop --state-file "$state" > /dev/null 2>&1 || rc=$?
+check "stop returns 0 for the run's own process" 0 "$rc"
+check "the run's own process is terminated" dead "$(alive "$own")"
+check "stop removes the state file after a kill" gone "$(present "$state")"
+
</file context>
| check "the run's own process is terminated" dead "$(alive "$own")" | |
| wait "$own" 2> /dev/null | |
| check "the run's own process is terminated" dead "$(alive "$own")" |
| check "the failure names the timeout" yes "$(has "$out" "did not boot")" | ||
| check "the serial console reaches the caller" yes "$(has "$out" SERIAL-MARKER)" | ||
| check "qemu's own output reaches the caller" yes "$(has "$out" STDERR-MARKER)" | ||
| check "a failed start writes no state file" gone "$(present "$state")" |
There was a problem hiding this comment.
P3: The failed-start case does not verify run-directory cleanup: qemu_write_state is never reached, so the state-file check passes regardless of whether qemu_fail_start removes the generated directory. Make the stub create or record -pidfile, then assert that its run directory is gone.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/test-qemu-runner.sh, line 122:
<comment>The failed-start case does not verify run-directory cleanup: `qemu_write_state` is never reached, so the state-file check passes regardless of whether `qemu_fail_start` removes the generated directory. Make the stub create or record `-pidfile`, then assert that its run directory is gone.</comment>
<file context>
@@ -0,0 +1,125 @@
+check "the failure names the timeout" yes "$(has "$out" "did not boot")"
+check "the serial console reaches the caller" yes "$(has "$out" SERIAL-MARKER)"
+check "qemu's own output reaches the caller" yes "$(has "$out" STDERR-MARKER)"
+check "a failed start writes no state file" gone "$(present "$state")"
+
+report_summary
</file context>
qemu-runner.sh writes a state file so start and stop can run in separate shells, and stop signals the recorded pid only while its argv still names the run's pidfile. The command that starts a VM installs the cleanup trap: the old source-time trap 'qemu_stop' EXIT replaced the cleanup_fixtures; cleanup_qemu trap test-matrix.sh registers earlier, since a bare trap ... EXIT replaces the chain rather than adding to it. test-matrix.sh now marks the VM active before qemu_start, so its own trap covers the boot window the removed trap used to, and clears the mark if the start fails. A start whose guest /tmp cannot be prepared fails, and a failed start prints the serial console and qemu's own output before its run directory goes. tests/test-qemu-runner.sh pins this against stand-ins, so no VM boots: a recycled pid, a process whose argv names the pidfile, and a start that never opens the port.
a6ae8ef to
a886dd0
Compare
Improve error reporting from qemu execution, in preparation for conformance test failed runs.
Summary by cubic
Improves
qemu-runner.shlifecycle 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 PATHrecords the port, key, and pidfile;stop --state-file PATHvalidates process identity before signaling and preserves state if SIGKILL fails./tmpsetup now report the serial console and QEMU output before cleanup.test-qemu-runner.shruns in thechecklane with stand-ins.Migration
--state-file PATHto bothstartandstopfor cross-shell use; without it,stopcannot find the VM.Written for commit a886dd0. Summary will update on new commits.