feat: virtio-blk filesystem emulation + overlay CoW block device#10
Open
chaosreload wants to merge 17 commits intozerobootdev:mainfrom
Open
feat: virtio-blk filesystem emulation + overlay CoW block device#10chaosreload wants to merge 17 commits intozerobootdev:mainfrom
chaosreload wants to merge 17 commits intozerobootdev:mainfrom
Conversation
added 17 commits
March 23, 2026 16:33
Step 1 complete: - virtio_blk.rs: KVM_EXIT_MMIO virtio-blk emulator with overlay CoW - vmstate.rs: robust offset detection for FC v1.15+, virtio queue addr parsing - kvm.rs: integrate VirtioBlk into fork_cow, sendfile-based memfd loading - guest/init.c: C init with popen python3 for CODE: execution - Verified: echo/cat/CODE:numpy all work end-to-end Test: Ubuntu 22.04 rootfs, Python 3.10, numpy 2.2.6, pandas 2.3.3 Fork latency: ~1ms, Python exec: ~200ms, numpy exec: ~450ms
- ARCHITECTURE.md: new section covering virtio-blk design, overlay CoW, EVENT_IDX fix, vmstate detection, guest init protocol, rootfs build guide, template creation, and performance benchmarks table - API.md: added Filesystem Access section explaining isolated CoW per fork - README.md: updated How It Works to include filesystem step, refreshed benchmark table with actual measured numbers Closes Step 1 documentation.
Author
|
Hi, just a heads-up on the related PRs I have opened to keep things reviewable in smaller pieces:
This PR (#10) contains the core feature implementation. The docs in this PR overlap with #11 — if you prefer to review docs separately, feel free to merge #11 first and I can rebase this PR to remove the doc changes. Happy to make any adjustments. Thanks for your time! |
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.
Summary
This PR implements Step 1 of the zeroboot enhancement plan: virtio-blk MMIO emulation with overlay CoW isolation, enabling full filesystem access in forked VMs without relying on Firecracker at runtime.
Changes
New:
src/vmm/virtio_blk.rsVirtioBlk: Full virtio-blk MMIO emulator handlingKVM_EXIT_MmioWrite/ReadQueueNotify→ reads virtq descriptors from guest memoryVIRTIO_F_EVENT_IDXsuppression: updatesavail_eventafter queue drainOverlayBlockDevice: Per-fork in-memory CoW layerHashMap<sector, Vec<u8>>first, fall back topread()on base imageArc<File>shared read-only)Modified:
src/vmm/vmstate.rs[0x02][u32]prefix format)Modified:
src/vmm/kvm.rsVirtioBlkintoForkedVmMmioRead/MmioWriteexits to virtio-blk emulatorfork_cow()acceptsblock_file: Option<Arc<File>>parametersendfileinstead ofstd::fs::readto avoid double-bufferingModified:
guest/init.cCODE:<python_code>command: executes viapopen("python3 /tmp/zb_code.py 2>&1")cat <path>now works with full filesystem accessModified:
src/main.rs,src/api/handlers.rs{workdir}/rootfs_pathorZEROBOOT_ROOTFSenv varcmd_template()saves rootfs absolute path after snapshot creationModified:
docs/,README.mdTest Results
Tested on c8i.xlarge with nested virtualization enabled (Ubuntu 22.04, Python 3.10, numpy 2.2.6, pandas 2.3.3):
CODE:print(1+1)2CODE:import numpy as np; print(np.array([1,2,3]).mean())2.0cat /etc/os-releaseKnown Limitations
.soloading through virtio-blk. Future: pre-warm pages before snapshot to eliminate disk I/O post-fork.Rootfs Build
See ARCHITECTURE.md for full rootfs build instructions (Ubuntu 22.04 + Python 3.10 + numpy/pandas + static init binary).