# `Hyper.Node.FireVMM.Daemon`
[🔗](https://github.com/harmont-dev/hyper/blob/main/lib/hyper/node/fire_vmm/daemon.ex#L1)

The jailed firecracker OS process for one microVM, as a static child of
`Hyper.Node.FireVMM.Core`.

A `trap_exit` GenServer that owns firecracker's lifetime end to end:

  * on every (re)start it resets any stale jail left by a prior incarnation —
    the firecracker jailer refuses to reuse an existing chroot — then launches
    the jailer under a linked `MuonTrap.Daemon`. The supervised process is
    `hyper-suidhelper jailer ...`, which `execve`s into the jailer (same pid).
  * if firecracker exits, the linked `MuonTrap.Daemon` exits and this server
    stops with that reason, so `Core`'s `:one_for_all` cold-boots the pair.
  * on teardown it **guarantees firecracker is dead**: `MuonTrap`'s port-close
    kills by process group, but the jailer `setsid`s firecracker into its own
    session, so it escapes that kill and would leak (holding the cgroup, the
    rootfs dm device, loop devices). `terminate/2` therefore runs the helper's
    `cgroup.kill` teardown (`ChrootJail.remove`), which SIGKILLs the whole leaf
    cgroup regardless of session. The same call on (re)start cleans up after a
    prior incarnation the BEAM could not (a SIGKILL'd node leaves no
    `terminate/2`); the periodic `Hyper.Node.Reaper` is the final backstop.

# `child_spec`

```elixir
@spec child_spec(Hyper.Node.FireVMM.Opts.t()) :: Supervisor.child_spec()
```

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `start_link`

```elixir
@spec start_link(Hyper.Node.FireVMM.Opts.t()) :: GenServer.on_start()
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
