Skip to content

Add WithRootFSShareDir to share a caller-prepared rootfs dir - #176

Open
thejoeejoee wants to merge 1 commit into
stacklok:mainfrom
thejoeejoee:feat/rootfs-share-dir
Open

thejoeejoee wants to merge 1 commit into
stacklok:mainfrom
thejoeejoee:feat/rootfs-share-dir

Conversation

@thejoeejoee

@thejoeejoee thejoeejoee commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #177.

Adds WithRootFSShareDir(tag, dir), a sibling of WithRootFSShare (#160) for callers that prepare the shared root themselves instead of taking it from the image cache.

Run boots from the same empty root directory in the data dir (hooks, guest VM config and .krun_config.json land there) and shares dir read-only over virtio-fs under tag. No image is pulled and imageRef is ignored, so hooks get a nil OCI config and the environment comes from WithEnv.

Use case: jailoc converts OCI layers into per-layer EROFS images on the host and the guest init mounts them as overlay lowers (seznam/jailoc#361). There is no unpacked rootfs in the image cache to point WithRootFSShare at, and WithRootFSPath would put .krun_config.json and the hooks' files into the shared directory.

  • dir must be an absolute path to an existing directory; rejected together with WithRootFSPath. Tag collisions are checked as for WithRootFSShare.
  • WithRootFSShare and WithRootFSShareDir replace each other, last one wins.
  • VM.Remove keeps dir.

Testing

  • TestRun_RootFSShareDir_SharesDirReadOnly: no image pull, hooks see an empty root and a nil OCI config, nothing is written into dir, the backend gets the read-only mount of dir, Remove keeps it.
  • TestRun_RootFSShareDir_Validation: relative, missing and non-directory paths and the combination with WithRootFSPath fail before the backend starts.
  • TestWithRootFSShareDir_ReplacesRootFSShare.
  • go test .

@thejoeejoee

Copy link
Copy Markdown
Contributor Author

@jhrozek any chance you could take a look at this?

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.

Share a caller-prepared directory as the guest root

1 participant