Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KernelPath ¶
func KernelPath() string
KernelPath is the on-disk location of the shared microVM kernel binary — $XDG_DATA_HOME/weft-microvm/kernel — written by PullKernel and read by the agent's RegisterMicroVM. Exported because the agent reads it via the same path resolution rule the puller uses.
func Pull ¶
Pull resolves `image`, downloads everything, and materialises the rootfs + .weft-microvm/config.json. Returns nil on success.
func PullKernel ¶
PullKernel resolves the OCI artifact reference, downloads the kernel layer, and atomically replaces $XDG_DATA_HOME/weft-microvm/kernel. Re-running with the same ref is a (cheap) re-download — content-addressable dedup is left to the underlying transport; here we just always overwrite.
Types ¶
type Args ¶
type Args struct {
// Image is the OCI reference to boot (e.g. "alpine:3.21" or
// "ghcr.io/example/app:v1.2.3"). Required in single-container
// mode (i.e. when Pod is empty).
Image string
// Cmd overrides the image's entrypoint+cmd when non-nil
// (equivalent to the `-- CMD…` tail in a CLI front-end, e.g.
// Cmd=["sh","-c","echo hi"]).
Cmd []string
// Detach, when true, returns once the VM is alive rather than
// streaming stdio until exit. Not implemented yet.
Detach bool
// MountTag is the virtio-fs tag exposed inside the guest.
// Default "rootfs0"; rarely changed but useful for parallel
// runs sharing the same kernel.
MountTag string
// WeftSocket overrides the path to weft's Unix gRPC socket.
// Empty means use the default ~/.weft/weft.sock (same as weft).
WeftSocket string
// Project is the multitenant namespace the new microVM lands
// in. Empty resolves to weft's default project (currently
// `usr-<weft-os-user>`); a string like `team-net` lands the VM
// in a shared project. Phase-2 auth will gate access here.
Project string
// Pod, when non-empty, is the path to a pod manifest JSON
// (multi-container mode). Mutually exclusive with Image and
// Cmd: the manifest names its own images and commands. Pod mode
// boots weft-init (a supervisor PID 1) instead of weft-microvm-init.
Pod string
}
Args holds the typed inputs for Run. The CLI front-end populates it from parsed flags/positionals; library callers build it directly.
type PreparedBoot ¶
type PreparedBoot struct {
// Name is the conventional "weft-microvm-<refsafe>". Callers that
// already have a name on the request override this ; callers that
// don't (eg. weft-network's lifecycle.Ensure passing the Router
// uuid) plug it in directly.
Name string
// Kernel + Initrd : populated in direct-Linux mode (the default
// produced by the weft-microvm-init kernel + ncl-init initrd in
// the local cache). Mutually exclusive with BootISO.
Kernel string
Initrd string
// BootISO : populated only in UKI mode (when locateBootArtefacts
// finds a boot.iso but no separate kernel).
BootISO string
// Cmdline synthesised for the weft-microvm-init guest. Carries
// the rootfs share tag so the guest knows which virtio-fs share
// to pivot-root into : "weft.rootfs=virtiofs:<tag> console=hvc0".
Cmdline string
// SharePath is the host-side path to the extracted OCI rootfs
// (post-Pull). ShareTag is the virtio-fs / 9p tag the guest
// mounts at boot — default "rootfs0".
}
PreparedBoot is the bundle a `weft RegisterMicroVM` consumer (typically the weft daemon's server-side handler) plugs into the boot + shares fields after resolving an OCI image.
Mirrors what runMicroVM assembles client-side ; the goal of Prepare is to expose that same translation to any in-process caller — so the gRPC RegisterMicroVM handler can accept a bare `image` field and do the OCI pull + share assembly server-side without forcing every client (Go, Python, Terraform) to re-implement the dance.
func Prepare ¶
func Prepare(image string) (*PreparedBoot, error)
Prepare resolves an OCI image into the artefacts RegisterMicroVM needs. Pure host-side prep — doesn't dial weft, doesn't register anything ; the caller does that with the returned PreparedBoot.
Lifecycle :
- Compute the cache path for the image's rootfs.
- If missing on disk, Pull() it (matches `docker run`'s auto-pull UX). Honors WEFT_NO_AUTO_PULL=1 for strict offline mode.
- Locate the boot artefacts (the shared weft-microvm-init kernel + initrd cached under $XDG_DATA_HOME/weft-microvm/, or the fallback UKI boot.iso).
- Synthesise the cmdline + share tag.
Returns InvalidArgument when image is empty.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cpio writes the "newc" cpio archive format used by the Linux initramfs.
|
Package cpio writes the "newc" cpio archive format used by the Linux initramfs. |
|
Package initbuild produces the initramfs cpio.gz consumed by the LinuxBootLoader path.
|
Package initbuild produces the initramfs cpio.gz consumed by the LinuxBootLoader path. |