Hyper.Node.Img (Hyper v0.1.0)

Copy Markdown View Source

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).

Summary

Functions

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

Every image id currently active on this node.

Returns a specification to start this module under a supervisor.

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 a per-VM mutable layer for vm_id over img_id.

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.

Functions

activate(img_id)

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

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

active()

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

Every image id currently active on this node.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

create_fork(img_id, parent_vm_id, child_vm_id)

@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(img_id, vm_id)

@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(opts \\ [])

with_image(img, vm_id, callable)

@spec with_image(Hyper.Img.id(), Hyper.Vm.Id.t(), (-> 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.