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

Supervisor for this node's active images, and the entry point for image
operations. Owns:

  * a unique `Registry` (`img_id -> Img.Server`), and
  * a `DynamicSupervisor` holding the (shared, read-only) image servers, and
  * a *separate* `DynamicSupervisor` holding the per-VM mutable layers
    (`Img.Mutable`), so the writable layers form their own process tree.
  * a `ThinPool`, per node, which manages each `dm-thin` instance on this machine.

On top of that tree it leases an image for the lifetime of a VM
(`with_image/3`).

# `activate`

```elixir
@spec activate(Hyper.Img.id()) :: {:ok, pid()} | {:error, term()}
```

Activate `img_id` on this node: start (or reuse) its image server.

# `active`

```elixir
@spec active() :: [Hyper.Img.id()]
```

Every image id currently active on this node.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `create_fork`

```elixir
@spec create_fork(Hyper.Img.id(), Hyper.Vm.Id.t(), Hyper.Vm.Id.t()) ::
  {:ok, pid()} | {:error, term()}
```

Create `child_vm_id`'s mutable layer as a thin snapshot of `parent_vm_id`'s
live volume — same `img_id` lineage, blocks shared COW-style in the node pool.

# `create_mutable`

```elixir
@spec create_mutable(Hyper.Img.id(), Hyper.Vm.Id.t()) ::
  {:ok, pid()} | {:error, term()}
```

Create a per-VM mutable layer for `vm_id` over `img_id`.

# `start_link`

# `with_image`

```elixir
@spec with_image(Hyper.Img.id(), Hyper.Vm.Id.t(), (-&gt; result)) ::
  result | {:error, term()}
when result: var
```

Serve `img` to `vm_id` for the duration of `callable`, holding a DB lease on the
image (and transitively its whole blob chain) the whole time.

---

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