[release/0.1] forward ro bind-mount option to virtio-fs share#235
Merged
Conversation
The ext4 mount path in mount.go already parses `ro` from the OCI mount options; the bind-mount path silently dropped it. Plumb the flag through bindMounter and vmInstance.AddFS so the virtio-fs share itself is marked read-only at the host edge via krun_add_virtiofs3 (libkrun >= 1.18), giving us defense-in-depth on top of the guest-side `ro` bind mount and opening the door to VMM-side optimizations on immutable shares. When the loaded libkrun is older and does not export krun_add_virtiofs3, the binding falls back to krun_add_virtiofs with an info log and enforcement stays on the guest mount options exactly as today. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com> (cherry picked from commit 6db5a00) Signed-off-by: Derek McGowan <derek@mcg.dev>
There was a problem hiding this comment.
Pull request overview
This PR extends the bind-mount (virtio-fs) path to honor the OCI ro mount option by plumbing a read-only flag through the shim’s bind-mount transform into the libkrun virtio-fs attachment call, adding defense-in-depth by enforcing read-only at the host-side virtio-fs share.
Changes:
- Parse
ro/rwfrom OCI bind-mount options and forward the resulting read-only intent intosandbox.WithFS(...). - Extend the libkrun virtio-fs attachment API to call
krun_add_virtiofs3(..., readonly)and plumb the flag throughvmInstance.AddFS. - Add unit tests covering both bind-mount option parsing and libkrun readonly forwarding; bump documented/built libkrun version to >= 1.18.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the libkrun >= 1.18 requirement for krun_add_virtiofs3 readonly support. |
| internal/vm/libkrun/krun.go | Switches virtio-fs attachment to krun_add_virtiofs3 and adds a readonly parameter. |
| internal/vm/libkrun/krun_test.go | Adds unit tests validating readonly propagation and error behavior for virtio-fs attach. |
| internal/vm/libkrun/instance.go | Plumbs vm.MountOpt readonly config into the virtio-fs attachment call. |
| internal/shim/task/mount.go | Parses ro/rw for bind mounts and forwards to sandbox.WithFS(..., readonly). |
| internal/shim/task/mount_test.go | Adds assertions that bind-mount readonly flows into sandbox filesystem opts. |
| Dockerfile | Bumps the libkrun build ARG version to v1.18.1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
austinvazquez
approved these changes
Jun 23, 2026
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.
The ext4 mount path in mount.go already parses
rofrom the OCI mount options; the bind-mount path silently dropped it. Plumb the flag through bindMounter and vmInstance.AddFS so the virtio-fs share itself is marked read-only at the host edge via krun_add_virtiofs3 (libkrun >= 1.18), giving us defense-in-depth on top of the guest-siderobind mount and opening the door to VMM-side optimizations on immutable shares. When the loaded libkrun is older and does not export krun_add_virtiofs3, the binding falls back to krun_add_virtiofs with an info log and enforcement stays on the guest mount options exactly as today.(cherry picked from commit 6db5a00)