Skip to content

[release/0.1] forward ro bind-mount option to virtio-fs share#235

Merged
dmcgowan merged 1 commit into
containerd:release/0.1from
dmcgowan:backport-virtiofs-ro
Jun 23, 2026
Merged

[release/0.1] forward ro bind-mount option to virtio-fs share#235
dmcgowan merged 1 commit into
containerd:release/0.1from
dmcgowan:backport-virtiofs-ro

Conversation

@dmcgowan

Copy link
Copy Markdown
Member

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.

(cherry picked from commit 6db5a00)

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>
Copilot AI review requested due to automatic review settings June 23, 2026 15:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/rw from OCI bind-mount options and forward the resulting read-only intent into sandbox.WithFS(...).
  • Extend the libkrun virtio-fs attachment API to call krun_add_virtiofs3(..., readonly) and plumb the flag through vmInstance.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.

Comment thread internal/vm/libkrun/krun.go
@dmcgowan dmcgowan merged commit cc5704c into containerd:release/0.1 Jun 23, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants