Repository navigation
feat(devices): make the virtio-fs backend state limit configurable - #151
Merged
Merged
Conversation
Add a per-VM virtio-fs backend state budget (default 4 MiB) with VmBuilder::fs_state_limit. The device-state and VirtioDeviceState envelope limits are derived from it, and the encode/decode pair gains *_with_fs_backend_limit variants.
0xpolarzero
marked this pull request as ready for review
October 2, 2026 21:45
Add reusable DeviceStateLimits and a VM-configured DeviceStateCodec so embedders can configure the filesystem budget once for capture and serialization. Keep default codec behavior and rename the explicit limit methods for consistent filesystem terminology.
Member
|
@0xpolarzero made a minor change to share the device state limits, and just a few function renames. |
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.
Lets the embedder choose how much virtio-fs backend state each device may capture and restore. Today the backend state is capped at 4 MiB and the encoded states at 8 MiB, all hard-coded, so a guest that has looked up a few tens of thousands of host files cannot be checkpointed. microsandbox wants to expose this as a setting (superradcompany/microsandbox#1751).
What changed
VmBuilder::fs_state_limit(bytes)sets the backend state budget for every virtio-fs device, passthrough and custom. The default isDEFAULT_MAX_FS_BACKEND_STATE_BYTES(4 MiB, as before).VirtioDeviceStatefor virtio-fs adds the existing 1 MiB envelope allowance on top.VirtioDeviceState::encode_with_fs_backend_limit/decode_with_fs_backend_limittake the budget.encode/decodekeep their signatures and use the default.max_virtio_device_state_bytes(device_type, budget)returns the largest encoded state, so embedders can size their own admission checks the same way.Non-fs devices are unchanged. At the default budget, every state that 0.1.40 could capture still round-trips. The generic
VirtioDeviceStatebound for virtio-fs tightens from 8 MiB to about 5 MiB, which the fs device already enforced on restore.How it was tested
devicesandvmmcover:cargo testformsb_krun_devices(virtio::fs),msb_krun_vmm --features blkandmsb_krun --features net,blk, plus clippy-D warningson those crates, on macOS.The PR appears safe to merge based on the changes since the previous review.
What we checked:
Reviews (3) · Last reviewed commit: "feat(api): share device state limits bet..."