shared

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

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.

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

func GenerateNetworkConfig

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

GenerateNetworkConfig will generate the cloud-init network config from the vm spec.

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 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.

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