Skip to content

Add krun_set_root2() API to support read-only root filesystems#637

Open
d-e-s-o wants to merge 1 commit intocontainers:mainfrom
d-e-s-o:topic/set-root-ro
Open

Add krun_set_root2() API to support read-only root filesystems#637
d-e-s-o wants to merge 1 commit intocontainers:mainfrom
d-e-s-o:topic/set-root-ro

Conversation

@d-e-s-o
Copy link
Copy Markdown
Contributor

@d-e-s-o d-e-s-o commented Apr 15, 2026

Pull request #623 added support for read-only mounts. It seems only consequent to also provide users with the ability to set read-only state for the root file system.
Introduce krun_set_root2(), which extends krun_set_root() with a read_only parameter to allow exposing the root filesystem as read-only to the guest. The original krun_set_root() now delegates to the new function with read_only=false, preserving the previous behavior.

Pull request containers#623 added support for read-only mounts. It seems only
consequent to also provide users with the ability to set read-only state
for the root file system.
Introduce krun_set_root2(), which extends krun_set_root() with a
read_only parameter to allow exposing the root filesystem as read-only
to the guest. The original krun_set_root() now delegates to the new
function with read_only=false, preserving the previous behavior.

Signed-off-by: Daniel Müller <deso@posteo.net>
@mtjhrc
Copy link
Copy Markdown
Collaborator

mtjhrc commented Apr 15, 2026

I'm not really a fan of adding this right now, users can already do krun_add_virtiofs3(ctx, "/dev/root", "/path/to/root", /*shm_size*/0, /*read-only*/ true).

Only problem is user has to know we use "/dev/root" in the default cmdline arguments for the kernel. Only addition I think we should consider is #define KRUN_FS_ROOT_TAG "/dev/root" in the header.

For libkrun 2.0 I think we should make the user always pass in the virtiofs tag to boot from explicitly, that is more obvious to the user and flexible.

@mtjhrc
Copy link
Copy Markdown
Collaborator

mtjhrc commented Apr 15, 2026

Also we could also add an explicit comment to krun_set_root to tell users to use krun_add_virtiofs* instead to specify more parameters for the root virtiofs.

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.

2 participants