Skip to content

Add configuration for additional virtiofs devices - #2273

Open
jakogut wants to merge 2 commits into
containers:mainfrom
jakogut:virtiofs-config
Open

jakogut wants to merge 2 commits into
containers:mainfrom
jakogut:virtiofs-config

Conversation

@jakogut

@jakogut jakogut commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Add configuration for additional virtiofs devices through .krun_vm.json as well as the annotation krun.virtiofs. This can be useful for mapping devshm from the host (useful for shared memory backing, such as the mechanism muvm-bridge uses to export X11 shared memory fences), as well as other filesystems and directories.

@giuseppe

Copy link
Copy Markdown
Member

@slp PTAL

@jakogut it needs a rebase

The VM configuration file can only configure the root virtiofs export.
Add a "virtiofs" array whose entries give a tag, a path inside the
container, and a DAX shm_size, and add each one with
krun_add_virtiofs2() after the root export, in array order.

crun checks only that each entry has the expected JSON types and a
positive shm_size. Tag length and uniqueness are left to libkrun.

Signed-off-by: Joseph Kogut <joseph@anodize.com>
Let the container creator add virtiofs devices through the
krun.virtiofs annotation, a JSON array in the same format as the
"virtiofs" field of .krun_vm.json.

Unlike the other krun annotations, this one does not override the
configuration file. The image and the container creator can each
supply devices, so both lists are added: first the devices from
.krun_vm.json, then the devices from the annotation.

Signed-off-by: Joseph Kogut <joseph@anodize.com>
@kolyshkin

Copy link
Copy Markdown
Collaborator

@slp PTAL

@slp slp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks @jakogut

@giuseppe

Copy link
Copy Markdown
Member

@slp can this open security holes given the file is coming from an untrusted source?

@kolyshkin

Copy link
Copy Markdown
Collaborator

@slp can this open security holes given the file is coming from an untrusted source?

@slp wdyt?

@slp

slp commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

@slp can this open security holes given the file is coming from an untrusted source?

@slp wdyt?

The virtio-fs in libkrun can only access filesystems within the container mount namespace. This only allows exposing things such as the container's /dev/shm, /tmp or /proc.

The problem here is managing user's expectations. The krun handler was always intended to provide a context as close as possible as the container context, but while running inside a VM. But then, it's clear some users have different expectations, and could imaging some people not liking the idea of the guest having visibility of the container's /proc.

I guess the safest approach would be only supporting this as annotations, which are exclusively controlled by the host owner.

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