Skip to content

microvm tests: stream OpenVMM transcripts to disk as they are read - #659

Open
Pedro Henrique Penna (ppenna) wants to merge 5 commits into
devfrom
ppenna/stream-openvmm-transcript-20261020
Open

Pedro Henrique Penna (ppenna) wants to merge 5 commits into
devfrom
ppenna/stream-openvmm-transcript-20261020

Conversation

@ppenna

Copy link
Copy Markdown
Contributor

Replaces #588 by Jay (@jay23606), whose commits are carried here unchanged (head 2634167ff). It is opened from a microsoft/nvx branch so that CI runs on a stable head: automated rebases of the original kept superseding its runs.


Fixes #176.

Summary

  • OpenvmmProcess kept the transcript in memory and wrote it only from wait or close. A run that was terminated before cleanup left no transcript, or a truncated one, even though its output had been read.
  • The transcript is now opened before OpenVMM starts. Each consumed chunk is appended and flushed as it is read, and wait and close only close the file. Bytes are written in the order received, with no prefixes and no rewrite at cleanup, so nothing is duplicated.
  • A transcript that cannot be created stops the run before OpenVMM starts. Output still queued at close is written too.
  • In-memory output, marker search and timeout behavior are unchanged.
  • Scope: OpenvmmProcess only. TcpConsole has no transcript path, and the benchmark helpers in benchmark.py are not changed. Those are follow-ups.

Test

  • Three new tests: growth while the process runs (fails before the change, since the file did not exist until wait), a transcript that cannot be created (fails before the change), and output delivered after the last wait.
  • A real Windows child process printed BOOT, then LATE three seconds later. The transcript contained BOOT while the child was still running, and the final transcript matched the output.
  • test_microvm_tests: 193 tests. The dev baseline (190 tests) has the same nine failures and errors in host-loopback, private network ingress and SMP timer tests. They are unrelated to the transcript code and present on untouched dev.
  • ruff check and format are clean.
  • Not run: the PTY path on Linux, which needs a Linux host.

🤖 Generated with Claude Code

Jay (jay23606) and others added 4 commits October 20, 2026 16:11
OpenvmmProcess kept the transcript in memory and wrote it only from wait or
close, so a run terminated before cleanup left no transcript, or a truncated
one, even though output had been read.

Open the transcript before OpenVMM starts, append each consumed chunk and flush
it, and close the file at wait or close. Bytes are written in the order received,
with no prefixes and no duplication at cleanup. An error creating the transcript
stops the run before OpenVMM starts. Output still queued at close is written
too. The in-memory output and marker search are unchanged.

Adds tests for growth while the process runs, a transcript that cannot be
created, and output delivered after the last wait.

Fixes #176

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Signed-off-by: jay23606 <4602056+jay23606@users.noreply.github.com>
… release the transcript

close drained the reader's queue before the interaction had stopped, so a final
chunk queued during shutdown was lost from both output and transcript. A write
failure during that drain also skipped closing the interaction and the transcript.

Stop the interaction first, then drain, and release the transcript in a finally
block.

Adds regression tests for output queued during interaction close and for a
transcript write failure.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Signed-off-by: jay23606 <4602056+jay23606@users.noreply.github.com>
If InteractiveProcess.close raised, the drain was skipped and chunks still queued
were missing from both output and the transcript. Drain in a finally around the
interaction shutdown, so the transcript is complete whichever step fails.

Adds a regression test with queued output and a failing interaction shutdown.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Signed-off-by: jay23606 <4602056+jay23606@users.noreply.github.com>
_drain_available stopped at the first failed transcript write, so chunks
still queued behind it never reached process.output. Keep collecting them
in memory and re-raise the first error once the queue is empty.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Signed-off-by: jay23606 <4602056+jay23606@users.noreply.github.com>

Copilot AI left a comment

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.

🟢 Approval recommended

Static review identified no blocking issues; runtime tests were not executed.

No open issues 🎉

What changed in this PR

Updates OpenvmmProcess to persist transcripts incrementally, preserving diagnostics if a run ends before normal cleanup.

Changes:

  • Opens the transcript before launch and flushes each consumed chunk.
  • Drains queued output during cleanup and releases resources on write failures.
  • Adds regression tests for transcript growth and cleanup failures.
File Description
scripts/​test_microvm_tests.py Tests incremental capture, delayed output, and failure handling.
scripts/​nvx_tools/​openvmm_process.py Streams transcript bytes and strengthens cleanup handling.

Review effort: Balanced

The signature of the test that keeps every queued chunk when the
transcript write fails reached 90 columns, past the 88-column limit,
so ruff format --check failed the Lint, typing, and formatting job.
Wrap it as ruff format does, like the file's other long signatures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 20, 2026 21:05

Copilot AI left a comment

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.

🟢 Approval recommended

Static review identified no blocking issues in the focused changes; runtime tests were not executed during review.

No open issues 🎉

Review effort: Balanced

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.

Stream OpenVMM test transcripts to disk incrementally

3 participants