#[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");
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 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");
}