Skip to content

[DO NOT MERGE] Move to Hyperlight's virtqueue transport (v0.18) - #142

Open
danbugs wants to merge 6 commits into
mainfrom
hyperlight-v0.18-virtio
Open

danbugs wants to merge 6 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's virtqueue transport, tracking hyperlight main until v0.18.0 is published. Draft: the hyperlight dependency is a git rev on danbugs/hyperlight (upstream main 5ddb37af minus 3ef1a362, whose sparse snapshot blobs slow Windows cold starts about 4x), and the kernel submodule points at danbugs/unikraft plat-hyperlight-v2-virtio; both go back before merge.

  • Kernel: a C packed-ring driver for G2H/H2G (plat/hyperlight/transport.c); host function calls, guest function calls and snapshot checkpoints move onto it.
  • Console output and stdin travel as bytes (HostWrite, byte ReadStdin): non-UTF-8 output no longer fails the guest function call, and output over 4 KiB is no longer cut short.
  • hostfs moves 64 KiB per host call (reads ~55%, writes ~50% faster than v0.17); host-mount paths that aren't UTF-8 or are over 1,023 bytes fail with EILSEQ / ENAMETOOLONG instead of failing the call or being truncated.
  • Snapshots from earlier builds are refused; native kernels must be rebuilt.

Hyperlight 0.18 replaces the PEB's I/O stacks with two VIRTIO packed
rings in scratch memory.  It is not on crates.io yet, so
hyperlight-host and hyperlight-common track its main branch at
3ee2d4cb, and the kernel moves with it: plat-hyperlight-v2-virtio on
the danbugs/unikraft fork until that merges into plat-hyperlight-v2.
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>) instead of the
string HostPrint, which failed on output that was not UTF-8: it goes
to stdout, and to drain_output(), decoded as it arrives, a character
split between writes held until its end comes and bytes that are not
UTF-8 read as U+FFFD.  ReadStdin hands over bytes, not a lossy string.

MultiUseSandbox is now Sandbox.  SNAPSHOT_CONTRACT goes to 4: 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:

- a line longer than one host call reached the host cut to 4 KiB;
- 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.

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 added the ci/arm64 Run the arm64 guest tests (self-hosted KVM and HVF runners) label Oct 6, 2026
Hyperlight 3ef1a362 (#1788) writes the snapshot memory blob sparsely.
On Windows, a sandbox built from such a snapshot pays for it on its
first call: python-shell cold-snap went from 16 to 59 ms on a laptop
and over the CI ceilings.  Track main (5ddb37af) with that commit
reverted, on the danbugs/hyperlight fork, until it is sorted out
upstream.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
@danbugs danbugs closed this Oct 7, 2026
@danbugs danbugs reopened this Oct 7, 2026
Signed-off-by: danbugs <danilochiarlone@gmail.com>
@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
Comment on lines +1323 to +1324
// Nothing will finish a character the process left cut short.
let text = output.lock().unwrap().finish();

This branch has not been deployed

No deployments
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