Skip to main content

SandboxFs

Struct SandboxFs 

Source
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

Source

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):

  1. Fork an empty base namespace (Namespace::fork of new() — every sandbox starts from a clean, private mount table).
  2. 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).
  3. 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.

Source

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.

Source

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.

Source

pub fn namespace(&self) -> &Namespace

The composed namespace (read-only borrow; e.g. for tests / inspection).

Source

pub fn subject(&self) -> &Subject

The Subject this namespace is served under.

Source

pub fn injected(&self) -> &InjectedMounts

Runtime handles for the injected mounts.

Source

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.

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ServiceExt for T

§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> MaybeSync for T
where T: Sync,