Skip to content

Make Linux shim generic on file system#662

Open
CvvT wants to merge 4 commits intomainfrom
weiteng/generic_fs_shim
Open

Make Linux shim generic on file system#662
CvvT wants to merge 4 commits intomainfrom
weiteng/generic_fs_shim

Conversation

@CvvT
Copy link
Contributor

@CvvT CvvT commented Feb 11, 2026

I was trying to add 9p fs and use it for SNP runner, then I realized our Linux shim decides the fs to use not runner. This PR makes Linux shim generic on fs so that runner can pick whatever fs.

@CvvT CvvT marked this pull request as ready for review February 11, 2026 18:52
@wdcui wdcui requested a review from jaybosamiya-ms February 12, 2026 02:46
Copy link
Member

@jaybosamiya-ms jaybosamiya-ms left a comment

Choose a reason for hiding this comment

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

Thanks Weiteng, this is similar to a (broader) refactoring I was planning do but haven't had a chance to finish it up. There are some minor cleanups possible here, but I don't want to block you especially since I plan to do some of that cleanup later on anyways. Please feel free to merge, thanks!

Comment on lines +64 to +66
/// A trait required for file systems to be used in the shim.
pub trait ShimFS: litebox::fs::FileSystem + Send + Sync + 'static {}
impl<T: litebox::fs::FileSystem + Send + Sync + 'static> ShimFS for T {}
Copy link
Member

Choose a reason for hiding this comment

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

This portion is the key change, as I understand it, right?

This is similar to a (broader) refactoring I was planning do but haven't had a chance to finish it up. That refactoring can build on top of this one and can clean it up, so please feel free to merge this as is.

Copy link
Member

Choose a reason for hiding this comment

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

I assume you've already tested this, but any particular reason it needs to be Send + Sync + 'static? Can we relax any/all of them? It'd be nice to have it be the weakest requirements needed. If it cannot be weakened by removing those traits, that is fine, but just checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

'static is required by Box

struct NewThreadArgs<FS: ShimFS> {
/// Task struct that maintains all per-thread data
task: Task<FS>,
}
impl<FS: ShimFS> litebox::shim::InitThread for NewThreadArgs<FS> {
type ExecutionContext = litebox_common_linux::PtRegs;
fn init(
self: alloc::boxed::Box<Self>,
) -> alloc::boxed::Box<dyn litebox::shim::EnterShim<ExecutionContext = Self::ExecutionContext>>
{
let Self { task } = *self;
Box::new(crate::LinuxShimEntrypoints {
task,
_not_send: core::marker::PhantomData,
})
}

Send and Sync are required by Arc in multiple places for sharing across threads, e.g.,

Unix(Arc<crate::syscalls::unix::UnixSocket<FS>>),

@github-actions
Copy link

🤖 SemverChecks 🤖 ⚠️ Potential breaking API changes detected ⚠️

Click for details
--- failure trait_requires_more_generic_type_params: trait now requires more generic type parameters ---

Description:
A trait now requires more generic type parameters than it used to. Uses of this trait that supplied the previously-required number of generic types will be broken. To fix this, consider supplying default values for newly-added generic types.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-parameter-no-default
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/trait_requires_more_generic_type_params.ron

Failed in:
  trait LinuxShim (0 -> 1 required generic types) in /home/runner/work/litebox/litebox/litebox_shim_linux/src/lib.rs:222
  trait LinuxShimBuilder (0 -> 1 required generic types) in /home/runner/work/litebox/litebox/litebox_shim_linux/src/lib.rs:143
  trait LinuxShimEntrypoints (0 -> 1 required generic types) in /home/runner/work/litebox/litebox/litebox_shim_linux/src/lib.rs:78
  trait LoadedProgram (0 -> 1 required generic types) in /home/runner/work/litebox/litebox/litebox_shim_linux/src/lib.rs:300

--- failure type_requires_more_generic_type_params: type now requires more generic type parameters ---

Description:
A type now requires more generic type parameters than it used to. Uses of this type that supplied the previously-required number of generic types will be broken. To fix this, consider supplying default values for newly-added generic types.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-parameter-no-default
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/type_requires_more_generic_type_params.ron

Failed in:
  Struct LinuxShim (0 -> 1 required generic types) in /home/runner/work/litebox/litebox/litebox_shim_linux/src/lib.rs:222
  Struct LinuxShimBuilder (0 -> 1 required generic types) in /home/runner/work/litebox/litebox/litebox_shim_linux/src/lib.rs:143
  Struct LinuxShimEntrypoints (0 -> 1 required generic types) in /home/runner/work/litebox/litebox/litebox_shim_linux/src/lib.rs:78
  Struct LoadedProgram (0 -> 1 required generic types) in /home/runner/work/litebox/litebox/litebox_shim_linux/src/lib.rs:300

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