Repository navigation
Conversation
Initialize empty and prefilled rings through MemOps. Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Start fresh queues on capture, restore, and cloning. Keep retained guest data separate, so it stays valid while the queues have their full receive capacity. Preserve messages the host sends before the guest next runs. This provides the snapshot foundation for buffer replacement. It also prepares for snapshot capture without running guest code to tidy the queues. Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Unsafe ownership reconstruction involving retained aliases, scratch reuse, and snapshot ABI changes requires human review and hypervisor-backed validation of capture, restore, and source continuation across supported architectures.
No open issues 🎉
What changed in this PR
Hyperlight snapshots use host-built queue images while the guest stays stopped. Guest entry reconstructs queue ownership, preserving retained data and host-written requests to support guest-side zero-copy streams.
Changes:
- Deterministic queue initialization and producer retirement separate retained buffers from active queues.
- Capture and restore provide full configured receive capacity before guest entry.
- Snapshot ABI 12, documentation, and regression tests cover the transport lifecycle.
| File | Description |
|---|---|
src/tests/rust_guests/simpleguest/src/bin/simpleguest-incomplete-init.rs |
Adds an early-halt fixture for incomplete initialization. |
src/hyperlight_host/tests/snapshot_goldens/goldens_version.rs |
Sets snapshot goldens to v12.0. |
src/hyperlight_host/tests/integration_test.rs |
Tests retained buffers across transport generations with larger requests. |
src/hyperlight_host/src/sandbox/uninitialized_evolve.rs |
Checks initialization readiness and tests early-halt rejection. |
src/hyperlight_host/src/sandbox/snapshot/tripwires.rs |
Pins the expected snapshot ABI to 12. |
src/hyperlight_host/src/sandbox/snapshot/mod.rs |
Clarifies scratch-size validation documentation. |
src/hyperlight_host/src/sandbox/snapshot/file/transport.rs |
Uses bootstrap images in transport serialization tests. |
src/hyperlight_host/src/sandbox/snapshot/file/media_types.rs |
Sets the snapshot ABI version to 12. |
src/hyperlight_host/src/sandbox/snapshot/file_tests.rs |
Tests retained buffers through OCI persistence and updates ABI assertions. |
src/hyperlight_host/src/sandbox/outb.rs |
Removes checkpoint-specific host-call restrictions. |
src/hyperlight_host/src/sandbox/initialized.rs |
Uses host-only capture and tests snapshot lifecycle behavior. |
src/hyperlight_host/src/mem/virtq/tests.rs |
Tests deterministic bootstrap validation and restoration. |
src/hyperlight_host/src/mem/virtq/mod.rs |
Builds, validates, and installs bootstrap ring images. |
src/hyperlight_host/src/mem/virtq/mem.rs |
Supports checked writes to private ring images. |
src/hyperlight_host/src/mem/mgr.rs |
Installs fresh transport ownership and checks initialization readiness. |
src/hyperlight_host/src/mem/layout.rs |
Updates mailbox documentation terminology. |
src/hyperlight_host/src/hypervisor/hyperlight_vm/test_support.rs |
Adds virtual CPU execution fault injection. |
src/hyperlight_guest/src/transport/mod.rs |
Exposes initialization completion and removes checkpoint preparation. |
src/hyperlight_guest/src/transport/context.rs |
Initializes queues and reconstructs producers on generation changes. |
src/hyperlight_guest/src/transport/backing.rs |
Documents alias reservations across transport generations. |
src/hyperlight_guest_bin/src/lib.rs |
Publishes readiness after guest initialization. |
src/hyperlight_guest_bin/src/guest_function/call.rs |
Removes checkpoint dispatch handling. |
src/hyperlight_common/src/virtq/ring.rs |
Reconstructs private ring state from bootstrap geometry. |
src/hyperlight_common/src/virtq/producer.rs |
Adds producer reconstruction, retirement, and ownership tests. |
src/hyperlight_common/src/virtq/pool/tests.rs |
Removes tests for the deleted pool-swap mechanism. |
src/hyperlight_common/src/virtq/pool/slot.rs |
Defines reusable pool geometry and deterministic allocation order. |
src/hyperlight_common/src/virtq/pool.rs |
Exports PoolLayout. |
src/hyperlight_common/src/virtq/mod.rs |
Adds ring initialization helpers and bootstrap exports. |
src/hyperlight_common/src/virtq/buffer.rs |
Tests retained lease isolation with fresh pool instances. |
src/hyperlight_common/src/virtq/bootstrap.rs |
Defines deterministic empty and prefilled queue images. |
src/hyperlight_common/src/transport.rs |
Removes checkpoint messages and defines initialization mailbox states. |
src/hyperlight_common/src/layout.rs |
Updates transport mailbox documentation terminology. |
docs/virtio-host-guest-communication.md |
Documents host-driven capture and guest ownership reconstruction. |
docs/snapshot-versioning.md |
Describes ABI 12 and snapshot regeneration requirements. |
docs/snapshot-oci-format.md |
Updates the protocol reference to snapshot bootstrap state. |
CHANGELOG.md |
Records the ABI break, transport behavior, and removed APIs. |
Review effort: Balanced
Benchmark ResultsMeasured commit: kvm / amd (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
kvm / intel (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
mshv3 / amd (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
mshv3 / intel (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
hyperv-ws2025 / amd (Windows) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
hyperv-ws2025 / intel (Windows) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
Reported by |
ludfjig
left a comment
There was a problem hiding this comment.
I am big fan of these changes! I also checked perf, snapshot is faster (yay!) but guest calls after restore is slower...
| Benchmark | MSHV 6.6 | MSHV 6.18 | KVM |
|---|---|---|---|
snapshots/create/default |
−19% to −22% | −18% to −20% | −14% to −16% |
snapshots/call_and_create/default |
−13% to −15% | −11% to −14% | −3% to −7% |
guest_calls/call_with_restore/default |
+2% to +7% | +3% to +6% | +9% to +10% |
I looked into the slow guest calls, and it's due to extra page faults in guest. After a restore, maybe_refresh builds both new producers before retiring the old ones. The new allocations land on fresh heap pages so more page faults.
Resetting the producers in place instead of having the two live at the same time before retiring the old one fixes most of it, and I think this shoudl be easy fix unless there's a reason we need both?
Separate: do we still need to save the transport blob in the snapshot on disk, or can they always be rebuilt from the layout? Maybe could be simplified?
| // SAFETY: The host discarded the old queues with no live chain handles. | ||
| // Old pools only release leases. New producers own the scratch slots. | ||
| unsafe { | ||
| self.g2h_producer | ||
| .reclaim_slots() | ||
| .expect("G2H pool recovery failed"); | ||
| self.h2g_producer | ||
| .reclaim_slots() | ||
| .expect("H2G pool recovery failed"); | ||
| old_g2h.retire().expect("G2H retirement failed"); | ||
| old_h2g.retire().expect("H2G retirement failed"); | ||
| } |
There was a problem hiding this comment.
do you think we can replace the old ones inline or retire them before creating new one? It would save perf
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Currently on snapshot we are running the guest to reset its virtual queues and then we save those queues. This patch changes this to the host building fresh queues itself instead. Snapshot capture keeps the guest stopped.
This separates the lifetime of retained data from the queues used to deliver new messages and is important for guest-side zero-copy streams because it will allow us to refill pools with any scratch mapped memory not only memory bounded by initial pool layout. This also eliminates the need for snapshot preparation guest entry.
The new restore workflow looks roughly like this: