Provisions & event handlers

provision {} scripts run on vmlab up (failure is fatal); on "event" {} handlers react to lifecycle events (failure is logged).

Provision scripts run on vmlab up in declaration order; event handlers react to lifecycle events. Both are wscript files — see the provision block and the event handler block for the declarations.

Provision failures fail vmlab up; handler failures are logged, never fatal. A scoped provision (vms = [...]) gates depends_on on those VMs: dependents wait for the provision to finish. See the event list for every event name.

§ 1Examples

§ 1.1A crash event handler

fn handle(event, lab): screenshot the crashed VM. Failures here are logged, never fatal.

rust
use vmlab

fn handle(event: Event, lab: Lab) {
    lab.log("crash handler fired for " + event.vm + " (" + event.name + ")")
    let Ok(vm) = lab.vm(event.vm) else { return }
    match vm.screenshot("") {
        Ok(path) => lab.log("saved crash screenshot: " + path),
        Err(e)   => lab.log("could not screenshot: " + e),
    }
}