Documentation
¶
Overview ¶
Package volume manages persistent virtio-blk disk volumes for unikernel VMs. A volume is a raw disk image file in the volume root directory, identified by a human-readable name. Volumes survive VM restarts; they are only deleted when the user explicitly runs "jerboa volume rm".
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureFormatted ¶ added in v0.51.0
func EnsureFormatted(ctx context.Context, diskPath, label string, sizeBytes int64, format Formatter) error
EnsureFormatted formats the disk at diskPath as an empty TFS volume labeled label if it is not already formatted. It is idempotent: a volume that already carries a TFS filesystem is left untouched so existing data is preserved. sizeBytes is the minimum image size; when <= 0 the current file size is used. format must be non-nil (the mkfs toolchain is supplied by the daemon).
func IsFormatted ¶ added in v0.51.0
IsFormatted reports whether the disk at path already carries a TFS filesystem (its first bytes match the TFS magic). A missing file or a freshly allocated zero-filled disk reports false.
func ParseSize ¶
ParseSize parses a human size string ("512M", "1G", "2048K") into bytes. Supported suffixes: K (kibibytes), M (mebibytes), G (gibibytes). A bare integer is interpreted as bytes. Unknown suffixes are an error.
func SanitizeLabel ¶ added in v0.51.0
SanitizeLabel trims name to a valid TFS label (<= maxLabelLen bytes). The kernel's volume_match compares the label verbatim, so it must equal the value injected into the guest mount config.
Types ¶
type Formatter ¶ added in v0.51.0
Formatter formats the raw disk at diskPath as an empty TFS filesystem labeled label with a minimum size of sizeBytes. Implemented by internal/tools using the mkfs toolchain; the daemon supplies one at run time (mkfs is Linux-only, so formatting cannot happen on a Windows client at create time).
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages volumes on disk.
func (*Store) Create ¶
Create allocates a new volume named name with the given size in bytes. If sizeBytes is 0 the default (1 GiB) is used.
type Volume ¶
type Volume struct {
// ID is the volume name (unique within the store).
ID string `json:"id"`
// DiskPath is the absolute path to the raw disk image file.
DiskPath string `json:"disk_path"`
// SizeBytes is the allocated size of the disk image.
SizeBytes int64 `json:"size_bytes"`
// CreatedAt is when the volume was created.
CreatedAt time.Time `json:"created_at"`
// Label is the TFS filesystem label written when the volume is formatted.
// It defaults to the volume ID and is the key the guest kernel matches to
// mount this disk. Capped to maxLabelLen.
Label string `json:"label,omitempty"`
}
Volume is a named persistent disk image.