Skip to main content

microvm_warm_pool/
stack_key.rs

1//! Bucket identifier for warm pool entries.
2
3/// Identifier for a pool entry's bucket. Same `(stack_name, version,
4/// vcpu_count, mem_size_mib)` share a pool; different identities have
5/// separate pools so handoff doesn't mismatch.
6///
7/// The four-tuple matches what a downstream blueprint can guarantee about a
8/// pre-restored VM:
9/// - `stack_name` + `version` pin the rootfs / sidecar image,
10/// - `vcpu_count` + `mem_size_mib` pin the machine config baked into the
11///   snapshot (Firecracker rejects restores into a differently-shaped VM).
12///
13/// All four must match for a warm entry to be valid for the caller's request.
14#[derive(Debug, Clone, Hash, Eq, PartialEq)]
15pub struct StackKey {
16    /// Logical stack identifier (e.g. `"node20"`, `"python311-pytorch"`).
17    pub stack_name: String,
18    /// Version of the stack (e.g. sidecar version, rootfs revision).
19    pub version: String,
20    /// vCPU count the snapshot was taken with — must match the restore target.
21    pub vcpu_count: u8,
22    /// Memory size (MiB) the snapshot was taken with — must match on restore.
23    pub mem_size_mib: u32,
24}