Merged
Conversation
Plumb a ReadOnly flag through the full VirtioFSMount chain so callers can declare host directories as read-only inside the guest. Enforcement is guest-side via MS_RDONLY mount flags; libkrun does not yet support host-side read-only virtiofs. Closes #53 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
ReadOnly boolfield toVirtioFSMountand plumbs it through the full type chain:microvm.VirtioFSMount→hypervisor.FilesystemMount→runner.VirtioFSMount→ runner binary duplicate → guest boot configMS_RDONLYmount flags inmount.Workspace()vmconfig.Config.VirtioFSMounts(written to/etc/go-microvm.json)EROFSon every read-only workspace)Closes #53
Details
Why guest-side only? libkrun's
krun_add_virtiofsC API has no read-only parameter. The upstream virtiofsd has aPassthroughFsRowrapper but libkrun's vendored copy doesn't include it. An upstream PR to add host-side support would provide defense-in-depth.Files changed (18):
ReadOnly boolguest/mount/mount.go— addsMS_RDONLYflag, skips chown on read-only mounts, unmounts on chown failureguest/vmconfig/vmconfig.go— newVirtioFSMountInfotype for host→guest metadatamicrovm.go—buildVMConfig()writes read-only mount info to guest configguest/boot/options.go— newWithWorkspaceReadOnly()optionrunner/cmd/.../main.go— warning log for host-side enforcement gapTest plan
task fmt— no formatting changestask lint— 0 issuestask test-nocgo— all tests passCGO_ENABLED=0 go vet— clean🤖 Generated with Claude Code