mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[GH-ISSUE #390] feature(qemu-backend): add a QEMU sandbox backend for GPU, Windows and macOS sandboxes #99
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#99
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @yingdi-shan on GitHub (Oct 19, 2026).
Original GitHub issue: https://github.com/kvcache-ai/AgentENV/issues/390
Affected component: Orchestrator / sandbox lifecycle (also: Firecracker runtime, Snapshot / template builder, Gateway / scheduler)
Problem statement
We need AgentENV to provide GPU sandboxes and Windows and macOS sandboxes in addition to today's Linux CPU sandboxes. AgentENV is built only on Firecracker, which rules out both:
The Firecracker dependency goes beyond the device model. Our capture path relies on our Firecracker fork's dirty-memory-range API, on a file-backed (MAP_PRIVATE) or uffd memory backend, and on MMDS for guest metadata. None of these has a direct QEMU equivalent. Several other parts of the stack also assume a Linux guest:
Use case
Current behavior and workarounds
server.rs, the orchestrator and the template runner constructFirecrackerSandboxFactory/FirecrackerSandboxdirectly. No other VMM can be selected (#381 adds a factory alias for a mock backend).src/sandbox/firecracker/do not depend on Firecracker at all: OverlayBD snapshot sealing and restacking, dirty-memory-to-OverlayBD conversion,ProcessVmReader,SandboxResources, startup prefetch on the ublk device, and theMmdsMetadatatype. A second backend cannot reuse them where they are.Desired behavior
nvidia-smi(or the equivalent), then the device is visible and usable.backend = "qemu", and a restore is routed only to nodes that can run that backend.Proposed approach
The work is split into phases, each of which can be shipped and reviewed on its own. Line counts are rough estimates based on the current Firecracker backend (about 6.2k lines of code plus 3.2k lines of tests). They cover the AgentENV host side only and exclude the guest agent ports in phase 4.
src/sandbox/firecracker/:overlaybd_snapshot.rsrestacking and memory-layer building →src/sandbox/ublk/process_vm_reader.rsresources.rs→src/sandbox/startup_pack.rsMmdsMetadatatypeconvert_dirty_memory_to_overlaybdtake a neutral dirty-range type instead offirecracker_client::models::DirtyMemoryRanges.FirecrackerCommonConfiginto a shared sandbox config and the Firecracker-only fields. Useserde(flatten)and add tests that persisted paused states and snapshot configs from before the split still load.FirecrackerCaptureArtifactsdowncast inpublish_capturedwith a recording hook the backend supplies.FirecrackerManifestandfirecracker_versionRust identifiers, keeping their stored names.FirecrackerSandboxFactory(coordinate with #381).microvm/q35command-line builder, process lifecycle and logs[qemu]config and dependency/setup packagingOpen question: memory model (phase 2). Upstream QEMU does not expose dirty RAM ranges outside migration. Its options each lose something Firecracker gives us today:
x-ignore-sharedrequiresshare=on, which breaks copy-on-write for forks.mapped-ram(QEMU ≥ 9.0) restores eagerly.Incremental capture probably needs a small QEMU patch (about 0.5–1.5k lines of C) that we package the same way as our Firecracker fork. We should prototype QEMU memory restore from a ublk device before committing to the phase 2 design.
Open question: where macOS can run. Apple's macOS license allows macOS to run in a virtual machine only on Apple-branded hardware. AgentENV hosts are Linux with KVM, ublk and network namespaces. The options are:
This needs a decision, and legal review, before macOS work starts. It may become its own issue.
Compatibility and operational impact
API/config changes:
[qemu]section and a per-node backend selection. Firecracker stays the default.Snapshot or storage format changes:
SandboxSnapshotManifest.backendalready exists, so"qemu"is added toKNOWN_BACKENDS."firecracker".New host/runtime requirements:
config/deps_manifest.toml./dev/vfio.Scheduler:
backend, guest OS and the required devices.Upgrade and rollback considerations:
Alternatives considered
Non-goals
Vmmtrait abstraction before a QEMU prototype shows where the shared boundary really is.Contribution
I can implement it
Pre-submission checklist
@dushulin commented on GitHub (Oct 28, 2026):
@yingdi-shan hi, This is a capability that we very much need. Has there been any discussion on the technical solution?
@yingdi-shan commented on GitHub (Oct 28, 2026):
We are currently working on v0.3.0, which introduces a database to track relationships among layers, enabling online garbage collection of snapshot data. This work will follow once v0.3.0 is complete.