supermachine 0.7.82

Run any OCI/Docker image as a hardware-isolated microVM on macOS HVF (Linux KVM and Windows WHP in progress). Single library API, zero flags for the common case, sub-100 ms cold-restore from snapshot.
Documentation
//! Validate idle pre-warming: a pool with min>0 keeps N pre-restored VMs ready,
//! so acquire is a ~µs pop (not a ~ms restore), and the idle set refills.

#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
fn main() {
    use std::time::{Duration, Instant};
    use supermachine::Image;

    let image = Image::from_oci("alpine").expect("from_oci");
    eprintln!("=== pool().min(2).max(8).build() ===");
    let pool = image.pool().min(2).max(8).build().expect("build");
    // Let the background refiller pre-warm the idle set.
    std::thread::sleep(Duration::from_millis(1500));
    let s = pool.stats();
    eprintln!(
        "after warm: idle={} alive={} min={} max={}",
        s.idle, s.alive, s.min, s.max
    );

    for i in 0..4 {
        let t = Instant::now();
        let vm = pool.acquire().expect("acquire");
        let acq = t.elapsed();
        let o = vm
            .exec_builder()
            .argv(["/bin/echo", "ok"])
            .output()
            .expect("exec");
        eprintln!("acquire #{i}: {acq:?} exec_ok={}", o.success());
        drop(vm);
        std::thread::sleep(Duration::from_millis(300)); // let refill catch up
    }
    let s2 = pool.stats();
    eprintln!("final: idle={} alive={}", s2.idle, s2.alive);
    let pass = s.idle >= 2;
    eprintln!(
        "=== IDLE PRE-WARM: {} ===",
        if pass { "PASS" } else { "FAIL" }
    );
}

#[cfg(not(all(target_os = "linux", target_arch = "x86_64")))]
fn main() {
    eprintln!("kvm_idle_pool is Linux/x86_64 only");
}