feat: virtio-blk filesystem emulation + overlay CoW block device#10
feat: virtio-blk filesystem emulation + overlay CoW block device#10chaosreload wants to merge 17 commits intozerobootdev:mainfrom
Conversation
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.
|
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! |
|
Hi @nekomeowww 👋 — Thanks again for your approval! I noticed Would you be able to dismiss the stale review and merge when you get a chance? CI is green and there are no unresolved conflicts. Really appreciate it! 🙏 |
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).