Hyper.Node.FireVMM.State (Hyper v0.1.0)

Copy Markdown View Source

:gen_statem controller for one microVM. It drives the boot protocol against a daemon whose lifecycle is owned by the supervisor (Hyper.Node.FireVMM.Core, :one_for_all): the controller does not launch, monitor, or kill the daemon - if firecracker dies, Core restarts the daemon and this controller together, and init simply cold-boots again.

:awaiting_api --> :configuring --> :running --> :stopping

States:

  • :awaiting_api - poll the (already-launched) daemon's API socket until it
                  answers, or fail the boot if the readiness deadline lapses.
  • :configuring - stage the kernel + rootfs device into the jail chroot
                  (rewriting the spec to in-jail paths), then push
                  machine-config, boot-source, drives, NICs, and
                  `InstanceStart`.
  • :running - guest is live; handles stop.
  • :stopping - teardown requested in-band; reject further calls.

The gen_statem data (this struct) holds the start Opts, the resolved boot spec, and the readiness deadline; the state is the lifecycle atom above.

Summary

Functions

The start Opts of the running VM id — how a fork recovers the parent's img_id/type/arch/boot_args from just a vm_id. Exits if the VM is gone; callers translate that to {:error, :not_found}.

Types

t()

@type t() :: %Hyper.Node.FireVMM.State{
  api_granted: boolean(),
  boot_deadline: integer() | nil,
  opts: Hyper.Node.FireVMM.Opts.t(),
  spec: Hyper.Node.FireVMM.BootSpec.Cold.t() | nil
}

Functions

child_spec(opts)

describe(id)

@spec describe(Hyper.Vm.Id.t()) :: Hyper.Node.FireVMM.Opts.t()

The start Opts of the running VM id — how a fork recovers the parent's img_id/type/arch/boot_args from just a vm_id. Exits if the VM is gone; callers translate that to {:error, :not_found}.

start_link(opts)

stop(id)

@spec stop(Hyper.Vm.Id.t()) :: :ok