pub struct SandboxFs { /* private fields */ }Expand description
A fully composed, per-sandbox VFS: the namespace, its Subject, and the runtime handles for the injected mounts.
Implementations§
Source§impl SandboxFs
impl SandboxFs
Sourcepub fn compose(
rafs_store: &RafsStore,
image_id: &str,
sandbox_dir: &Path,
subject: Subject,
models: SyntheticNode,
deltas: SyntheticNode,
) -> Result<Self>
pub fn compose( rafs_store: &RafsStore, image_id: &str, sandbox_dir: &Path, subject: Subject, models: SyntheticNode, deltas: SyntheticNode, ) -> Result<Self>
Compose a per-sandbox VFS namespace for image_id, bound to subject.
Steps (the FS-D core):
- Fork an empty base namespace (
Namespace::forkofnew()— every sandbox starts from a clean, private mount table). - Mount the image filesystem (
image_fs_for) at/. The RAFS image is the shared RO lower; a per-sandbox writable upper under<sandbox_dir>/rootfs/is the CoW layer. It is the root purely because it is mounted at/— “root” is a mount position, not a type (#633). - Bind the injected mounts —
/stream(native pipes),/models,/deltas(synthetic, read-only) — into the namespace.
models / deltas are passed as synthetic trees so the caller decides
what to expose (e.g. available model ids / delta metadata for this
tenant). Pass empty dirs to expose just the mount point.
Sourcepub fn from_namespace(namespace: Namespace, subject: Subject) -> Self
pub fn from_namespace(namespace: Namespace, subject: Subject) -> Self
Wrap an already-composed namespace for serving, without doing any image composition here (#635).
Used by SandboxBackend::deliver_namespace:
as the #508/#635 narrowing lands, composition becomes the caller’s job
(the universal filesystem-service Mount, or #634’s shared
namespace-composition builder) and the backend’s job narrows to
serving + attaching the transport. There is no fresh
StreamRegistry wired into namespace here — the caller is
responsible for mounting whatever injected registries it needs before
calling this; the placeholder InjectedMounts returned by
Self::injected is unused in this path.
Sourcepub fn root_mount(&self) -> Arc<dyn Mount> ⓘ
pub fn root_mount(&self) -> Arc<dyn Mount> ⓘ
A clone of the tenant root Mount (the / image filesystem).
The same Subject-scoped Mount the virtio-fs namespace roots on — exported so a second transport (the kata guest’s 9P-over-vsock channel, #731) can serve it without re-composing or duplicating the writable-upper CoW layer.
Sourcepub fn namespace(&self) -> &Namespace
pub fn namespace(&self) -> &Namespace
The composed namespace (read-only borrow; e.g. for tests / inspection).
Sourcepub fn injected(&self) -> &InjectedMounts
pub fn injected(&self) -> &InjectedMounts
Runtime handles for the injected mounts.
Sourcepub fn into_filesystem(self, rt: Handle) -> (VfsFileSystem, InjectedMounts)
pub fn into_filesystem(self, rt: Handle) -> (VfsFileSystem, InjectedMounts)
Build the FS-A VfsFileSystem down-adapter from this composed namespace,
consuming self (the namespace moves into the adapter).
rt is a tokio runtime handle the adapter uses to drive the async VFS ops
from the server’s synchronous (OS-thread) vring loop.
Sourcepub fn serve_on(
self,
socket_path: PathBuf,
rt: Handle,
) -> Result<SandboxFsServer>
pub fn serve_on( self, socket_path: PathBuf, rt: Handle, ) -> Result<SandboxFsServer>
Compose, then serve the namespace over a per-sandbox Unix socket.
Spawns a dedicated OS thread running FS-A’s blocking serve daemon
(which VhostUserDaemon::wait()s until CH disconnects). Returns a
SandboxFsServer holding the socket path and the injected handles; the
caller then attaches the socket to CH via
attach_share_fs before start_vm.
rt is captured for the down-adapter’s async→sync bridge.
Sourcepub fn serve_local_at(
self,
rt: Handle,
mountpoint: PathBuf,
) -> Result<SandboxFsLocalMount>
pub fn serve_local_at( self, rt: Handle, mountpoint: PathBuf, ) -> Result<SandboxFsLocalMount>
FUSE-mount this composed namespace at mountpoint as a real host
directory — the non-VM sibling of [serve_on] (Model B, #715).
Where [serve_on] serves the VfsFileSystem to a VM guest over
vhost-user-fs (virtio-fs), this serves the same down-adapter to the
host kernel over /dev/fuse via
hyprstream_vfs_server::serve_local, so a non-VM sandbox (e.g.
systemd-nspawn --directory=<mountpoint>) can POSIX-root its workload
directly in the tenant’s composed VFS. Any host process that enters the
sandbox — the inference workload, a shell — then sees the tenant VFS as
its filesystem, closing the “run a task” gap (#506) for the POSIX case.
§Subject preservation (MAC-conservative)
The Subject is preserved automatically: into_filesystem bakes
it into the VfsFileSystem, so every VFS op driven over the FUSE
channel is attributed to this sandbox’s single Subject at the Mount
boundary (Subject-per-call). Because the mount is per-sandbox and
served under one Subject, there is no uid→Subject mapping to invent
(and none is invented): every operation over this mount is correctly
attributed to the sandbox principal, exactly as the virtio-fs path is.
Rootless-userns uid-mapping / allow_other nuances (e.g. an unprivileged
/dev/fuse under a podman --userns=keep-id remapping) are out of
scope for the nspawn target, which runs closer to the host; they are
deferred to the OCI/rootless-FUSE feasibility spike (#715 / #617).
serve_local blocks until the mount is torn down, so it runs on a
dedicated OS thread; the returned SandboxFsLocalMount unmounts and
joins that thread on drop (RAII), mirroring SandboxFsServer.
mountpoint is created (create_dir_all) if absent. rt is captured for
the down-adapter’s async→sync bridge.
Auto Trait Implementations§
impl Freeze for SandboxFs
impl !RefUnwindSafe for SandboxFs
impl Send for SandboxFs
impl Sync for SandboxFs
impl Unpin for SandboxFs
impl UnsafeUnpin for SandboxFs
impl !UnwindSafe for SandboxFs
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more