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 the unified ergonomic constructors on KVM: `Image::from_oci` and
//! `Image::ensure_baked` should produce a runnable KVM image on Linux (routing
//! through the KVM bake), not just on HVF.

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

    eprintln!("=== Image::from_oci(\"alpine\") ===");
    let img = Image::from_oci("alpine").expect("from_oci");
    let vm = img.start(&VmConfig::new()).expect("start");
    std::thread::sleep(std::time::Duration::from_millis(5000));
    let o = vm
        .exec_builder()
        .argv(["/bin/cat", "/etc/os-release"])
        .output()
        .expect("exec");
    eprintln!(
        "from_oci exec: success={} os={:?}",
        o.success(),
        String::from_utf8_lossy(&o.stdout)
            .lines()
            .next()
            .unwrap_or("")
    );
    vm.stop().ok();

    eprintln!("=== Image::ensure_baked(\"alpine_eb\", \"alpine\", |b| b) ===");
    let img2 = Image::ensure_baked("alpine_eb", "alpine", |b| b).expect("ensure_baked");
    let vm2 = img2.start(&VmConfig::new()).expect("start2");
    std::thread::sleep(std::time::Duration::from_millis(5000));
    let o2 = vm2
        .exec_builder()
        .argv(["/bin/echo", "ensure-baked-ok"])
        .output()
        .expect("exec2");
    eprintln!(
        "ensure_baked exec: success={} out={:?}",
        o2.success(),
        String::from_utf8_lossy(&o2.stdout).trim_end()
    );
    vm2.stop().ok();
    eprintln!("=== done ===");
}

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