shared

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OverlayBaseDriveSuffix is appended to the root volume id to name the
	// drive that holds the read-only base.
	OverlayBaseDriveSuffix = "_base"
	// OverlayRWDriveSuffix is appended to the root volume id to name the
	// drive that holds the writable disk.
	OverlayRWDriveSuffix = "_rw"

	// OverlayBasePath is where the read-only base of an overlay root volume
	// is, relative to the state directory of the microvm.
	OverlayBasePath = "volumes/root.base"
	// OverlayRWPath is where the writable disk of an overlay root volume is,
	// relative to the state directory of the microvm.
	OverlayRWPath = "volumes/root.rw"
)
View Source
const (
	// CloudInitDriveID is the id of the drive that holds the cloud-init image.
	CloudInitDriveID = "cloud-init"
)

Variables

This section is empty.

Functions

func BuildDrives added in v0.16.0

func BuildDrives(vm *models.MicroVM, opts DriveOptions) (models.Drives, error)

BuildDrives returns the drives of a microvm in the order the guest sees them: the root volume, the cloud-init image if there is one, then the additional volumes in the order of the spec. A virtiofs volume is not a block device and gets no drive.

A root volume in VolumeModeOverlay is two drives: the read-only base, then the writable disk. Neither is flagged as the root device. The guest contract parameters tell the init which device is which.

The path of a drive is empty until its volume has been mounted.

func GenerateNetworkConfig

func GenerateNetworkConfig(vm *models.MicroVM, exclude ...string) (string, error)

GenerateNetworkConfig will generate the cloud-init network config from the vm spec. Interfaces whose guest device name is in exclude are left out.

func GuestDeviceName added in v0.16.0

func GuestDeviceName(index int) string

GuestDeviceName returns the name that the guest gives to the virtio block device at the index, counting from zero: vda to vdz, then vdaa, vdab and so on. It returns an empty string for a negative index.

func IsDriveMounted added in v0.17.0

func IsDriveMounted(vm *models.MicroVM, drive models.Drive) bool

IsDriveMounted reports whether the volume status of a microvm records the mount a drive needs. The cloud-init drive holds no volume and is always mounted. The root-base drive needs the base mount. Every other drive needs a status entry for its volume.

func PIDReadFromFile

func PIDReadFromFile(pidFile string, fs afero.Fs) (int, error)

func PIDWriteToFile

func PIDWriteToFile(pid int, pidFile string, fs afero.Fs) error

func RemoveStaleSockets added in v0.15.2

func RemoveStaleSockets(fs afero.Fs, paths ...string) error

RemoveStaleSockets removes any of the given socket files that exist, so a VMM can bind to them on (re)create.

func ResolveImageFile added in v0.15.2

func ResolveImageFile(root, filename string) (string, error)

ResolveImageFile returns the host path of filename within the image mounted at root, which must be an absolute path. Symlinks are followed as if root were the filesystem root, so the result never escapes the mount. The result must be a regular file.

func ResolveSocketPath added in v0.15.2

func ResolveSocketPath(fs afero.Fs, path, legacyPath string) string

ResolveSocketPath returns the socket path for a process that is already running. That's path, unless only legacyPath exists, which means the process was started before sockets moved out of the state directory. Legacy fallback for #1226, to be removed in the next minor release.

func SetOverlayKernelParams added in v0.17.0

func SetOverlayKernelParams(cmdLine config.KernelCmdLine, drives models.Drives)

SetOverlayKernelParams sets the guest contract parameters of an overlay root volume on a kernel command line: the contract version and the guest devices of the base and of the writable disk, taken from the drives. It replaces a value the spec set for one of them, so the init sees each key once. It does nothing when the drives hold no overlay root.

Types

type DriveOptions added in v0.16.0

type DriveOptions struct {
	// CloudInitImage is the location on the host of the cloud-init image.
	// When it is set, the image is presented read-only as the drive after the
	// root volume.
	CloudInitImage string
}

DriveOptions holds what differs between providers when the drives of a microvm are worked out.

type MachineMetrics

type MachineMetrics struct {
	Namespace   string  `json:"Namespace"`
	MachineName string  `json:"MachineName"`
	MachineUID  string  `json:"MachineUID"`
	Data        Metrics `json:"Data"`
}

func (MachineMetrics) ToPrometheus

func (mm MachineMetrics) ToPrometheus() []byte

type Metrics

type Metrics map[string]map[string]int64

Jump to

Keyboard shortcuts

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