Add console tests and build on windows#127
Merged
dmcgowan merged 3 commits intocontainerd:mainfrom Mar 20, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the libkrun VM backend to better support Windows builds and adds integration tests that capture and assert on VM console output to improve startup diagnostics.
Changes:
- Add
ConsoleWriterstart option to tee VM console output for tests/diagnostics. - Introduce Windows-specific implementations for dynamic library loading and console output plumbing (named pipe), with Unix counterparts for parity.
- Improve Windows compatibility in integration test harness PATH handling and add a Windows cross-build target for the shim.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/vm/vm.go | Adds ConsoleWriter to VM start options and a WithConsoleWriter helper. |
| internal/vm/libkrun/krun.go | Switches lib loading/closing calls to OS-specific wrappers. |
| internal/vm/libkrun/instance.go | Uses setupConsole, adds optional console teeing, and adjusts Windows timing defaults. |
| internal/vm/libkrun/dlfcn_windows.go | Implements dlOpen/dlClose using LoadLibrary/FreeLibrary. |
| internal/vm/libkrun/dlfcn_unix.go | Implements dlOpen/dlClose using purego on non-Windows. |
| internal/vm/libkrun/console_windows.go | Implements console setup via a Windows named pipe and background connector. |
| internal/vm/libkrun/console_unix.go | Implements console setup via FIFO + SetConsole on non-Windows. |
| integration/vm_test.go | Adds console output and boot diagnostic integration tests. |
| integration/main_test.go | Makes PATH injection portable on Windows and adds a runWithVMOpts helper. |
| Makefile | Adds a Windows cross-build target for containerd-shim-nerdbox-v1.exe. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
520b093 to
0238c24
Compare
Member
Author
|
We should probably get 131 in first and I'll rebase this one |
0238c24 to
f04b143
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Make the VM layer compile and work on Windows using a krun.dll which
provides the same krun_* C API
Platform-specific abstractions (each has a Unix and Windows variant):
- console_{unix,windows}.go: Kernel console output. Unix uses a FIFO;
Windows uses a named pipe via NamedPipeBackend for virtio-console.
Changes to shared code:
- krun.go: Use dlOpen/dlClose instead of purego.Dlopen/Dlclose.
- instance.go: Add krun.dll to library search. Skip os.Stat for
socket detection on Windows (AF_UNIX sockets aren't filesystem
entries). Use longer TTRPC ping deadlines and VM startup timeout
on Windows (WHP has higher overhead). Add WithConsoleWriter start
option for capturing console output in tests. Relative socket
paths are used on all platforms to stay within the 108-byte
AF_UNIX limit.
- vm.go: Add WithConsoleWriter StartOpt.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Derek McGowan <derek@mcg.dev>
Add two new integration tests and a helper for VM debugging: - TestConsoleOutput: Boots a VM with console capture via WithConsoleWriter and verifies kernel boot messages appear. Validates the console plumbing (FIFO on Unix, named pipe on Windows). - TestBootDiagnostics: Boots a VM, measures boot timing, and queries system info via TTRPC. On failure, dumps console output to help diagnose boot issues. - runWithVMOpts: Helper that passes StartOpt to the VM, used by the new tests to inject WithConsoleWriter. Also fix os.PathListSeparator in TestMain (was hardcoded ":"). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Derek McGowan <derek@mcg.dev>
Add Makefile target for building containerd-shim-nerdbox-v1.exe via GOOS=windows GOARCH=amd64 cross-compilation. Promote github.com/Microsoft/go-winio from indirect to direct dependency (used by console_windows.go and io_copystreams_windows.go). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Derek McGowan <derek@mcg.dev>
f04b143 to
1d8eb13
Compare
Kern--
approved these changes
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates the vm instance to support building on Windows. Adds test for checking the console and start up.