cdi

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package cdi reads a Container Device Interface spec and resolves what a named set of devices asks a container runtime to do.

An ateom cannot leave this to the container runtime. containerd applies CDI to the pod's containers, and an actor's containers are created by the ateom underneath one of them, so whatever hands devices to actors reads the spec itself. That holds for any sandbox, and under DRA too, which names allocated devices as CDI device IDs.

Applying the edits is a separate step and is not generic: it depends on how the sandbox gets an OCI spec and whether it shares the host's device nodes. See cmd/ateom-gvisor/internal/cdiinject for the gVisor one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dev

type Dev struct {
	Path  string `json:"path"`
	Type  string `json:"type,omitempty"`
	Major int64  `json:"major,omitempty"`
	Minor int64  `json:"minor,omitempty"`
}

Dev is a device node to create in the container. Major and Minor are often absent: CDI leaves resolving them to the OCI runtime, which stats the host.

type Device

type Device struct {
	Name           string `json:"name"`
	ContainerEdits Edits  `json:"containerEdits"`
}

Device is one addressable device in a spec. Generators name the same underlying hardware several ways -- nvidia-ctk emits per-index ("0"), per-UUID and an "all" device that repeats every node -- so applying every device in a spec injects each node several times over.

type Edits

type Edits struct {
	Env         []string `json:"env,omitempty"`
	DeviceNodes []Dev    `json:"deviceNodes,omitempty"`
	Mounts      []Mount  `json:"mounts,omitempty"`
	Hooks       []Hook   `json:"hooks,omitempty"`
}

Edits are the changes a device makes to a container.

type Hook

type Hook struct {
	HookName string   `json:"hookName"`
	Path     string   `json:"path"`
	Args     []string `json:"args,omitempty"`
	Env      []string `json:"env,omitempty"`
}

Hook is a lifecycle hook the spec asks the runtime to run.

type Mount

type Mount struct {
	HostPath      string   `json:"hostPath"`
	ContainerPath string   `json:"containerPath"`
	Type          string   `json:"type,omitempty"`
	Options       []string `json:"options,omitempty"`
}

Mount is a host path to mount into the container.

type Spec

type Spec struct {
	Devices []Device `json:"devices"`
	// ContainerEdits apply to any container the spec touches, whichever devices
	// were named (driver libraries, control device nodes, env).
	ContainerEdits Edits `json:"containerEdits"`
}

Spec is the part of a CDI spec that is consumed here: the devices and the edits applied to every container.

func Parse

func Parse(data []byte) (*Spec, error)

Parse reads a CDI spec in JSON form.

func (*Spec) EditsFor

func (s *Spec) EditsFor(devices []string) (Edits, error)

EditsFor collects the spec-level edits plus those of the named devices. A name the spec does not carry is an error rather than a silent no-op: it means the caller and the generator disagree about what the host has.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL