PayloadKind

Enum PayloadKind 

Source
pub enum PayloadKind {
    Scheduler(&'static Scheduler),
    Binary(&'static str),
}
Expand description

How a payload is launched inside the guest.

Two variants — scheduler and binary — map to the two launch paths in the runtime. “Kernel default” (EEVDF) is represented as Scheduler(&Scheduler::EEVDF) rather than a dedicated variant because Scheduler already carries the no-userspace-binary taxonomy via its own binary: SchedulerSpec field.

Variants§

§

Scheduler(&'static Scheduler)

Wraps an existing Scheduler definition. The scheduler’s own binary: SchedulerSpec carries the Eevdf/Discover/Path/ KernelBuiltin taxonomy — no duplication at the Payload level.

§

Binary(&'static str)

Bare userspace binary looked up by name in the guest. Not a scheduler — runs as a workload under whatever scheduler the test declares.

§How the binary reaches the guest

The stored &'static str is the executable name passed to std::process::Command::new inside the guest (see PayloadRun::run), which resolves it against the guest’s PATH. The framework resolves binaries through the include-file pipeline — for #[ktstr_test] entries via declarative include_files / extra_include_files, or via -i on ktstr shell.

Supply a binary through the framework’s include-file pipeline. The pipeline is wired up to the shell subcommand of both ktstr and cargo ktstr through the repeatable -i / --include-files flag. Each -i argument accepts:

  • an explicit path (absolute, relative, or containing /) — must exist on the host;
  • a bare name — searched in PATH on the host;
  • a directory — walked recursively, preserving structure under /include-files/<dirname>/... in the guest.

Every regular file ends up at /include-files/<name> (or deeper for directory walks). Dynamically-linked ELFs pull in their DT_NEEDED shared libraries automatically; the guest init prepends every /include-files/* subdirectory containing an executable to PATH, so a binary packaged with -i is runnable by bare name from a test body.

Example — launch a shell VM with fio available by bare name:

cargo ktstr shell -i fio --exec "fio --version"

The fio binary is resolved against the host’s PATH, copied to /include-files/fio in the guest, exposed on the guest PATH, and spawnable as fio from any guest-side process.

§#[ktstr_test] entries

Declarative include_files on #[derive(Payload)] and extra_include_files on #[ktstr_test] handle binary packaging automatically — no CLI -i and no bespoke harness needed.

§Scheduler config files

Scheduler-kind payloads that set Scheduler’s config_file field get automatic packaging: the config file is placed at /include-files/{filename} without a -i flag — the field is the source the harness reads.

§Binary-kind packaging

Payloads built via #[derive(Payload)] get automatic binary packaging: the derive macro prepends the binary = "..." spec to the emitted include_files slice, so the spawn target is packaged into the guest without requiring a separate #[include_files("...")] entry. Auxiliary files the payload needs (helpers, config files, fixtures) still go on #[include_files(...)] — the derive only injects the primary binary.

Payloads constructed manually via struct literal (rather than the derive) do not get this auto-injection: the harness does not derive include_files from the PayloadKind::Binary(name) at aggregation time. Manual constructions must list the binary in Payload::include_files themselves, or declare it on extra_include_files at the #[ktstr_test] level. A binary referenced at spawn time but neither auto-injected nor listed as an include is expected to already be present in the guest filesystem (e.g. a standard busybox applet on the base image); otherwise the omission surfaces as ENOENT at exec time inside the guest.

§Fork / kill semantics

A binary-kind payload is spawned in its own process group via CommandExt::process_group(0) in build_command so the framework can reach every descendant the binary forks. Direct consequences for test authors:

  • std::process::Child::kill() only targets the direct child — a fork()ed descendant (stress-ng worker, fio --numjobs, schbench worker mode, pipeline subshells under sh -c) survives. Never call child.kill() directly on a payload Child; the handle’s kill() wrapper fans out SIGKILL to the whole process group via killpg.
  • PayloadHandle::kill, PayloadHandle::wait cleanup, and the panic-safety Drop arm all route through kill_payload_process_group, which issues killpg(pgid, SIGKILL) followed by a single-pid SIGKILL fallback so descendants and the leader both exit. This is the only kill path test authors need.
  • Pipe drainers (stdout / stderr reader threads) block on EOF, which only arrives after every descendant holding the write ends closes them. A bare child.kill() leaves the descendants holding the pipes open and wait_and_capture hangs forever — motivating the killpg requirement.

Trait Implementations§

Source§

impl Clone for PayloadKind

Source§

fn clone(&self) -> PayloadKind

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PayloadKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for PayloadKind

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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> MaybeSend for T
where T: Send,

§

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