feat(microvm): apply outbound NAT and host-memory admission on both VM runtimes - #200
Merged
Merged
Conversation
Shine-neko
force-pushed
the
feat/microvm-nat-memory-parity
branch
from
July 25, 2026 06:19
cfc5fec to
7547cc8
Compare
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.
Two host-side facilities existed as shared modules but were only wired into one of the two microVM runtimes. Both are now applied on both.
Outbound NAT.
host_natmasquerades the guest supernet so a VM can reach external networks. It was called from Firecracker only, so a Cloud Hypervisor guest could serve inbound traffic but resolved nothing outbound. Cloud Hypervisor now makes the same call, in the branch that allocates the guest network — so it stays a no-op for a VM that declares no ports and therefore has no network at all. The rule set is idempotent and process-global, so this costs nothing after the first VM.Host-memory admission.
resources::check_host_memoryrefuses a deployment asking for more memory than the host has available. Cloud Hypervisor and containerd ran it; Firecracker had no memory gate, so an over-ask died on an opaque allocation failure at boot — and only after copying a full rootfs image per instance. The check now runs instart_vmbefore that copy. A refusal is terminal rather than a crash loop, since a retry cannot free memory.Neither module needed changes: both were already runtime-agnostic, they were simply not called.
Docs: documented outbound access on the Cloud Hypervisor page (including the
CAP_NET_ADMINrequirement and what happens without it), documented the memory gate on the Firecracker page, added both to the runtime comparison table, and corrected the Cloud Hypervisor page which describedresources.requests.*as ignored — it is not used to size the VM, butrequests.memorydoes drive admission control and takes precedence overlimits.memorythere.Tests
764 unit tests pass;
cargo fmtandcargo clippy --all-targetsare clean. The underlying modules already have unit coverage — what changed here is where they are called from, which only an e2e run on a KVM-capable host with the runtime binaries would exercise. Those suites do not run in CI today.