Documentation
¶
Overview ¶
Package virt is VirtoMir's gateway to libvirt. It owns the libvirt RPC connection, reconnects transparently when libvirtd restarts, and converts libvirt's raw values into the types the rest of VirtoMir works with.
Index ¶
- Constants
- Variables
- func BackupSpace(dir BackupDir) (free, total uint64, ok bool)
- func BuildDomain(s CreateSpec, diskPath, diskFormat, seedPath string, ...) *libvirtxml.Domain
- func CheckName(what, name string) error
- func FilterName(uuid string) string
- func FormatUUID(u libvirt.UUID) string
- func HashPassword(password string) (string, error)
- func IsCryptHash(s string) bool
- func LabelForVMs(log *slog.Logger, dir string)
- func OnSystemDisk(dir BackupDir) bool
- func RewriteForMove(doc string, paths map[string]string) (string, []string, error)
- func SameCPU(a, b HostCPU) bool
- func TemplateDisks(x *libvirtxml.Domain) []*libvirtxml.DomainDisk
- func VXLANBridge(vni uint) string
- type Action
- type Backup
- type BackupDir
- type BackupDisk
- type BackupOptions
- type BalloonStats
- type BootDevice
- type BusyError
- type CPUInfo
- type Client
- func (c *Client) AddDHCPHost(network string, h DHCPHost) error
- func (c *Client) AddDevice(uuid string, spec DeviceSpec) (DeviceResult, error)
- func (c *Client) AdoptDomain(doc string) (string, error)
- func (c *Client) AttachDisk(uuid string, spec DiskSpec) (string, error)
- func (c *Client) AttachHostdev(uuid string, spec HostdevSpec) (liveErr string, err error)
- func (c *Client) AttachInterface(uuid string, spec NICSpec) error
- func (c *Client) BackupDomain(ctx context.Context, dir BackupDir, uuid string, opts BackupOptions, ...) (Backup, error)
- func (c *Client) BaselineCPU(cpus []HostCPU) (string, error)
- func (c *Client) ChangeMedia(uuid, target, source string) error
- func (c *Client) CheckCreate(spec CreateSpec) error
- func (c *Client) CheckPaths(paths []string) ([]PathCheck, error)
- func (c *Client) Clone(ctx context.Context, uuid, name string, report func(string)) (string, error)
- func (c *Client) Close() error
- func (c *Client) ConfidentialKinds() ([]string, error)
- func (c *Client) ConfigEvents(ctx context.Context) (<-chan ConfigEvent, error)
- func (c *Client) Conn() (*libvirt.Libvirt, error)
- func (c *Client) ConsoleInfo(uuid string) (ConsoleInfo, error)
- func (c *Client) ContainerSupport() error
- func (c *Client) CopyVolumeInto(src, pool, name, format string, minBytes uint64) (libvirt.StorageVol, string, error)
- func (c *Client) CreateContainer(ctx context.Context, spec CreateSpec, report func(string)) (CreateResult, error)
- func (c *Client) CreateDomain(spec CreateSpec) (CreateResult, error)
- func (c *Client) CreateMDev(spec MDevSpec) (string, error)
- func (c *Client) CreateNetwork(spec NetworkSpec) error
- func (c *Client) CreatePool(spec PoolSpec) error
- func (c *Client) CreateSnapshot(uuid string, spec SnapshotSpec) (string, error)
- func (c *Client) CreateVolume(pool string, spec VolumeSpec) (Volume, error)
- func (c *Client) CreateVolumeFile(pool, name string, bytes uint64, format string, provisioning ...string) (libvirt.StorageVol, string, error)
- func (c *Client) DefineNetworkXML(name, doc string) (ObjectSaveResult, error)
- func (c *Client) DefinePoolXML(name, doc string) (ObjectSaveResult, error)
- func (c *Client) DefineXML(uuid, xmlDoc string) (DefineResult, error)
- func (c *Client) Delete(uuid string, removeStorage bool) (DeleteResult, error)
- func (c *Client) DeleteBackup(dir BackupDir, id string) error
- func (c *Client) DeleteDHCPHost(network, mac string) error
- func (c *Client) DeleteMDev(uuid string) error
- func (c *Client) DeleteNetwork(name string) error
- func (c *Client) DeletePool(name string) error
- func (c *Client) DeleteSnapshot(uuid, name string) error
- func (c *Client) DeleteStorageVol(vol libvirt.StorageVol) error
- func (c *Client) DeleteVolume(pool, name string) error
- func (c *Client) Deploy(ctx context.Context, template string, spec DeploySpec, report func(string)) (string, error)
- func (c *Client) DetachDevice(uuid string, ref DeviceRef) (DeviceResult, error)
- func (c *Client) DialSPICE(ctx context.Context, uuid string) (net.Conn, error)
- func (c *Client) DialVNC(ctx context.Context, uuid string) (net.Conn, error)
- func (c *Client) DialVNCHead(ctx context.Context, uuid string, head int) (net.Conn, error)
- func (c *Client) DiskBytes(uuids []string) (map[string]uint64, error)
- func (c *Client) DiskUsers() (map[string][]string, error)
- func (c *Client) DomainAction(uuid string, action Action) error
- func (c *Client) DomainActive(uuid string) (bool, error)
- func (c *Client) DomainDetail(uuid string) (DomainDetail, error)
- func (c *Client) DomainStats() ([]DomainStats, error)
- func (c *Client) DomainUUIDs() ([]string, error)
- func (c *Client) DomainXML(uuid string, inactive bool) (string, error)
- func (c *Client) Firewall(uuid string) (Firewall, error)
- func (c *Client) FlatCopy(ctx context.Context, dir BackupDir, id string, report func(string)) (string, func(), error)
- func (c *Client) GetQEMUArgs(uuid string) (QEMUArgs, error)
- func (c *Client) GetSettings(uuid string) (SettingsView, error)
- func (c *Client) GuestExec(ctx context.Context, uuid string, argv []string) (GuestExecResult, error)
- func (c *Client) GuestInfo(uuid string) (GuestInfo, error)
- func (c *Client) HostCPU() (HostCPU, error)
- func (c *Client) HostHardware() (HostHardware, error)
- func (c *Client) HostInfo() (HostInfo, error)
- func (c *Client) HostStats() (HostStats, error)
- func (c *Client) ImportOVA(ctx context.Context, pool, name string, r io.Reader, report func(string)) (CreateResult, error)
- func (c *Client) LabelDirPools()
- func (c *Client) LifecycleEvents(ctx context.Context) (<-chan string, error)
- func (c *Client) ListBackups(dir BackupDir, uuid string) ([]Backup, error)
- func (c *Client) ListDomains() ([]Domain, error)
- func (c *Client) ListNetworks() ([]VNetwork, error)
- func (c *Client) ListPools() ([]Pool, error)
- func (c *Client) ListSnapshots(uuid string) ([]Snapshot, error)
- func (c *Client) ListVolumes(pool string) ([]Volume, error)
- func (c *Client) MigrateBegin(uuid string, flags libvirt.DomainMigrateFlags, disks []string) ([]byte, string, error)
- func (c *Client) MigrateConfirm(uuid string, cookie []byte, flags libvirt.DomainMigrateFlags, disks []string, ...) error
- func (c *Client) MigrateFinish(name, uri string, cookie []byte, flags libvirt.DomainMigrateFlags, ...) ([]byte, error)
- func (c *Client) MigratePerform(ctx context.Context, uuid, uri string, cookie []byte, ...) ([]byte, error)
- func (c *Client) MigratePrepare(name, xml, uri string, cookie []byte, flags libvirt.DomainMigrateFlags, ...) ([]byte, string, error)
- func (c *Client) MoveDisk(ctx context.Context, uuid, target, pool string, report func(string)) error
- func (c *Client) NameTaken(name string) (bool, error)
- func (c *Client) NetworkAction(name, action string) error
- func (c *Client) NetworkLeases(name string) ([]Lease, error)
- func (c *Client) NetworkXML(name string) (string, error)
- func (c *Client) Placements() ([]Placement, error)
- func (c *Client) PlanMigration(uuid string) (MigrationSource, error)
- func (c *Client) PlanMove(uuid string) (MovePlan, error)
- func (c *Client) PoolAction(name, action string) error
- func (c *Client) PoolXML(name string) (string, error)
- func (c *Client) PreviewSettings(uuid string, s Settings) (Preview, error)
- func (c *Client) PruneBackups(dir BackupDir, uuid string, keep func([]time.Time) []bool) (int, error)
- func (c *Client) RemoveFirewall(uuid string) error
- func (c *Client) RemoveImage(path string) error
- func (c *Client) Rename(uuid, name string) error
- func (c *Client) ResizeDisk(uuid, target string, sizeGiB uint64) error
- func (c *Client) ResizeVolume(pool, name string, sizeGiB uint64) error
- func (c *Client) RestoreBackup(ctx context.Context, dir BackupDir, id, name, pool string, force bool, ...) (string, error)
- func (c *Client) RestoreXML(uuid, xmlDoc string) (DefineResult, error)
- func (c *Client) RevertSnapshot(uuid, name string, safety bool) (RevertResult, error)
- func (c *Client) SaveSettings(uuid string, s Settings) (SaveResult, error)
- func (c *Client) SerialConsole(ctx context.Context, uuid, device string, in io.Reader, out io.Writer) error
- func (c *Client) SetAutostart(uuid string, on bool) error
- func (c *Client) SetDiskQoS(uuid, target string, qos DiskIoTune) error
- func (c *Client) SetDisplay(uuid, protocol string) error
- func (c *Client) SetFirewall(uuid string, fw Firewall) (FirewallResult, error)
- func (c *Client) SetGPUPool(uuid, pool string, count int) error
- func (c *Client) SetGuestPassword(uuid, user, password string) error
- func (c *Client) SetInterfaceBandwidth(uuid, mac string, bw NICBandwidth) error
- func (c *Client) SetNetworkAutostart(name string, on bool) error
- func (c *Client) SetOwner(uuid, owner string) error
- func (c *Client) SetPoolAutostart(name string, on bool) error
- func (c *Client) SetProject(uuid, projectID string) error
- func (c *Client) SetQEMUArgs(uuid string, q QEMUArgs) (DefineResult, error)
- func (c *Client) SetTemplate(uuid string, on bool) error
- func (c *Client) SetVXLANPeers(name string, peers []string) error
- func (c *Client) SparsifyDisk(ctx context.Context, uuid, target string, report func(string)) (uint64, error)
- func (c *Client) SweepPartialBackups(dir BackupDir, olderThan time.Duration) (int, error)
- func (c *Client) UploadBytes(pool, name string, data []byte) (libvirt.StorageVol, string, error)
- func (c *Client) UploadVolume(ctx context.Context, pool, name string, size int64, r io.Reader) (Volume, error)
- func (c *Client) VXLANTunnels() ([]Tunnel, error)
- func (c *Client) VerifyBackup(ctx context.Context, dir BackupDir, id string, report func(string)) (Backup, error)
- type CloudInit
- type ConfigEvent
- type ConsoleInfo
- type ContainerImage
- type CreateResult
- type CreateSpec
- type DHCPHost
- type DRHost
- func (h DRHost) DefineDomain(xmlDoc string) (string, error)
- func (h DRHost) DomainState(uuid string) (string, error)
- func (h DRHost) GetDomainXML(uuid string) (string, error)
- func (h DRHost) StartDomain(uuid string) error
- func (h DRHost) StopDomain(uuid string, force bool) error
- func (h DRHost) UndefineDomain(uuid string) error
- type DefineResult
- type DeleteResult
- type DeploySpec
- type Device
- type DeviceGroup
- type DeviceRef
- type DeviceResult
- type DeviceSpec
- type DiskCounters
- type DiskIoTune
- type DiskSpec
- type Domain
- type DomainDetail
- type DomainState
- type DomainStats
- type Firewall
- type FirewallResult
- type FirewallRule
- type GuestExecResult
- type GuestFilesystem
- type GuestInfo
- type HostCPU
- type HostHardware
- type HostInfo
- type HostMDev
- type HostMDevType
- type HostPCI
- type HostStats
- type HostUSB
- type HostdevSpec
- type InvalidError
- type KeptVolume
- type Lease
- type LiveDisk
- type MDevSpec
- type MemoryInfo
- type MigrationSource
- type MoveDisk
- type MovePlan
- type NICBandwidth
- type NICSpec
- type NetCounters
- type NetworkSpec
- type OVF
- type ObjectSaveResult
- type OperationError
- type PathCheck
- type Placement
- type Pool
- type PoolSpec
- type Preview
- type Prop
- type QEMUArgs
- type RevertResult
- type SaveResult
- type Settings
- type SettingsView
- type Snapshot
- type SnapshotSpec
- type SpiceInfo
- type StaticNetwork
- type SystemInfo
- type Tuning
- type Tunnel
- type VCPUPlacement
- type VNCInfo
- type VNetwork
- type Volume
- type VolumeSpec
Constants ¶
const DefaultSocket = "/var/run/libvirt/libvirt-sock"
DefaultSocket is the system libvirtd (or virtproxyd) UNIX socket.
const MaxManualChain = 30
MaxManualChain caps the chain of incremental backups made by hand (BackupOptions.FullEvery).
const MigrateFlags = libvirt.MigrateLive | libvirt.MigratePersistDest | libvirt.MigrateUndefineSource | libvirt.MigrateChangeProtection | libvirt.MigrateAutoConverge
MigrateFlags are what every VirtoMir live migration uses; copying disks adds MigrateNonSharedDisk.
const (
// VXLANMTU is the bridge and guest MTU on a 1500-byte underlay.
VXLANMTU = 1450
)
Variables ¶
var ContainerImages = []ContainerImage{ {Key: "debian-13", Label: "Debian 13 (trixie)", /* contains filtered or unexported fields */}, {Key: "ubuntu-24.04", Label: "Ubuntu 24.04 LTS", /* contains filtered or unexported fields */}, {Key: "alpine-3.22", Label: "Alpine Linux 3.22", /* contains filtered or unexported fields */}, }
ContainerImages are the images VirtoMir offers.
var ErrNotFound = errors.New("not found")
ErrNotFound means the requested object (domain, pool, volume, network, snapshot) does not exist (any more).
var MemAvailableKiB = func() uint64 { raw, err := os.ReadFile("/proc/meminfo") if err != nil { return 0 } return parseMemAvailable(string(raw)) }
MemAvailableKiB is the host's MemAvailable from /proc/meminfo (0 when unknown): memory a new guest can get without the host swapping. Tests replace it.
Functions ¶
func BackupSpace ¶ added in v1.1.0
BackupSpace is the free and total bytes where backups go (ok false when unknown).
func BuildDomain ¶ added in v0.9.0
func BuildDomain(s CreateSpec, diskPath, diskFormat, seedPath string, diskVolume ...*libvirtxml.DomainDiskSourceVolume) *libvirtxml.Domain
BuildDomain constructs the libvirt Domain configuration for a CreateSpec.
func FormatUUID ¶ added in v0.9.0
FormatUUID formats a libvirt UUID byte array into a canonical UUID string.
func HashPassword ¶ added in v0.9.0
HashPassword returns a glibc-style $6$ SHA-512 password hash for the given plaintext password, using a random 16-character salt. The result is in the format cloud-init expects for its hashed_passwd field.
func IsCryptHash ¶ added in v0.9.0
IsCryptHash reports whether s looks like a glibc crypt password hash ($1$ MD5, $5$ SHA-256, $6$ SHA-512).
func LabelForVMs ¶ added in v1.2.1
LabelForVMs gives dir (and everything below it) the virt_image_t label when SELinux is on and the folder does not have it yet: a persistent rule through semanage, then restorecon; without semanage, chcon (lost on a full relabel, but correct until then). Errors are only logged: the folder still works where SELinux allows it.
func OnSystemDisk ¶ added in v1.1.1
OnSystemDisk reports whether backups land on the same file system as "/" (Linux only): they would not survive that disk failing.
func RewriteForMove ¶
RewriteForMove points the definition at the copied disks (old path → new path) and ejects CD/DVD media, which stay on the old host. It returns notes for the user.
func SameCPU ¶
SameCPU reports whether two hosts have the same CPU (model, vendor and features), the condition for live-migrating a machine whose CPU is "same as host" (host-passthrough).
func TemplateDisks ¶ added in v0.9.0
func TemplateDisks(x *libvirtxml.Domain) []*libvirtxml.DomainDisk
TemplateDisks are the disks a new machine needs its own copy (or overlay) of.
func VXLANBridge ¶ added in v0.8.0
VXLANBridge is the bridge of the VXLAN network with vni.
Types ¶
type Action ¶
type Action string
Action is a power/lifecycle operation on a domain.
const ( ActionStart Action = "start" ActionShutdown Action = "shutdown" // ACPI power button; the guest decides ActionReboot Action = "reboot" // ACPI reboot request ActionForceOff Action = "force-off" // virDomainDestroy: pulls the plug ActionPause Action = "pause" // virDomainSuspend: freezes vCPUs, RAM stays allocated ActionResume Action = "resume" ActionReset Action = "reset" // virDomainReset: hardware reset button, no guest involvement // ActionSave writes RAM to disk and stops the machine (libvirt managed save); the next // start resumes exactly where it was. ActionSave Action = "save" )
func ParseAction ¶
type Backup ¶
type Backup struct {
ID string `json:"id"` // "<machine dir>/<timestamp>"
Domain string `json:"domain"`
DomainUUID string `json:"domainUuid"`
Created time.Time `json:"created"`
Live bool `json:"live"` // taken while running (libvirt backup job)
Automatic bool `json:"automatic"` // made by a schedule (subject to its retention)
Disks []BackupDisk `json:"disks"`
SizeBytes uint64 `json:"sizeBytes"`
DurationSec float64 `json:"durationSec"`
Note string `json:"note,omitempty"`
// Incremental: its disk files hold only what changed since Parent (another backup ID of
// the same machine) and build on Parent's files. Checkpoint is the libvirt checkpoint
// taken with it, which the next incremental backup starts from (see backup_incr.go).
Incremental bool `json:"incremental,omitempty"`
Parent string `json:"parent,omitempty"`
Checkpoint string `json:"checkpoint,omitempty"`
// Verified is when the disk files were last checked (qemu-img check and checksums, see
// backup_verify.go); CheckError is what that check found wrong ("" = fine).
Verified *time.Time `json:"verified,omitempty"`
CheckError string `json:"checkError,omitempty"`
// Location is the earlier backup folder this backup is in ("" = the current one); not stored.
Location string `json:"location,omitempty"`
}
Backup is one full backup of a machine: its definition plus a copy of every own disk, in <dir>/<machine>-<uuid8>/<timestamp>/ with a manifest.json describing it.
type BackupDir ¶
type BackupDir string
BackupDir is where backups go; it must be on a disk with room (NFS mounts work).
type BackupDisk ¶
type BackupOptions ¶ added in v1.0.0
type BackupOptions struct {
// Automatic: made by a schedule (subject to its retention).
Automatic bool
// FullEvery: 0 or 1 always takes a full backup; n > 1 takes incremental ones (only what
// changed since the previous backup) with a full one every n backups.
FullEvery int
}
BackupOptions says how BackupDomain backs up.
type BalloonStats ¶
type BalloonStats struct {
CurrentKiB uint64
MaximumKiB uint64
RSSKiB uint64 // host memory the QEMU process really uses
UsableKiB uint64 // guest: memory it could use without swapping
AvailableKiB uint64 // guest: total memory it sees
}
BalloonStats in KiB. Guest-reported values (Usable, Available) need the balloon driver and a stats period in the guest; they are 0 otherwise.
type BootDevice ¶
BootDevice is something the machine can boot from.
type BusyError ¶ added in v1.1.0
type BusyError struct{ Op string }
BusyError means another long operation (clone, backup, restore, delete, …) holds the machine right now. The API answers it with 409 Conflict.
type CPUInfo ¶
type CPUInfo struct {
Mode string `json:"mode"` // host-passthrough, host-model, custom, maximum
Model string `json:"model,omitempty"`
Sockets int `json:"sockets"`
Dies int `json:"dies,omitempty"`
Cores int `json:"cores"`
Threads int `json:"threads"`
VCPUs uint `json:"vcpus"` // currently plugged
MaxVCPUs uint `json:"maxVcpus"` // <vcpu> value
CPUSet string `json:"cpuset,omitempty"`
Features int `json:"features"` // explicit <feature> overrides
NUMANodes int `json:"numaNodes"`
Pinned bool `json:"pinned"`
}
type Client ¶
type Client struct {
// ContainerDir holds the containers' root file systems and the downloaded images
// ("" = /var/lib/virtomir/containers).
ContainerDir string
// ProtectedDirs, when set, returns the directories VirtoMir keeps its own files in (the
// state directory, the backup location); no storage pool may be created in them.
ProtectedDirs func() []string
// OldBackupDirs, when set, returns the earlier backup locations; backups made there are
// still listed, pruned, verified and restored (backup_dirs.go).
OldBackupDirs func() []string
// contains filtered or unexported fields
}
Client is safe for concurrent use; go-libvirt multiplexes calls over one connection.
func (*Client) AddDHCPHost ¶
AddDHCPHost reserves an address. Takes effect for the next lease the machine requests.
func (*Client) AddDevice ¶
func (c *Client) AddDevice(uuid string, spec DeviceSpec) (DeviceResult, error)
AddDevice adds one of the extra devices.
func (*Client) AdoptDomain ¶
AdoptDomain defines a machine moved here from another host. Name and UUID must be free.
func (*Client) AttachDisk ¶
AttachDisk adds a disk or CD/DVD drive, creating a new volume if requested. It returns the device name in the guest (e.g. "vdb").
func (*Client) AttachHostdev ¶
func (c *Client) AttachHostdev(uuid string, spec HostdevSpec) (liveErr string, err error)
AttachHostdev passes a host PCI or USB device to a machine (in its definition; also live when it runs and the device allows hot-plug). The same safety checks as the hardware list apply.
func (*Client) BackupDomain ¶
func (c *Client) BackupDomain(ctx context.Context, dir BackupDir, uuid string, opts BackupOptions, report func(string)) (Backup, error)
BackupDomain takes a backup. Running machines are backed up live and consistently with libvirt's backup job (no downtime, no snapshot left behind) — incrementally when opts and the machine allow it (see backup_incr.go); stopped ones are copied in full with qemu-img. Progress goes to report.
func (*Client) BaselineCPU ¶
BaselineCPU is the newest named CPU model every given host supports.
func (*Client) ChangeMedia ¶
ChangeMedia inserts an image into (or with source "" ejects it from) a CD/DVD or floppy drive.
func (*Client) CheckCreate ¶ added in v1.1.0
func (c *Client) CheckCreate(spec CreateSpec) error
CheckCreate answers the mistakes CreateDomain would refuse before it touches any disk (invalid spec, name taken, pool without files, disk in use), so the API can say so before it starts the slow part in the background.
func (*Client) CheckPaths ¶
CheckPaths answers PathCheck for each path (target side).
func (*Client) Clone ¶
Clone copies a shut-off machine under a new name: new UUID and MAC addresses, fresh UEFI variables and TPM, and a full copy of every writable disk in the same storage pool. Copying can take minutes; progress is reported through report.
func (*Client) ConfidentialKinds ¶ added in v0.8.0
ConfidentialKinds is what memory encryption this host can give new machines.
func (*Client) ConfigEvents ¶ added in v1.1.0
func (c *Client) ConfigEvents(ctx context.Context) (<-chan ConfigEvent, error)
ConfigEvents streams the libvirt events that change machine configurations: defined and undefined machines, starts and stops, and devices added or removed while running (hot-plug, e.g. virsh attach-device --live). The channel closes when ctx ends or the connection to libvirt drops; callers subscribe again after reconnecting. Device events are optional: an old libvirt without them still delivers the lifecycle events.
It subscribes on a connection of its own: libvirt 12 refuses a second callback for the same event on one connection ("event callback already tracked"), and the live view (LifecycleEvents) subscribes on the shared one.
func (*Client) ConsoleInfo ¶
func (c *Client) ConsoleInfo(uuid string) (ConsoleInfo, error)
ConsoleInfo describes the consoles of a machine.
func (*Client) ContainerSupport ¶ added in v0.8.0
ContainerSupport is nil when this host can run system containers, else why not.
func (*Client) CopyVolumeInto ¶ added in v0.9.0
func (c *Client) CopyVolumeInto(src, pool, name, format string, minBytes uint64) (libvirt.StorageVol, string, error)
CopyVolumeInto copies the pool volume at src into pool as name (converting to format) and resizes it if needed.
func (*Client) CreateContainer ¶ added in v0.8.0
func (c *Client) CreateContainer(ctx context.Context, spec CreateSpec, report func(string)) (CreateResult, error)
CreateContainer makes a system container from one of ContainerImages (a background job: the image may have to be downloaded first).
func (*Client) CreateDomain ¶
func (c *Client) CreateDomain(spec CreateSpec) (CreateResult, error)
CreateDomain creates the system disk, defines the machine and optionally starts it.
func (*Client) CreateMDev ¶
CreateMDev creates a slice, starts it and keeps it across host reboots. It returns its UUID.
func (*Client) CreateNetwork ¶
func (c *Client) CreateNetwork(spec NetworkSpec) error
CreateNetwork defines, starts and autostarts a network.
func (*Client) CreatePool ¶
CreatePool defines, builds (creates the directory, mount point or volume group), starts (mounts) and autostarts a pool.
func (*Client) CreateSnapshot ¶
func (c *Client) CreateSnapshot(uuid string, spec SnapshotSpec) (string, error)
CreateSnapshot takes a snapshot: for a running machine its memory is saved too, so reverting brings it back exactly as it was (see snapshotDoc for where it is kept).
func (*Client) CreateVolume ¶
func (c *Client) CreateVolume(pool string, spec VolumeSpec) (Volume, error)
func (*Client) CreateVolumeFile ¶ added in v0.9.0
func (c *Client) CreateVolumeFile(pool, name string, bytes uint64, format string, provisioning ...string) (libvirt.StorageVol, string, error)
CreateVolumeFile creates a new volume in pool and returns the volume descriptor and path.
func (*Client) DefineNetworkXML ¶ added in v0.5.0
func (c *Client) DefineNetworkXML(name, doc string) (ObjectSaveResult, error)
DefineNetworkXML replaces a network's definition. Name and UUID must stay.
func (*Client) DefinePoolXML ¶ added in v0.5.0
func (c *Client) DefinePoolXML(name, doc string) (ObjectSaveResult, error)
DefinePoolXML replaces a storage pool's definition. Name and UUID must stay.
func (*Client) DefineXML ¶
func (c *Client) DefineXML(uuid, xmlDoc string) (DefineResult, error)
DefineXML replaces the persistent definition of an existing machine with the given XML, validated by libvirt against its schema. The UUID and the name must stay the same: a different UUID would silently create a second machine, renaming has its own action.
func (*Client) Delete ¶
func (c *Client) Delete(uuid string, removeStorage bool) (DeleteResult, error)
Delete removes a stopped machine: its definition, snapshot and checkpoint metadata, UEFI variables, TPM state and managed-save image. With removeStorage its writable disks are deleted too, unless another machine uses them or they are not in a storage pool.
func (*Client) DeleteBackup ¶
DeleteBackup removes one backup directory.
func (*Client) DeleteDHCPHost ¶
DeleteDHCPHost removes the reservation for mac.
func (*Client) DeleteMDev ¶
DeleteMDev stops and removes a slice no machine uses.
func (*Client) DeleteNetwork ¶
DeleteNetwork stops and removes a network no machine is connected to.
func (*Client) DeletePool ¶
DeletePool forgets a stopped pool. The directory and its files stay on disk.
func (*Client) DeleteSnapshot ¶
DeleteSnapshot removes one snapshot; its children are re-attached to its parent.
func (*Client) DeleteStorageVol ¶ added in v0.9.0
func (c *Client) DeleteStorageVol(vol libvirt.StorageVol) error
DeleteStorageVol removes a storage volume from libvirt.
func (*Client) DeleteVolume ¶
DeleteVolume removes a volume that no machine uses.
func (*Client) Deploy ¶
func (c *Client) Deploy(ctx context.Context, template string, spec DeploySpec, report func(string)) (string, error)
Deploy creates a machine from a template and returns its UUID. Long copies report progress.
func (*Client) DetachDevice ¶
func (c *Client) DetachDevice(uuid string, ref DeviceRef) (DeviceResult, error)
DetachDevice removes a device. A disk image itself is kept.
func (*Client) DialSPICE ¶ added in v0.6.0
DialSPICE connects to the SPICE server of a running machine.
func (*Client) DialVNC ¶
DialVNC connects to the VNC server of a running machine (the caller proxies the bytes).
func (*Client) DialVNCHead ¶ added in v0.5.0
DialVNCHead connects to monitor head (0 = the first, served by libvirt).
func (*Client) DiskBytes ¶ added in v0.6.0
DiskBytes returns, for each machine, the full (virtual) size of its own disks: the writable, unshared ones a backup copies too. A thin disk counts with the size it can grow to, which is what a disk quota has to plan for (ADR-0044). Machines that do not exist are left out.
func (*Client) DiskUsers ¶ added in v1.2.0
DiskUsers maps every disk image path to the machines that use it (also as a backing image).
func (*Client) DomainAction ¶
DomainAction runs a lifecycle action on the domain with the given UUID.
func (*Client) DomainActive ¶ added in v1.1.0
DomainActive reports whether a machine is running (configuration history keeps live versions only of running machines).
func (*Client) DomainDetail ¶
func (c *Client) DomainDetail(uuid string) (DomainDetail, error)
DomainDetail returns the machine page model: summary, parsed XML, disk sizes and, for running machines, the guest IP addresses libvirt knows about.
func (*Client) DomainStats ¶
func (c *Client) DomainStats() ([]DomainStats, error)
DomainStats returns bulk counters for all running domains in one RPC. Domains busy with a job (e.g. migration) are skipped instead of blocking the sampler.
func (*Client) DomainUUIDs ¶
DomainUUIDs lists every machine's UUID (config history sweeps).
func (*Client) DomainXML ¶
DomainXML returns the domain definition. inactive selects the persistent config the domain gets on its next boot instead of the live one. Secrets (e.g. VNC passwords) are never included.
func (*Client) FlatCopy ¶ added in v1.0.0
func (c *Client) FlatCopy(ctx context.Context, dir BackupDir, id string, report func(string)) (string, func(), error)
FlatCopy makes an incremental backup stand alone for an off-site copy: its chain is merged into <dir>/.virtomir-flat/<id>. It returns the directory to read the backup from (dir itself for a full backup) and a cleanup to call afterwards.
func (*Client) GetSettings ¶
func (c *Client) GetSettings(uuid string) (SettingsView, error)
GetSettings reads the form from the persistent definition.
func (*Client) GuestExec ¶ added in v1.0.0
func (c *Client) GuestExec(ctx context.Context, uuid string, argv []string) (GuestExecResult, error)
GuestExec runs argv inside a running machine through its guest agent and waits for it to end, at most until ctx is done (the command keeps running inside the guest then).
func (*Client) GuestInfo ¶ added in v1.0.0
GuestInfo asks the guest agent of a running machine; Connected is false without one.
func (*Client) HostHardware ¶
func (c *Client) HostHardware() (HostHardware, error)
HostHardware lists PCI and USB devices with what uses them and whether they can be passed through, and why not.
func (*Client) ImportOVA ¶
func (c *Client) ImportOVA(ctx context.Context, pool, name string, r io.Reader, report func(string)) (CreateResult, error)
ImportOVA reads an OVA (a tar of an OVF descriptor and disk images) from r, converts its disks to qcow2 in a directory pool and creates the machine (not started). name overrides the name from the OVF.
func (*Client) LabelDirPools ¶ added in v1.2.1
func (c *Client) LabelDirPools()
LabelDirPools labels the folders of this host's directory pools (see LabelForVMs).
func (*Client) LifecycleEvents ¶
LifecycleEvents streams domain lifecycle changes (started, stopped, defined, …) until ctx is cancelled or the libvirt connection drops; then the channel is closed. Only the fact that something changed matters to callers, so the payload is the domain name.
func (*Client) ListBackups ¶
ListBackups scans the backup directory and the earlier backup locations (see backup_dirs.go); uuid "" lists all machines. Newest first.
func (*Client) ListDomains ¶
func (*Client) ListNetworks ¶
func (*Client) ListVolumes ¶
ListVolumes lists a pool's volumes with the machines that use each of them.
func (*Client) MigrateBegin ¶
func (c *Client) MigrateBegin(uuid string, flags libvirt.DomainMigrateFlags, disks []string) ([]byte, string, error)
MigrateBegin is phase 1 (source): the domain XML and cookie for the target.
func (*Client) MigrateConfirm ¶
func (c *Client) MigrateConfirm(uuid string, cookie []byte, flags libvirt.DomainMigrateFlags, disks []string, cancelled bool) error
MigrateConfirm is phase 5 (source): ends the job; on success the source is undefined, cancelled resumes it here.
func (*Client) MigrateFinish ¶
func (c *Client) MigrateFinish(name, uri string, cookie []byte, flags libvirt.DomainMigrateFlags, disks []string, cancelled bool) ([]byte, error)
MigrateFinish is phase 4 (target): resumes the machine here (or, cancelled, cleans up).
func (*Client) MigratePerform ¶
func (c *Client) MigratePerform(ctx context.Context, uuid, uri string, cookie []byte, flags libvirt.DomainMigrateFlags, disks []string, progress func(string)) ([]byte, error)
MigratePerform is phase 3 (source): sends memory (and copied disks) and blocks until done. progress gets the share transferred so far.
func (*Client) MigratePrepare ¶
func (c *Client) MigratePrepare(name, xml, uri string, cookie []byte, flags libvirt.DomainMigrateFlags, disks []string) ([]byte, string, error)
MigratePrepare is phase 2 (target): QEMU starts listening at uri. Returns the cookie and the URI the source must send to.
func (*Client) MoveDisk ¶ added in v1.0.0
func (c *Client) MoveDisk(ctx context.Context, uuid, target, pool string, report func(string)) error
MoveDisk moves one disk of a machine into another storage pool on the same host, as a standalone qcow2 (a linked clone's template stays where it is). A running machine keeps running: libvirt copies the disk while the guest writes to it (block copy) and switches over once both are in sync. A stopped machine's disk is copied with qemu-img. The old image is deleted afterwards if it is a pool volume no other machine uses.
func (*Client) NameTaken ¶ added in v0.9.0
NameTaken reports whether a machine or container named name exists.
func (*Client) NetworkAction ¶
func (*Client) NetworkXML ¶ added in v0.5.0
NetworkXML returns a network's persistent (inactive) definition.
func (*Client) Placements ¶ added in v0.5.0
Placements lists the running machines' vCPU placement. A machine that stops between listing and asking is left out.
func (*Client) PlanMigration ¶
func (c *Client) PlanMigration(uuid string) (MigrationSource, error)
PlanMigration checks that a machine can be live-migrated and describes its disks.
func (*Client) PlanMove ¶
PlanMove checks that a machine can be moved and lists what has to be copied.
func (*Client) PoolAction ¶
PoolAction starts, stops or refreshes (rescans) a pool.
func (*Client) PreviewSettings ¶
PreviewSettings returns what saving the settings would change, without saving.
func (*Client) PruneBackups ¶
func (c *Client) PruneBackups(dir BackupDir, uuid string, keep func([]time.Time) []bool) (int, error)
PruneBackups deletes the automatic backups of a machine that keep (given their creation times, newest first) does not keep. Manual backups are never touched, and neither is a backup that a kept incremental backup builds on.
func (*Client) RemoveFirewall ¶
RemoveFirewall deletes a machine's filter after the machine itself was deleted.
func (*Client) RemoveImage ¶
RemoveImage deletes a disk image that was copied to another host by a live migration (libvirt only undefines the source). Only images no machine here uses are removed.
func (*Client) ResizeDisk ¶
ResizeDisk grows a machine's disk. Running machines see the new size at once (block resize); the guest still has to grow its partition and file system. Disks never shrink: that destroys data.
func (*Client) ResizeVolume ¶
ResizeVolume grows a volume that no machine uses (resize attached disks from the machine).
func (*Client) RestoreBackup ¶
func (c *Client) RestoreBackup(ctx context.Context, dir BackupDir, id, name, pool string, force bool, report func(string)) (string, error)
RestoreBackup creates a new machine from a backup: disks are copied into pool, the definition gets the new name, a new UUID and new MAC addresses. The original machine (if it still exists) is never touched. A backup whose files no longer match their recorded checksums, or whose last check failed, is only restored with force.
func (*Client) RestoreXML ¶ added in v1.2.0
func (c *Client) RestoreXML(uuid, xmlDoc string) (DefineResult, error)
RestoreXML makes an earlier definition of a machine (a version of its configuration history) its definition again. Unlike DefineXML, which takes what a person typed, it takes what the machine once was:
- the machine keeps the name it has now. It may have been renamed since that version was saved, and a definition with the old name would be refused, leaving every version from before a rename impossible to go back to;
- disks of that version which are no longer on the host are reported: the definition is restored as it was, but the machine does not start until they are back or taken out.
func (*Client) RevertSnapshot ¶
func (c *Client) RevertSnapshot(uuid, name string, safety bool) (RevertResult, error)
RevertSnapshot returns the machine to the snapshot. With safety, the current state is kept first as a snapshot named before-revert-<time>, so the revert can be undone; when that is not possible the result says why and the revert goes on. A machine whose disks other machines build on (linked clones) is never reverted: that would break them.
func (*Client) SaveSettings ¶
func (c *Client) SaveSettings(uuid string, s Settings) (SaveResult, error)
func (*Client) SerialConsole ¶
func (c *Client) SerialConsole(ctx context.Context, uuid, device string, in io.Reader, out io.Writer) error
SerialConsole attaches to a text console until ctx ends or the stream closes. Input from in goes to the guest, guest output is written to out. An existing console session (e.g. virsh console) is taken over, so a reconnecting browser never finds the console "busy".
func (*Client) SetAutostart ¶
SetAutostart makes the machine start (or not) when the host boots.
func (*Client) SetDiskQoS ¶ added in v0.7.1
func (c *Client) SetDiskQoS(uuid, target string, qos DiskIoTune) error
SetDiskQoS updates the I/O limits of a VM disk (QEMU iotune) both live and in the configuration.
func (*Client) SetDisplay ¶ added in v0.6.0
SetDisplay switches a machine's console between VNC and SPICE, from its next start.
func (*Client) SetFirewall ¶
func (c *Client) SetFirewall(uuid string, fw Firewall) (FirewallResult, error)
SetFirewall writes the filter and points the machine's adapters at it (or, disabled, removes the references and the filter). A running machine gets the change right away.
func (*Client) SetGPUPool ¶ added in v1.0.0
SetGPUPool records the GPUs a machine got from a GPU pool ("" and 0 clear it).
func (*Client) SetGuestPassword ¶ added in v1.0.0
SetGuestPassword sets a user's password inside a running machine through its agent.
func (*Client) SetInterfaceBandwidth ¶ added in v1.0.0
func (c *Client) SetInterfaceBandwidth(uuid, mac string, bw NICBandwidth) error
SetInterfaceBandwidth limits an adapter's average traffic, live and in the definition; 0 removes a limit.
func (*Client) SetNetworkAutostart ¶
func (*Client) SetProject ¶ added in v0.9.0
SetProject puts a machine into a project ("" takes it out again; kept in its <metadata>).
func (*Client) SetQEMUArgs ¶
func (c *Client) SetQEMUArgs(uuid string, q QEMUArgs) (DefineResult, error)
SetQEMUArgs replaces the extra QEMU arguments (empty removes them). Used from the next boot.
func (*Client) SetTemplate ¶
SetTemplate turns a shut-off machine into a template or back. A template never starts: linked clones read its disks, and a single boot would change what they see.
func (*Client) SetVXLANPeers ¶ added in v1.0.0
SetVXLANPeers replaces the peers of VXLAN network name, live and in its definition; the tunnel follows within seconds (keepTunnels).
func (*Client) SparsifyDisk ¶ added in v1.0.0
func (c *Client) SparsifyDisk(ctx context.Context, uuid, target string, report func(string)) (uint64, error)
SparsifyDisk gives the host back the space a stopped machine's disk image holds for blocks its file systems no longer use (virt-sparsify --in-place: free space is trimmed, so it also works for images with snapshots or a backing file). Only for stopped machines: a running guest writing to the image would corrupt it. It answers how many bytes the image shrank by.
func (*Client) SweepPartialBackups ¶ added in v1.1.0
SweepPartialBackups removes backup folders left half-written (by a crash or a restart during a backup) in dir. Only folders in which nothing changed for olderThan go, so a backup that another host writes to a shared location right now is left alone.
func (*Client) UploadBytes ¶ added in v0.9.0
UploadBytes stores raw byte data as a new volume in pool (e.g. a cloud-init seed ISO).
func (*Client) UploadVolume ¶
func (c *Client) UploadVolume(ctx context.Context, pool, name string, size int64, r io.Reader) (Volume, error)
UploadVolume streams size bytes from r into a new volume. QCOW2 images (cloud images) are recognized by their magic bytes and stored as qcow2; everything else (ISOs, raw disks) as raw. A failed or cancelled upload leaves nothing behind.
func (*Client) VXLANTunnels ¶ added in v0.8.0
VXLANTunnels lists the tunnels of the active VXLAN networks.
type CloudInit ¶
type CloudInit struct {
Hostname string `json:"hostname,omitempty"`
User string `json:"user"`
Password string `json:"password,omitempty"`
SSHKeys []string `json:"sshKeys,omitempty"`
Packages []string `json:"packages,omitempty"`
// UserData replaces the generated #cloud-config entirely (power users).
UserData string `json:"userData,omitempty"`
// Network gives the adapter fixed addresses instead of DHCP (IP pools, ADR-0075).
Network *StaticNetwork `json:"network,omitempty"`
}
CloudInit configures a cloud image on first boot (NoCloud datasource): user, password and/or SSH keys, hostname. The QEMU guest agent is always installed so VirtoMir can see the machine's IP addresses.
type ConfigEvent ¶ added in v1.1.0
type ConfigEvent struct {
UUID string
Persistent bool
Live bool
Stopped bool
// What happened to the machine, for its timeline ("" for a change of the definition
// only): started, stopped, paused, resumed, crashed or shutdown, and why (Detail).
Lifecycle string
Detail string
}
ConfigEvent says that a machine's configuration may have changed (configuration history, ADR-0021): its saved definition (Persistent), its running configuration (Live), or it stopped (Stopped: the next running configuration is a fresh start).
type ConsoleInfo ¶
type ConsoleInfo struct {
Running bool `json:"running"`
// VNC is the graphical console, nil when the machine has none (or it is not running).
VNC *VNCInfo `json:"vnc,omitempty"`
// Serial lists the text consoles (alias names); the first is the default.
Serial []string `json:"serial"`
// Heads is how many monitors the graphical console can show (each on its own VNC server).
Heads int `json:"heads"`
// SPICE is the graphical console when the machine uses SPICE instead of VNC (ADR-0046).
SPICE *SpiceInfo `json:"spice,omitempty"`
// Display is the protocol in the definition (vnc, spice, ""), also for a stopped machine.
Display string `json:"display"`
}
ConsoleInfo tells the UI which consoles a machine offers right now.
type ContainerImage ¶ added in v0.8.0
type ContainerImage struct {
Key string `json:"key"`
Label string `json:"label"`
// contains filtered or unexported fields
}
ContainerImage is a system image a container can start from, published by the Linux Containers project (images.linuxcontainers.org).
type CreateResult ¶
type CreateResult struct {
UUID string `json:"uuid"`
StartError string `json:"startError,omitempty"`
}
CreateResult reports the new machine; StartError is set when it was created but did not start.
type CreateSpec ¶
type CreateSpec struct {
Name string `json:"name"`
Kind string `json:"kind,omitempty"` // vm (default) or container (CreateContainer)
OS string `json:"os"` // linux (default), windows, other
VCPUs int `json:"vcpus"`
MemoryMiB uint64 `json:"memoryMiB"`
// Firmware: uefi (default) or bios. Secure Boot and TPM default on for Windows.
Firmware string `json:"firmware"`
SecureBoot bool `json:"secureBoot"`
TPM bool `json:"tpm"`
Confidential string `json:"confidential,omitempty"` // sev, sev-snp, tdx
// Containers: one of ContainerImages and root's password.
Image string `json:"image,omitempty"`
RootPassword string `json:"rootPassword,omitempty"`
// Disk: a new empty volume (Pool + DiskGiB), a copy of a cloud image grown to DiskGiB
// (BaseImage), an existing image used as is (DiskPath), or none.
Pool string `json:"pool"`
DiskGiB uint64 `json:"diskGiB"`
Provisioning string `json:"provisioning,omitempty"` // thin (default) or thick
DiskPath string `json:"diskPath,omitempty"`
BaseImage string `json:"baseImage,omitempty"`
// CloudInit configures a cloud image on first boot (seed ISO attached as a CD-ROM).
CloudInit *CloudInit `json:"cloudInit,omitempty"`
// Installation media to boot from (optional).
ISO string `json:"iso,omitempty"`
// DriverISO is a second CD with drivers, e.g. virtio-win for Windows (optional, not booted).
DriverISO string `json:"driverIso,omitempty"`
Network *NICSpec `json:"network,omitempty"` // nil: no network adapter
Start bool `json:"start"`
}
CreateSpec is what the new-machine wizard collects. Everything else gets a sensible, modern default (q35, VirtIO where the guest supports it, UEFI), and can be changed later.
type DHCPHost ¶
type DHCPHost struct {
MAC string `json:"mac"`
IP string `json:"ip"`
Name string `json:"name,omitempty"`
}
DHCPHost is a fixed address reservation: the machine with MAC always gets IP.
type DRHost ¶ added in v1.0.0
type DRHost struct{ C *Client }
DRHost is the libvirt side of disaster recovery on this host (internal/dr's VirtController): it defines the recovered machines, powers them and removes them again. Disks are never touched here; the replicas and their clones belong to ZFS.
func (DRHost) DefineDomain ¶ added in v1.0.0
DefineDomain defines a new machine from xmlDoc and returns its UUID.
func (DRHost) DomainState ¶ added in v1.0.0
DomainState is the machine's state as VirtoMir names it ("running", "shutoff", …).
func (DRHost) GetDomainXML ¶ added in v1.0.0
GetDomainXML returns the persistent definition of a machine.
func (DRHost) StartDomain ¶ added in v1.0.0
StartDomain starts a machine.
func (DRHost) StopDomain ¶ added in v1.0.0
StopDomain shuts a machine down, or pulls the plug with force.
func (DRHost) UndefineDomain ¶ added in v1.0.0
UndefineDomain removes a machine's definition (with its UEFI variables), keeping its disks.
type DefineResult ¶
type DefineResult struct {
// The machine is running: the new definition is used from its next boot on.
AppliesOnNextBoot bool `json:"appliesOnNextBoot"`
// Disks of a restored version (RestoreXML) that are not on the host any more.
MissingDisks []string `json:"missingDisks,omitempty"`
}
DefineResult tells the UI how a saved definition takes effect.
type DeleteResult ¶
type DeleteResult struct {
RemovedVolumes []string `json:"removedVolumes"`
KeptVolumes []KeptVolume `json:"keptVolumes"`
}
DeleteResult reports what happened to the machine's disks.
type DeploySpec ¶
type DeploySpec struct {
Name string `json:"name"`
// Linked clones get thin overlays on the template's disks: instant, small, but tied to
// the template. Otherwise every disk is copied in full.
Linked bool `json:"linked"`
CloudInit *CloudInit `json:"cloudInit,omitempty"`
Start bool `json:"start"`
VCPUs int `json:"vcpus,omitempty"`
MemoryMiB uint64 `json:"memoryMiB,omitempty"`
}
DeploySpec is a new machine made from a template.
type Device ¶
type Device struct {
Kind string `json:"kind"` // disk, cdrom, floppy, interface, graphics, video, serial, …
Group DeviceGroup `json:"group"`
Title string `json:"title"`
Summary string `json:"summary,omitempty"`
Boot uint `json:"bootOrder,omitempty"`
Props []Prop `json:"props"`
// Filled from libvirt at request time where available.
CapacityBytes uint64 `json:"capacityBytes,omitempty"`
AllocationBytes uint64 `json:"allocationBytes,omitempty"`
Addresses []string `json:"addresses,omitempty"`
// Identify the device for actions: a disk's guest device name, an adapter's MAC.
Target string `json:"target,omitempty"`
Serial string `json:"serial,omitempty"` // a disk's serial number, if set
MAC string `json:"mac,omitempty"`
IoTune *DiskIoTune `json:"iotune,omitempty"`
// Bandwidth: an adapter's traffic limits, if any.
Bandwidth *NICBandwidth `json:"bandwidth,omitempty"`
}
Device is one entry of <devices>, flattened for display. Props carry the friendly label plus the libvirt XML name, so power users can map every value back to the XML.
type DeviceGroup ¶
type DeviceGroup string
DeviceGroup orders devices on the machine page. Groups after "display" are "advanced": shown on request, never hidden from the XML.
const ( GroupStorage DeviceGroup = "storage" GroupNetwork DeviceGroup = "network" GroupDisplay DeviceGroup = "display" GroupConsole DeviceGroup = "console" GroupPassthrough DeviceGroup = "passthrough" GroupInput DeviceGroup = "input" GroupSystem DeviceGroup = "system" GroupController DeviceGroup = "controller" )
type DeviceRef ¶
type DeviceRef struct {
Kind string `json:"kind"`
Target string `json:"target,omitempty"`
MAC string `json:"mac,omitempty"`
}
DeviceRef identifies a device to remove: a disk by its guest device name, an adapter by MAC, a host device by address (PCI), vendor:product (USB) or UUID (mdev), a shared folder by its mount tag. watchdog, tpm, rng and clipboard need no target (a machine has one).
type DeviceResult ¶
type DeviceResult struct {
// AppliesOnNextBoot: only the saved definition changed (the machine runs and QEMU cannot
// change this device live, or it failed: LiveError).
AppliesOnNextBoot bool `json:"appliesOnNextBoot"`
LiveError string `json:"liveError,omitempty"`
}
DeviceResult tells the UI whether a running machine already has the change.
type DeviceSpec ¶
type DeviceSpec struct {
// Kind: watchdog, tpm, rng, filesystem, mdev, clipboard, video.
Kind string `json:"kind"`
// watchdog: model i6300esb (default) or itco; action reset (default), poweroff, shutdown,
// pause, dump, inject-nmi, none. tpm: tpm-crb (default) or tpm-tis. video: see Heads.
Model string `json:"model,omitempty"`
Action string `json:"action,omitempty"`
// filesystem: a host directory shared with the guest as a virtiofs mount tag.
Source string `json:"source,omitempty"`
Tag string `json:"tag,omitempty"`
ReadOnly bool `json:"readOnly,omitempty"`
// mdev: the UUID of a mediated device created on the host (see Host hardware).
UUID string `json:"uuid,omitempty"`
// video: model virtio (default), qxl, vga, bochs, ramfb, cirrus; heads = monitors (1–4).
Heads uint `json:"heads,omitempty"`
}
DeviceSpec describes one device to add (Kind picks the fields that matter).
type DiskCounters ¶
type DiskIoTune ¶ added in v0.7.1
type DiskIoTune struct {
TotalBytesSec uint64 `json:"totalBytesSec,omitempty"`
ReadBytesSec uint64 `json:"readBytesSec,omitempty"`
WriteBytesSec uint64 `json:"writeBytesSec,omitempty"`
TotalIopsSec uint64 `json:"totalIopsSec,omitempty"`
ReadIopsSec uint64 `json:"readIopsSec,omitempty"`
WriteIopsSec uint64 `json:"writeIopsSec,omitempty"`
TotalIopsSecMax uint64 `json:"totalIopsSecMax,omitempty"`
TotalBytesSecMax uint64 `json:"totalBytesSecMax,omitempty"`
}
DiskIoTune holds I/O QoS throughput and IOPS limits (QEMU iotune).
type DiskSpec ¶
type DiskSpec struct {
Device string `json:"device"` // disk (default) or cdrom
Bus string `json:"bus"` // virtio (default for disks), sata, scsi, usb
Path string `json:"path,omitempty"`
Pool string `json:"pool,omitempty"`
Volume string `json:"volume,omitempty"`
SizeGiB uint64 `json:"sizeGiB,omitempty"`
Format string `json:"format,omitempty"` // qcow2 (default) or raw, for new volumes
IoTune *DiskIoTune `json:"iotune,omitempty"`
// Serial is what the guest sees as the disk's serial number: Linux names it
// /dev/disk/by-id/virtio-<serial> (the Kubernetes CSI driver finds its volumes so).
Serial string `json:"serial,omitempty"`
}
DiskSpec describes a disk to add. Either Path (an existing image, e.g. an ISO for a CD-ROM), Pool+Volume (an existing volume) or Pool+SizeGiB (a new volume) is set.
type Domain ¶
type Domain struct {
UUID string `json:"uuid"`
Name string `json:"name"`
ID int `json:"id,omitempty"` // only set while running
State DomainState `json:"state"`
VCPUs int `json:"vcpus"`
MemoryKiB uint64 `json:"memoryKiB"`
MaxMemoryKiB uint64 `json:"maxMemoryKiB"`
CPUTimeNs uint64 `json:"cpuTimeNs"`
Persistent bool `json:"persistent"`
Autostart bool `json:"autostart"`
// Template machines never start; they are the source of new machines.
Template bool `json:"template,omitempty"`
// LinkedFrom is the template whose disks this machine's disks are overlays on.
LinkedFrom string `json:"linkedFrom,omitempty"`
// Owner created the machine through VirtoMir; it counts against their quota.
Owner string `json:"owner,omitempty"`
// Project is the multi-tenancy project the machine belongs to (ADR-0060); empty = global.
Project string `json:"project,omitempty"`
// Kind: "vm" (default) or "container" (LXC).
Kind string `json:"kind,omitempty"`
// GPUPool and GPUCount: the GPUs it got from a GPU pool (ADR-0071).
GPUPool string `json:"gpuPool,omitempty"`
GPUCount int `json:"gpuCount,omitempty"`
}
Domain is a summary of one VM, suitable for list views.
type DomainDetail ¶
type DomainDetail struct {
Domain
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
System SystemInfo `json:"system"`
CPU CPUInfo `json:"cpu"`
Memory MemoryInfo `json:"memory"`
Devices []Device `json:"devices"`
}
DomainDetail is everything the machine page shows: the list summary plus a readable view of the domain XML. The XML itself stays the source of truth (see Client.DomainXML).
type DomainState ¶
type DomainState string
DomainState is libvirt's virDomainState as a stable, human-readable string.
const ( StateUnknown DomainState = "unknown" StateRunning DomainState = "running" StateBlocked DomainState = "blocked" StatePaused DomainState = "paused" StateShuttingDown DomainState = "shutting-down" StateShutoff DomainState = "shutoff" StateCrashed DomainState = "crashed" StateSuspended DomainState = "pm-suspended" )
type DomainStats ¶
type DomainStats struct {
UUID string
CPUTimeNs uint64
VCPUTimeNs []uint64 // index = vCPU number; only online vCPUs have a value
Balloon BalloonStats
Disks []DiskCounters
Nets []NetCounters
}
DomainStats are the cumulative counters of one running domain from libvirt's bulk stats (virConnectGetAllDomainStats). Rates are derived from two samples by internal/live.
type Firewall ¶
type Firewall struct {
Enabled bool `json:"enabled"`
// DefaultIn/DefaultOut apply to IPv4 and IPv6 traffic no rule matched: accept or drop.
DefaultIn string `json:"defaultIn"`
DefaultOut string `json:"defaultOut"`
// AntiSpoof adds libvirt's clean-traffic filter: the machine may only send with its own
// MAC and IP address (no spoofing, no rogue DHCP server).
AntiSpoof bool `json:"antiSpoof"`
Rules []FirewallRule `json:"rules"`
// Read only: adapters the filter applies to, and those it cannot (macvtap, hostdev).
Adapters []string `json:"adapters,omitempty"`
Unsupported []string `json:"unsupported,omitempty"`
}
Firewall is a machine's whole firewall.
type FirewallResult ¶
type FirewallResult struct {
LiveError string `json:"liveError,omitempty"`
}
FirewallResult tells whether a change reached the running machine.
type FirewallRule ¶
type FirewallRule struct {
Direction string `json:"direction"` // in, out
Action string `json:"action"` // accept, drop, reject
Protocol string `json:"protocol"` // all, tcp, udp, icmp
// Remote is the other end: an IPv4 or IPv6 address or network ("" anyone, both families).
Remote string `json:"remote,omitempty"`
// Ports on the machine for "in", on the remote side for "out": "22" or "8000-8100".
Ports string `json:"ports,omitempty"`
Comment string `json:"comment,omitempty"`
}
FirewallRule is one rule, in the guest's view: "in" is traffic to the machine.
type GuestExecResult ¶ added in v1.0.0
type GuestExecResult struct {
ExitCode int `json:"exitCode"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
}
GuestExecResult is what a command run inside a machine by its guest agent left behind.
type GuestFilesystem ¶ added in v1.0.0
type GuestInfo ¶ added in v1.0.0
type GuestInfo struct {
// Connected: an agent answers. Everything else is empty when it does not.
Connected bool `json:"connected"`
OS string `json:"os,omitempty"` // pretty name, e.g. "Debian GNU/Linux 13 (trixie)"
Kernel string `json:"kernel,omitempty"`
Hostname string `json:"hostname,omitempty"`
Timezone string `json:"timezone,omitempty"`
Users []string `json:"users"`
Filesystems []GuestFilesystem `json:"filesystems"`
}
GuestInfo is what the guest agent inside a running machine reports about it.
type HostCPU ¶
type HostCPU struct {
XML string `json:"xml"`
Model string `json:"model"`
Vendor string `json:"vendor"`
Features []string `json:"features"`
}
HostCPU is this host's CPU as libvirt describes it (<cpu> from the capabilities), the input for finding a model every cluster member can run.
type HostHardware ¶
type HostHardware struct {
// IOMMU: the kernel isolates devices (needed for PCI passthrough).
IOMMU bool `json:"iommu"`
PCI []HostPCI `json:"pci"`
USB []HostUSB `json:"usb"`
// MDevs: mediated devices (vGPU slices) created on the host's cards (see mdev.go).
MDevs []HostMDev `json:"mdevs"`
}
HostHardware is what the host could pass through to machines.
type HostInfo ¶
type HostInfo struct {
Hostname string `json:"hostname"`
Hypervisor string `json:"hypervisor"`
HypervisorVersion string `json:"hypervisorVersion"`
LibvirtVersion string `json:"libvirtVersion"`
CPUModel string `json:"cpuModel"`
CPUs int `json:"cpus"`
CPUMHz int `json:"cpuMHz"`
NUMANodes int `json:"numaNodes"`
Sockets int `json:"sockets"`
CoresPerSocket int `json:"coresPerSocket"`
ThreadsPerCore int `json:"threadsPerCore"`
MemoryKiB uint64 `json:"memoryKiB"`
}
HostInfo describes the hypervisor host.
type HostMDev ¶
type HostMDev struct {
Name string `json:"name"` // libvirt node device name
UUID string `json:"uuid"`
Parent string `json:"parent"` // PCI address of the card
Type string `json:"type"`
TypeName string `json:"typeName,omitempty"`
Active bool `json:"active"`
Autostart bool `json:"autostart"`
UsedBy []string `json:"usedBy"`
}
HostMDev is a slice that exists on the host.
type HostMDevType ¶
type HostMDevType struct {
ID string `json:"id"` // nvidia-63, i915-GVTg_V5_4, …
Name string `json:"name"` // GRID P4-2Q, …
API string `json:"api"` // vfio-pci
Available uint `json:"available"`
}
HostMDevType is one kind of slice a card offers.
type HostPCI ¶
type HostPCI struct {
Name string `json:"name"` // libvirt node device name
Address string `json:"address"` // 0000:00:1f.2
Class string `json:"class"` // 0x010601
ClassName string `json:"className"`
Vendor string `json:"vendor"`
Product string `json:"product"`
VendorID string `json:"vendorId"`
ProductID string `json:"productId"`
Driver string `json:"driver,omitempty"`
IOMMUGroup *int `json:"iommuGroup,omitempty"`
Group []string `json:"group,omitempty"` // addresses in the same IOMMU group
UsedBy []string `json:"usedBy"` // machines that have it
// HostUse says why the host needs it (mounted disks, an interface with an address).
HostUse string `json:"hostUse,omitempty"`
// Blocked explains why it cannot be passed through ("" = it can).
Blocked string `json:"blocked,omitempty"`
// MDevTypes: the slices this card can be split into (NVIDIA vGPU, Intel GVT-g, …).
MDevTypes []HostMDevType `json:"mdevTypes,omitempty"`
// SRIOV is true if the device is an SR-IOV Physical Function.
SRIOV bool `json:"sriov,omitempty"`
SRIOVTotalVFs int `json:"sriovTotalVfs,omitempty"`
SRIOVCurrentVFs int `json:"sriovCurrentVfs,omitempty"`
// IsVF is true if the device is an SR-IOV Virtual Function.
IsVF bool `json:"isVf,omitempty"`
PFAddress string `json:"pfAddress,omitempty"`
}
type HostStats ¶
type HostStats struct {
// Cumulative CPU time over all host CPUs, in nanoseconds.
CPUBusyNs, CPUTotalNs uint64
// Memory in KiB. Used excludes page cache and buffers (like `free`).
MemTotalKiB, MemUsedKiB uint64
}
HostStats is a point-in-time sample of host resource counters.
type HostUSB ¶
type HostUSB struct {
Name string `json:"name"`
Bus int `json:"bus"`
Device int `json:"device"`
VendorID string `json:"vendorId"`
ProductID string `json:"productId"`
Vendor string `json:"vendor"`
Product string `json:"product"`
UsedBy []string `json:"usedBy"`
Blocked string `json:"blocked,omitempty"`
}
type HostdevSpec ¶
type HostdevSpec struct {
Type string `json:"type"` // pci or usb
Address string `json:"address,omitempty"` // pci: 0000:01:00.0
VendorID string `json:"vendorId,omitempty"` // usb
ProductID string `json:"productId,omitempty"` // usb
}
HostdevSpec names a host device to give a machine.
type InvalidError ¶
type InvalidError struct{ Message string }
InvalidError means the request itself is wrong: malformed XML, a bad name, a size of 0. The message tells the user what to fix.
func (*InvalidError) Error ¶
func (e *InvalidError) Error() string
type KeptVolume ¶
type Lease ¶
type Lease struct {
MAC string `json:"mac"`
IP string `json:"ip"` // with prefix
Hostname string `json:"hostname,omitempty"`
Expires int64 `json:"expires"` // unix seconds
Machine string `json:"machine,omitempty"`
}
Lease is one DHCP lease handed out by a libvirt network.
type LiveDisk ¶
type LiveDisk struct {
Target string `json:"target"`
Path string `json:"path"`
CDROM bool `json:"cdrom"` // read-only media: must exist on the target too
Network bool `json:"network"` // on network storage (NFS) here
Writable bool `json:"writable"` // the machine's own disk
}
LiveDisk is a disk of a running machine as the migration sees it.
type MemoryInfo ¶
type MemoryInfo struct {
MaxKiB uint64 `json:"maxKiB"` // <memory>
CurrentKiB uint64 `json:"currentKiB"` // <currentMemory>, i.e. the balloon target
HotplugKiB uint64 `json:"hotplugKiB,omitempty"`
Hugepages bool `json:"hugepages"`
Balloon string `json:"balloon,omitempty"` // memballoon model, "" when none
}
type MigrationSource ¶
type MigrationSource struct {
UUID string `json:"uuid"`
Name string `json:"name"`
Disks []LiveDisk `json:"disks"`
// Networks the interfaces use; they must exist on the target.
Networks []string `json:"networks"`
// CPUMode of the machine: host-passthrough needs an identical CPU on the target.
CPUMode string `json:"cpuMode"`
// MemoryKiB is the machine's memory; the target must have that much available.
MemoryKiB uint64 `json:"memoryKiB"`
}
MigrationSource describes a running machine about to be migrated.
type MovePlan ¶
type MovePlan struct {
UUID string `json:"uuid"`
Name string `json:"name"`
XML string `json:"-"`
Disks []MoveDisk `json:"disks"`
Networks []string `json:"networks"` // libvirt networks the interfaces use
Bridges []string `json:"bridges"` // host bridges the interfaces use (not checked)
// Notes are things that do not travel (UEFI variables, TPM state, inserted media).
Notes []string `json:"notes"`
}
MovePlan is what moving a stopped machine to another host takes: its definition and the disk images to copy (ADR-0020, cold move). Building it checks everything that would make the move fail halfway.
type NICBandwidth ¶ added in v1.0.0
NICBandwidth limits an adapter's average traffic in Mbit/s (0 = no limit). In is traffic into the machine, Out traffic it sends (libvirt <bandwidth> inbound/outbound).
type NICSpec ¶
type NICSpec struct {
Network string `json:"network,omitempty"`
Bridge string `json:"bridge,omitempty"`
Model string `json:"model,omitempty"` // virtio (default), e1000e, rtl8139
MAC string `json:"mac,omitempty"` // generated when empty
// VLAN tags this adapter's traffic (Open vSwitch networks, macvtap passthrough, SR-IOV);
// 0 = as the network says.
VLAN uint `json:"vlan,omitempty"`
// OVN (SDN, ADR-0072): the adapter plugs into the integration bridge (Bridge, default
// br-int) as the logical switch port IfaceID of subnet OVNSubnet. The API allocates the
// port; the MAC must be the port's.
OVNSubnet string `json:"ovnSubnet,omitempty"`
IfaceID string `json:"ifaceId,omitempty"`
SecurityGroups []string `json:"securityGroups,omitempty"`
IPAddress string `json:"ipAddress,omitempty"`
}
NICSpec describes a network adapter to add: connected to a libvirt network or a host bridge.
type NetCounters ¶
type NetworkSpec ¶
type NetworkSpec struct {
Name string `json:"name"`
Mode string `json:"mode"`
Subnet string `json:"subnet,omitempty"` // e.g. 192.168.100.0/24
DHCP bool `json:"dhcp"`
DHCPStart string `json:"dhcpStart,omitempty"`
DHCPEnd string `json:"dhcpEnd,omitempty"`
Bridge string `json:"bridge,omitempty"` // host bridge, bridge mode only
// OVS: the host bridge is an Open vSwitch bridge (bridge mode). VLAN tags every
// machine on this network (bridge mode with OVS); 0 = untagged.
OVS bool `json:"ovs,omitempty"`
VLAN uint `json:"vlan,omitempty"`
// Subnet6 adds IPv6 (nat / route / isolated), a /64 such as fd12:3456:789a::/64; the
// host takes ::1 and sends router advertisements, so guests configure themselves
// (SLAAC). DHCP6 also hands out addresses ::100 – ::ffff. Either Subnet or Subnet6 (or
// both) is needed. In nat mode IPv6 is translated too (NAT66, libvirt ≥ 6.5).
Subnet6 string `json:"subnet6,omitempty"`
DHCP6 bool `json:"dhcp6,omitempty"`
DHCP6Start string `json:"dhcp6Start,omitempty"`
DHCP6End string `json:"dhcp6End,omitempty"`
// VXLAN: the VNI (1 – 16777215, the same on every host) and the other hosts' IP
// addresses. With a subnet this host is the overlay's gateway (NAT, DHCP); without one
// the network is plain layer 2 here, served by the gateway elsewhere.
VNI uint `json:"vni,omitempty"`
Peers []string `json:"peers,omitempty"`
// Cluster marks an overlay over the whole cluster: members that join later get it too,
// and every member's peer list follows the member list.
Cluster bool `json:"cluster,omitempty"`
// PF (hostdev mode, SR-IOV): machines on the network get a free virtual function of this
// NIC, passed through (ADR-0075). VLAN tags their traffic. Experimental: not tested on
// hardware.
PF string `json:"pf,omitempty"`
}
NetworkSpec describes a new network.
- nat / route / isolated: a new bridge with its own subnet (DHCP optional)
- bridge: machines join an existing host bridge (e.g. br0) and the physical LAN
type OVF ¶
type OVF struct {
Name string
VCPUs int
MemoryMiB uint64
UEFI bool
Windows bool
Disks []string // file names inside the OVA, boot disk first
}
OVF is the part of an OVF descriptor VirtoMir uses to rebuild a machine: its name, processors, memory, firmware, guest OS and disks (in order).
type ObjectSaveResult ¶ added in v0.5.0
type ObjectSaveResult struct {
// RestartNeeded: the object is running and only uses the new definition after a restart.
RestartNeeded bool `json:"restartNeeded"`
}
ObjectSaveResult reports how a saved definition takes effect.
type OperationError ¶
type OperationError struct{ Message string }
OperationError is libvirt (or VirtoMir) refusing an operation on a reachable host, e.g. starting a domain that is already running. The message is meant for the user.
func (*OperationError) Error ¶
func (e *OperationError) Error() string
type PathCheck ¶
type PathCheck struct {
Path string `json:"path"`
Exists bool `json:"exists"`
Network bool `json:"network"` // exists on network storage (NFS) here
// Pool: a storage pool here keeps files in that directory, so libvirt can create the
// disk for a live copy.
Pool string `json:"pool,omitempty"`
}
PathCheck is what the target says about one disk path of an incoming machine.
type Placement ¶ added in v0.5.0
type Placement struct {
UUID string `json:"uuid"`
Name string `json:"name"`
// VCPUs has one entry per vCPU, in order.
VCPUs []VCPUPlacement `json:"vcpus"`
// NUMANodes is the memory node set from the machine's NUMA policy ("" = no policy).
NUMANodes string `json:"numaNodes,omitempty"`
}
Placement is where a running machine's vCPUs sit on the host right now, next to where they are allowed to sit (P5: the topology view overlays this on the host's CPUs).
type Pool ¶
type Pool struct {
Name string `json:"name"`
UUID string `json:"uuid"`
Type string `json:"type"` // dir, logical, netfs, iscsi, …
Path string `json:"path,omitempty"`
Source string `json:"source,omitempty"` // Ceph pool (rbd), volume group (logical), zpool (zfs), host:export (netfs) or target IQN (iscsi)
Active bool `json:"active"`
Autostart bool `json:"autostart"`
CapacityBytes uint64 `json:"capacityBytes"`
AllocationBytes uint64 `json:"allocationBytes"`
AvailableBytes uint64 `json:"availableBytes"`
Volumes int `json:"volumes"`
}
Pool is a libvirt storage pool (usually a directory such as /var/lib/libvirt/images).
type PoolSpec ¶
type PoolSpec struct {
Name string `json:"name"`
Path string `json:"path"` // directory, or where an NFS share is mounted
// Type "dir" (default) or "netfs": an NFS share (Host:Export) mounted at Path. The
// same NFS pool on every host is what live migration without copying disks needs.
Type string `json:"type,omitempty"`
Host string `json:"host,omitempty"`
Export string `json:"export,omitempty"`
// iscsi: Host is the portal, Target the IQN; the LUNs become volumes. ChapUser and
// ChapPassword sign in to a target that asks (the password goes to a libvirt secret).
Target string `json:"target,omitempty"`
ChapUser string `json:"chapUser,omitempty"`
ChapPassword string `json:"chapPassword,omitempty"`
// rbd (Ceph): Monitors (host or host:port), the Ceph pool name, and the cephx user and
// key; the key is kept in a libvirt secret, never in the pool definition.
Monitors []string `json:"monitors,omitempty"`
CephPool string `json:"cephPool,omitempty"`
CephUser string `json:"cephUser,omitempty"`
CephKey string `json:"cephKey,omitempty"`
// logical (LVM): Source is the volume group. With Devices, a new volume group is made
// from those empty disks; without, an existing one is used. zfs: Source is an existing
// zpool (or dataset); VirtoMir never creates a zpool.
Source string `json:"source,omitempty"`
Devices []string `json:"devices,omitempty"`
}
PoolSpec describes a new pool: a directory, NFS share, iSCSI target, Ceph pool, LVM volume group or ZFS pool.
type Preview ¶
Preview is the definition before and after a settings change, both serialized the same way so a line diff shows only real changes (libvirt and libvirtxml quote differently).
type QEMUArgs ¶
QEMUArgs are extra arguments and environment variables for QEMU itself (<qemu:commandline>). libvirt marks such machines "tainted": what they do is outside its control, and they can break in ways nothing else can.
type RevertResult ¶ added in v1.1.0
type RevertResult struct {
SafetySnapshot string `json:"safetySnapshot,omitempty"`
SafetyNote string `json:"safetyNote,omitempty"`
}
RevertResult tells what a revert did besides going back: the safety snapshot it took of the state that was given up, or why it took none.
type SaveResult ¶
type SaveResult struct {
DefineResult
AppliedLive []string `json:"appliedLive"` // e.g. "vCPUs", "memory"
LiveErrors []string `json:"liveErrors"` // live changes that did not work (saved for next boot)
}
SaveResult tells what happened: saved to the definition, and what was applied live.
type Settings ¶
type Settings struct {
Title string `json:"title"`
Description string `json:"description"`
VCPUs uint `json:"vcpus"` // active at boot (<vcpu current=…>)
MaxVCPUs uint `json:"maxVcpus"` // <vcpu>, the hot-plug ceiling
CPUMode string `json:"cpuMode"` // host-passthrough, host-model, maximum, custom
CPUModel string `json:"cpuModel,omitempty"`
Sockets int `json:"sockets"`
Cores int `json:"cores"`
Threads int `json:"threads"`
// Nested: whether the guest may run virtual machines itself: "" (the host's default),
// "on" or "off" (the host CPU's vmx or svm feature).
Nested string `json:"nested"`
MemoryMiB uint64 `json:"memoryMiB"` // <memory>
CurrentMemoryMiB uint64 `json:"currentMemoryMiB"` // <currentMemory>, the balloon target
// Device keys in boot order: "disk:<target>" for disks and drives, "net:<mac>" for adapters.
BootOrder []string `json:"bootOrder"`
BootMenu bool `json:"bootMenu"`
Firmware string `json:"firmware"` // uefi or bios
SecureBoot bool `json:"secureBoot"`
Tuning
}
Settings are the common knobs of a machine as a form. They are read from and written to the persistent XML, so the form and the XML editor always show the same truth.
type SettingsView ¶
type SettingsView struct {
Settings
BootDevices []BootDevice `json:"bootDevices"`
// HotplugMemoryMiB is <maxMemory>, the upper limit for memory, if configured.
HotplugMemoryMiB uint64 `json:"hotplugMemoryMiB,omitempty"`
}
type Snapshot ¶
type Snapshot struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Parent string `json:"parent,omitempty"`
// Machine state when taken: running, paused, shutoff, disk-snapshot, …
State string `json:"state"`
Created int64 `json:"created"` // unix seconds
Current bool `json:"current"`
// Memory: the running state (RAM) was saved too, so reverting resumes where it was.
Memory bool `json:"memory"`
Location string `json:"location"` // internal (inside the qcow2) or external (overlay files)
}
Snapshot is one point in a machine's snapshot tree.
type SnapshotSpec ¶
SnapshotSpec names a new snapshot; an empty name gets a timestamp.
type SpiceInfo ¶ added in v0.6.0
type SpiceInfo struct {
Password string `json:"password,omitempty"`
}
SpiceInfo describes a running machine's SPICE console.
type StaticNetwork ¶ added in v1.0.0
type StaticNetwork struct {
MAC string `json:"mac"`
Addresses []string `json:"addresses"` // 10.20.0.50/24, fd00:20::50/64
Gateway4 string `json:"gateway4,omitempty"`
Gateway6 string `json:"gateway6,omitempty"`
Nameservers []string `json:"nameservers,omitempty"`
Search []string `json:"search,omitempty"`
}
StaticNetwork is one adapter's fixed configuration, written as network-config (version 2, which cloud-init renders for netplan, NetworkManager or ifupdown).
type SystemInfo ¶
type SystemInfo struct {
Hypervisor string `json:"hypervisor"` // libvirt domain type: kvm, qemu (TCG), …
OSType string `json:"osType"` // hvm, xen, linux, …
Arch string `json:"arch"`
Machine string `json:"machine"`
Firmware string `json:"firmware"` // "bios" or "uefi"
SecureBoot bool `json:"secureBoot"`
Loader string `json:"loader,omitempty"`
NVRAM string `json:"nvram,omitempty"`
// Direct kernel boot, if configured.
Kernel string `json:"kernel,omitempty"`
Cmdline string `json:"cmdline,omitempty"`
// Boot devices in order, e.g. "Disk vda", "Network 52:54:00:…".
BootOrder []string `json:"bootOrder"`
BootMenu bool `json:"bootMenu"`
Emulator string `json:"emulator,omitempty"`
Clock string `json:"clock,omitempty"`
Features []string `json:"features"`
LaunchSecurity string `json:"launchSecurity,omitempty"` // sev, sev-snp, tdx, s390-pv
OnPoweroff string `json:"onPoweroff,omitempty"`
OnReboot string `json:"onReboot,omitempty"`
OnCrash string `json:"onCrash,omitempty"`
}
type Tuning ¶
type Tuning struct {
// Pinning has one entry per vCPU (index = vCPU): a host CPU set like "2", "4-5" or
// "0,2"; "" lets the vCPU run anywhere.
Pinning []string `json:"pinning"`
EmulatorPin string `json:"emulatorPin"`
HugePages bool `json:"hugePages"`
// NUMAMode: "" (no policy), strict, preferred, interleave or restrictive; NUMANodes is
// the host node set, e.g. "0" or "0-1".
NUMAMode string `json:"numaMode"`
NUMANodes string `json:"numaNodes"`
// CPUWeight is the machine's share of CPU time against other machines when the host is
// busy (libvirt <shares>; 0 = default). CPULimit caps each vCPU at that percent of one
// host CPU (0 = no cap), even when the host is idle.
CPUWeight uint `json:"cpuWeight"`
CPULimit uint `json:"cpuLimit"`
}
Tuning is the performance part of the settings (P4): which host CPUs each vCPU and QEMU's own threads may run on, huge pages, and which NUMA nodes memory comes from.
type VCPUPlacement ¶ added in v0.5.0
type VCPUPlacement struct {
// CPU is the host CPU the vCPU last ran on (-1 = unknown).
CPU int `json:"cpu"`
// Pinned is the host CPU set it is pinned to ("" = may run anywhere), PinnedCPUs the same
// spelled out.
Pinned string `json:"pinned,omitempty"`
PinnedCPUs []int `json:"pinnedCpus,omitempty"`
}
type VNetwork ¶
type VNetwork struct {
Name string `json:"name"`
UUID string `json:"uuid"`
Active bool `json:"active"`
Autostart bool `json:"autostart"`
Persistent bool `json:"persistent"`
// nat, route, open, isolated (no forward), bridge (host bridge), macvtap modes, hostdev.
Mode string `json:"mode"`
Bridge string `json:"bridge,omitempty"`
Subnet string `json:"subnet,omitempty"` // e.g. 192.168.122.1/24 (gateway/prefix)
DHCPStart string `json:"dhcpStart,omitempty"`
DHCPEnd string `json:"dhcpEnd,omitempty"`
Domain string `json:"domain,omitempty"`
// IPv6 (ADR-0041): gateway/prefix, e.g. fd12:3456:789a::1/64, and the DHCPv6 range if
// any (without one, guests configure themselves from router advertisements).
Subnet6 string `json:"subnet6,omitempty"`
DHCP6Start string `json:"dhcp6Start,omitempty"`
DHCP6End string `json:"dhcp6End,omitempty"`
UsedBy []string `json:"usedBy"`
// Fixed address reservations (static DHCP).
DHCPHosts []DHCPHost `json:"dhcpHosts"`
// VXLAN overlay: its VNI and the other hosts' addresses (ADR-0054).
VNI uint `json:"vni,omitempty"`
Peers []string `json:"peers,omitempty"`
// ClusterWide: a VXLAN overlay over the whole cluster, kept on every member (#37).
ClusterWide bool `json:"clusterWide,omitempty"`
// PF: the SR-IOV NIC whose virtual functions a hostdev network hands out (ADR-0075).
PF string `json:"pf,omitempty"`
}
VNetwork is a libvirt virtual network.
type Volume ¶
type Volume struct {
Name string `json:"name"`
Path string `json:"path"`
Type string `json:"type"` // file, block, dir, network
Format string `json:"format"` // qcow2, raw, iso, …
CapacityBytes uint64 `json:"capacityBytes"`
AllocationBytes uint64 `json:"allocationBytes"`
Backing string `json:"backing,omitempty"`
UsedBy []string `json:"usedBy"`
// Writing: a running operation (restore, upload, download, clone) is writing it now.
Writing bool `json:"writing,omitempty"`
}
Volume is one image in a pool.
type VolumeSpec ¶
type VolumeSpec struct {
Name string `json:"name"`
SizeGiB uint64 `json:"sizeGiB"`
Format string `json:"format"` // qcow2 (default) or raw
Provisioning string `json:"provisioning,omitempty"` // thin (default/sparse) or thick (preallocated)
}
VolumeSpec describes a new empty volume.
Source Files
¶
- actions.go
- backup.go
- backup_dirs.go
- backup_incr.go
- backup_space.go
- backup_verify.go
- client.go
- cloudinit.go
- confidential.go
- configevents.go
- console.go
- container.go
- container_linux.go
- convert.go
- cpucompat.go
- create.go
- detail.go
- devices.go
- dhcp.go
- diskfree_linux.go
- diskmove.go
- diskquota.go
- diskuse.go
- drhost.go
- errors.go
- extradevs.go
- firewall.go
- fs_linux.go
- guest.go
- guestexec.go
- heads.go
- hostdev.go
- hostuse_linux.go
- imagefmt.go
- inflight.go
- lease.go
- lxc.go
- manage.go
- mdev.go
- migrate.go
- move.go
- networks.go
- objxml.go
- ova.go
- perm_linux.go
- placement.go
- qcow2chain.go
- resize.go
- restore.go
- selinux.go
- selinux_linux.go
- settings.go
- shacrypt.go
- snapshots.go
- sparsify.go
- spice.go
- stats.go
- storage.go
- template.go
- tuning.go
- vxlan.go
- watchdog.go