guest

package
v0.0.0-...-760d706 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package guest implements utilities and structured data for libvirt virtual machines

Index

Constants

This section is empty.

Variables

View Source
var ErrVMNotFound = errors.New("virtual machine not found")

ErrVMNotFound error when virtual machine is not found

Functions

This section is empty.

Types

type BlockIOParametersInfo

type BlockIOParametersInfo struct {
	Weight          uint
	DeviceWeight    string
	DeviceReadIops  string
	DeviceWriteIops string
	DeviceReadBps   string
	DeviceWriteBps  string
}

BlockIOParametersInfo is the struct describing VM block IO parameters

type DiskInfo

type DiskInfo struct {
	Name           string
	Partition      bool
	Alias          string
	GuestAlias     string
	DiskDependency []string
}

DiskInfo is the struct for guest disk information, and is used in VM

type IPInfo

type IPInfo struct {
	Type   string
	Addr   string
	Prefix uint
}

IPInfo provides guest IP network information, and is used in NetIFaceInfo

type NetIFaceInfo

type NetIFaceInfo struct {
	Name   string
	HWAddr string
	IP     []IPInfo
}

NetIFaceInfo provides guest Network Interface information, and is used in VM

type OSInfo

type OSInfo struct {
	ID            string
	Name          string
	PrettyName    string
	Version       string
	VersionID     string
	KernelRelease string
	KernelVersion string
	Machine       string
	Variant       string
	VariantID     string
}

OSInfo is the struct for guest operating system information, and is used in VM

type TimeZoneInfo

type TimeZoneInfo struct {
	Name   string
	Offset int
}

TimeZoneInfo provides guest timezone information, and is used in VM

type UserInfo

type UserInfo struct {
	Name      string
	Domain    string
	LoginTime time.Time
}

UserInfo is the struct for VM user information, and is used in VM

type VM

type VM struct {
	Name              string
	HostName          string
	ID                uint
	BackupXML         string
	Autostart         bool
	BlockIOParameters BlockIOParametersInfo
	Disks             []DiskInfo
	Users             []UserInfo
	OS                OSInfo
	TimeZone          TimeZoneInfo
	NetIFace          []NetIFaceInfo
	// contains filtered or unexported fields
}

VM holds a handle is used to communicate to Domains

func GetGuest

func GetGuest(name string, conn *libvirt.Connect) (*VM, error)

GetGuest loads guest information by name and returns it

func (*VM) Close

func (g *VM) Close() error

Close closes an open connection

type VMState

type VMState uint8

VMState represents different states a virtual machine can be in Some states are mutually exclusive, but some can be applied at the same time. ie. A machine can be running, and migrating at the same time. A machine can be running, but had a failed migration

const (

	// StateStopped means the VM isn't running
	StateStopped VMState = iota
	// StateRunning means the VM is currently running
	StateRunning
	// StateFailed means the VM is in a failed state, which can indicate a few things:
	// The VM healthcheck (not yet defined, but will be) has failed
	// A Migration has failed
	// Adding or removing a device has failed
	StateFailed
	// StateMigrated means the VM was successfully migrated to a new host
	StateMigrated
	// StateHealthy means the VM had a successful healthcheck the last time it was done
	StateHealthy
	// StateUnhealthy means the opposite of healthy, as in the VM has failed a health check
	StateUnhealthy

	// StateStarted means the VM has been turned on, but is not nesicarily available yet
	StateStarted
	// StateRestarted means a reboot was triggered, but hasn't be finished yet
	StateRestarted
	// StatePoweroff means a shutdown was triggered, but isn't finished yet
	StatePoweroff
	// StateMigrate means a migration was started, but isn't done yet
	StateMigrate
	// StateCreate means a VM is being created
	StateCreate
	// StateInstall means a VM is being installed. This usually implies from an ISO and
	// not an automated installation
	StateInstall
	// StateDestroy means a VM is scheduled or is in progress of being destroyed and deleted
	StateDestroy
	// StateBackup means a VM is in process of being backed up
	StateBackup
	// StateRestore means a VM is in process of being restored
	StateRestore
)

Jump to

Keyboard shortcuts

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