Skip to content

Add KRUN_FS_ROOT_TAG define and document krun_set_root alternative#637

Merged
mtjhrc merged 1 commit intocontainers:mainfrom
d-e-s-o:topic/set-root-ro
Apr 15, 2026
Merged

Add KRUN_FS_ROOT_TAG define and document krun_set_root alternative#637
mtjhrc merged 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.

Expose the virtiofs tag we use internally to krun_set_root() so that
users are able to use it with APIs such as krun_add_virtiofs3()
(recently added via containers#623). This way, they can gain control over the
read-only state of the root file system (among other properties) without
having to guess the tag to use.

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.

@d-e-s-o d-e-s-o force-pushed the topic/set-root-ro branch from 4ac0c50 to 4a7d366 Compare April 15, 2026 14:59
@d-e-s-o d-e-s-o changed the title Add krun_set_root2() API to support read-only root filesystems Add KRUN_FS_ROOT_TAG define and document krun_set_root alternative Apr 15, 2026
@d-e-s-o
Copy link
Copy Markdown
Contributor Author

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

Sure, done.

Copy link
Copy Markdown
Collaborator

@mtjhrc mtjhrc left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@mtjhrc mtjhrc merged commit 62e71f4 into containers:main Apr 15, 2026
11 checks passed
@d-e-s-o d-e-s-o deleted the topic/set-root-ro branch April 15, 2026 15:45
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