Skip to content

Move to Hyperlight 0.18's virtqueue transport - #142

Merged
danbugs merged 4 commits into
mainfrom
hyperlight-v0.18-virtio
Oct 15, 2026
Merged

danbugs merged 4 commits into
mainfrom
hyperlight-v0.18-virtio

Conversation

@danbugs

@danbugs danbugs commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Moves hluk and its kernel from the PEB I/O stacks to Hyperlight 0.18's virtqueue transport. hyperlight-host and hyperlight-common are 0.18 from crates.io, and the kernel submodule is unikraft/unikraft's plat-hyperlight-v2 at 3c363e9d, where the guest side of the transport has landed. Rebased on main after #145 and #146, so standard error stays a stream of its own and output stays within output_limit.

  • Kernel: a C packed-ring driver for G2H/H2G; host function calls, guest function calls, snapshot checkpoints and the boot checkpoint move onto it.
  • Console output and stdin travel as bytes: HostWrite/HostWriteErr replace the unreleased HostPrint/HostPrintErr, so output that isn't UTF-8 no longer fails the call. Each stream is decoded on its own, with a character split between writes joined, under output_limit and echo_output. A host without HostWriteErr still gets standard error through HostWrite.
  • hostfs moves 64 KiB per host call (reads about 55%, writes about 50% faster than v0.17); host-mount paths that aren't UTF-8 or are over 1,023 bytes fail with EILSEQ / ENAMETOOLONG.
  • A host call carries 69,620 bytes, a guest function call 73,716.
  • Snapshots from earlier builds are refused (SNAPSHOT_CONTRACT 5); native kernels must be rebuilt.

HostPrintErr and without_host_print_err from #145 are renamed to HostWriteErr and without_host_write_err; neither has been released. #145's "writes cut into 4 KiB host calls" CHANGELOG entry is dropped, since the byte transport replaces that behaviour before it ever shipped.

@danbugs danbugs added the ci/arm64 Run the arm64 guest tests (self-hosted KVM and HVF runners) label Oct 6, 2026
@danbugs danbugs closed this Oct 7, 2026
@danbugs danbugs reopened this Oct 7, 2026
@danbugs
danbugs marked this pull request as ready for review October 7, 2026 20:51
Copilot AI balanced review requested due to automatic review settings October 7, 2026 20:51
@danbugs danbugs changed the title Move to Hyperlight's virtqueue transport (v0.18) [DO NOT MERGE] Move to Hyperlight's virtqueue transport (v0.18) Oct 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The transport and snapshot migration needs cross-platform human validation, and output finalization remains unresolved.

1 open finding
What changed in this PR

Migrates hluk’s host–guest communication to Hyperlight’s virtqueue transport, preparing for v0.18.

Changes:

  • Configures transport pools and increases hostfs transfers to 64 KiB.
  • Adds byte-based console I/O and regression tests.
  • Updates snapshot compatibility, dependency pins, and protocol documentation.
File Description
tests/​step.rs Updates transport terminology in comments.
tests/​quickjs.rs Adjusts oversized-result test boundaries.
tests/​python.rs Tests console bytes, stdin, and path limits.
src/​lib.rs Migrates transport, console handling, and encoding tests.
src/​hostfs.rs Increases transfer chunks to 64 KiB.
examples/​python/​fs_large.py Exercises larger transfer chunks.
drivers/​hl_env.h Updates buffer-sizing comments.
drivers/​hl_driver.h Documents transport-derived limits.
docs/​RELEASE.md Updates snapshot compatibility guidance.
docs/​net.md Documents revised network transfer limits.
docs/​fs.md Documents chunk sizes and path errors.
docs/​driver.md Updates driver protocol limits.
docs/​calls.md Explains virtqueues and performance measurements.
demos/​pptx-gen/​Cargo.lock Refreshes demo dependencies.
CHANGELOG.md Records migration and compatibility changes.
Cargo.toml Pins temporary Hyperlight fork dependencies.
Cargo.lock Locks updated dependencies.
build.rs Bumps the snapshot contract.
.gitmodules Selects the temporary virtqueue kernel fork.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/lib.rs Outdated
Hyperlight 0.18 replaces the PEB's I/O stacks with two VIRTIO packed
rings in scratch memory.  hyperlight-host and hyperlight-common move to
0.18, and the kernel moves with it, to unikraft's plat-hyperlight-v2
with the virtqueue transport; both kernels and the native test fixture
are rebuilt from it.

Size the transport pools for 64 KiB transfers instead of the I/O
stacks.  Each half of the guest-to-host pool, a host call's request
and its reply, holds 64 KiB plus framing, rounded up to 18 pages, so
HOST_CALL_MAX is now what the guest computes from them, 69,620 bytes;
the host-to-guest pool holds a guest function call of 73,716.  The
quickjs result-size test follows the new limits.

Console output comes in through HostWrite(Vec<u8>) and
HostWriteErr(Vec<u8>) instead of the strings HostPrint and
HostPrintErr, which failed on output that was not UTF-8.  Each stream
is decoded on its own as it arrives, a character split between writes
held until its end comes and bytes that are not UTF-8 read as U+FFFD;
standard output goes to stdout and drain_output(), standard error to
stderr, drain_output() and drain_stderr(), as before, under
output_limit and echo_output.  A character still cut short reads as
U+FFFD when the process exits or a call poisons the sandbox.  A host
without HostWriteErr still gets standard error through HostWrite
(SandboxBuilder::without_host_write_err, for testing), and HostPrint,
which this kernel no longer calls, is taken as standard output.
ReadStdin hands over bytes, not a lossy string.

MultiUseSandbox is now Sandbox.  SNAPSHOT_CONTRACT goes to 5: the host
transport changed, and snapshots from earlier builds are refused.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
The guest reads and writes host files in chunks of the size
GetHostFsChunkSize returns, 32 KiB.  Over the virtqueues a host call
carries 69,620 bytes, and a 64 KiB chunk reads and writes about 40%
faster (Python, 64 MiB file, KVM); 256 KiB gains about 15% more for
0.8 MiB more pool per sandbox, and 1 MiB nothing.

Return 64 KiB, checked at compile time against what one host call
carries.  fs_large.py keeps writing three full chunks.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
Each of these failed before the kernel's last changes:

- output that was not UTF-8 failed the guest function call;
- stdin cut inside a character, or not UTF-8, arrived as U+FFFD;
- a host-mount path that was not UTF-8 failed the guest function
  call, and one over 1,023 bytes was cut short and acted on.

A line longer than one host call is checked to arrive whole, as it
does since the kernel sends output in as many calls as it takes.

The long-path test runs on Linux only: the host directories it makes
are past the path limits of macOS and Windows.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
calls.md gets a section on the transport and the knobs measured for
it; the limits in calls.md, driver.md and net.md and the chunk size in
fs.md follow the new figures, and fs.md says which paths are refused.
RELEASE.md names the pool sizes where it named the I/O stacks.  The
CHANGELOG records the move and what it fixes.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
@danbugs danbugs changed the title [DO NOT MERGE] Move to Hyperlight's virtqueue transport (v0.18) Move to Hyperlight 0.18's virtqueue transport Oct 15, 2026
@danbugs
danbugs force-pushed the hyperlight-v0.18-virtio branch from d4e1c96 to 1ed4085 Compare October 15, 2026 16:13
@danbugs
danbugs merged commit c52aaa9 into main Oct 15, 2026
44 checks passed
@danbugs
danbugs deleted the hyperlight-v0.18-virtio branch October 15, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/arm64 Run the arm64 guest tests (self-hosted KVM and HVF runners)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants