disk

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package disk is the runtime attach interface for extra virtio-blk disks backed by existing raw files. Attach is runtime-only — snapshot/hibernate is refused while one is attached; detach never deletes the backing file.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedBackend = errors.New("backend does not support disk attach")

ErrUnsupportedBackend signals the backend cannot hot-plug virtio-blk disks (e.g. Firecracker).

Functions

func DeriveID

func DeriveID(name string) string

DeriveID returns the deterministic CH device id for a disk name (used by attach + detach so concurrent attaches collide on CH's id check).

func NameFromID

func NameFromID(id string) string

NameFromID reverses DeriveID; empty when id is not a hot-added disk (foreign same-prefix ids with an illegal name suffix are not ours).

Types

type Attached

type Attached struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Path     string `json:"path"`
	ReadOnly bool   `json:"readonly,omitempty"`
}

Attached is the inspect-time view of one hot-added disk read from the running VM's CH config.

type Attacher

type Attacher interface {
	DiskAttach(ctx context.Context, vmRef string, spec Spec) (deviceID string, err error)
	DiskDetach(ctx context.Context, vmRef, name string) error
}

Attacher hot-plugs and removes virtio-blk data disks on a running VM.

type Lister

type Lister interface {
	DiskList(ctx context.Context, vmRef string) ([]Attached, error)
}

Lister enumerates hot-added disks from running VM state.

type Spec

type Spec struct {
	Path     string
	Name     string
	ReadOnly bool
	DirectIO *bool
}

Spec is one attach request: an existing raw disk file. DirectIO nil means the create-path default (O_DIRECT unless writable disks have it disabled); tmpfs-backed files need an explicit off.

func (*Spec) Normalize

func (s *Spec) Normalize() error

Normalize enforces required fields; Name doubles as the guest serial (/dev/disk/by-id/virtio-<name>) and the detach key.

Jump to

Keyboard shortcuts

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