Documentation ¶
Index ¶
- Constants
- func MakeLinkName(machine MachineName, conn Connection) string
- func MakeQMPSocketPaths(info MachineInfo, names ...string) (paths []string)
- func MakeTPMSocketPath(info MachineInfo) string
- type Agent
- type Attributes
- type CPU
- type Connection
- type ConnectionName
- type Definition
- type Device
- type DeviceAddress
- type DeviceClass
- type DeviceID
- type DeviceName
- type Enlightenments
- type FileSystemPrivileges
- type Firmware
- type Group
- type GroupID
- type GroupName
- type IntPattern
- type Machine
- type MachineConnection
- type MachineID
- type MachineInfo
- type MachineName
- type MediatedDevice
- type MediatedDeviceList
- type MediatedDeviceMap
- type MediatedDeviceName
- type MediatedDeviceType
- type MediatedDeviceTypes
- type Memory
- type Network
- type NetworkMap
- type NetworkName
- type PatternMapper
- type PortPattern
- type Privileges
- type Processor
- type ProcessorMap
- type ProcessorName
- type QEMUAgent
- type QMP
- func (q *QMP) AllSocketPaths(info MachineInfo) (paths []string)
- func (q *QMP) CommandSocketPaths(info MachineInfo) (paths []string)
- func (q *QMP) Config(info MachineInfo, out summary.Interface)
- func (q *QMP) CustomSocketPaths(info MachineInfo) (paths []string)
- func (q *QMP) SystemSocketPaths(info MachineInfo) []string
- type QMPSockets
- type Seed
- func (s Seed) DeviceID(components ...[]byte) DeviceID
- func (s Seed) GroupID(components ...[]byte) GroupID
- func (s Seed) HardwareAddr(components ...[]byte) net.HardwareAddr
- func (s Seed) SerialNumber(components ...[]byte) string
- func (s Seed) UUID(components ...[]byte) UUID
- func (s Seed) WWN(components ...[]byte) wwn.Value
- type Spice
- type Storage
- type StorageMap
- type StorageName
- type StoragePath
- type StoragePattern
- type StorageType
- type StringPattern
- type System
- type TPM
- type TPMSocket
- type Tag
- type TagMap
- type Template
- type UUID
- type UserID
- type Vars
- type Volume
- type VolumeName
- type VolumePath
- type VolumeSerialNumber
Constants ¶
const ( LinuxBinDir = "/usr/bin" LinuxConfDir = "/etc/machina" LinuxMachineDir = "/etc/machina/machine.conf.d" LinuxUnitDir = "/etc/systemd/system" LinuxRunDir = "/run/machina" LinuxBashCompletionDir = "/usr/share/bash-completion/completions" )
Common paths assumed by machina's code generators.
const ( RawStorage = StorageType("raw") ISOStorage = StorageType("iso") FirmwareStorage = StorageType("firmware") )
Storage types.
Variables ¶
This section is empty.
Functions ¶
func MakeLinkName ¶
func MakeLinkName(machine MachineName, conn Connection) string
MakeLinkName returns the network interface name for a connection.
func MakeQMPSocketPaths ¶
func MakeQMPSocketPaths(info MachineInfo, names ...string) (paths []string)
MakeQMPSocketPaths returns a QMP socket path for each name for the given machine.
If info lacks necessary details to build a QMP socket path, it returns nil.
func MakeTPMSocketPath ¶
func MakeTPMSocketPath(info MachineInfo) string
MakeTPMSocketPath returns a Trusted Platform Module socket path for the given machine.
If info lacks necessary details to build a TPM socket path, it returns an empty string.
Types ¶
type Agent ¶
type Agent struct {
QEMU QEMUAgent `json:"qemu,omitempty"`
}
Agent describes the attributes of a machine's guest agent support.
type Attributes ¶
type Attributes struct { Firmware Firmware `json:"firmware,omitempty"` CPU CPU `json:"cpu,omitempty"` Memory Memory `json:"memory,omitempty"` Enlightenments Enlightenments `json:"enlightenments,omitempty"` TPM TPM `json:"tpm,omitempty"` QMP QMP `json:"qmp,omitempty"` Agent Agent `json:"agent,omitempty"` Spice Spice `json:"spice,omitempty"` }
Attributes describe various attributes of a machine.
func MergeAttributes ¶
func MergeAttributes(attrs ...Attributes) Attributes
MergeAttributes merges a set of attributes in order. If an attribute value is defined more than once, the first definition is used.
func (*Attributes) Config ¶
func (a *Attributes) Config(info MachineInfo, vars Vars, out summary.Interface)
Config adds the attributes configuration to the summary.
type CPU ¶
type CPU struct { Processor ProcessorName `json:"processor,omitempty"` Sockets int `json:"sockets,omitempty"` Cores int `json:"cores,omitempty"` ThreadsPerCore int `json:"threads,omitempty"` }
CPU describes the attributes of a machine's central processing units.
type Connection ¶
type Connection struct { Name ConnectionName `json:"name"` Network NetworkName `json:"network"` IP string `json:"ip"` MAC string `json:"mac"` }
Connection describes a network connection.
func MergeConnections ¶
func MergeConnections(conns ...Connection) []Connection
MergeConnections merges a set of connections in order. If more than one connection exists with the same name, only the first is included.
func (*Connection) Config ¶
func (c *Connection) Config(out summary.Interface)
Config adds the connection configuration to the summary.
func (Connection) Populate ¶
func (c Connection) Populate(seed Seed) Connection
Populate returns a copy of the connection with a hardware address, if one is not already present.
The provided machine seed is used to generate the address.
func (Connection) String ¶
func (c Connection) String() string
String returns a string representation of the network connection configuration.
type ConnectionName ¶
type ConnectionName string
ConnectionName is the name of a network connection on a machine.
type Definition ¶
type Definition struct { Vars Vars `json:"vars,omitempty"` Privileges Privileges `json:"privileges,omitempty"` Attributes Attributes `json:"attrs,omitempty"` Volumes []Volume `json:"volumes,omitempty"` Connections []Connection `json:"connections,omitempty"` Devices []Device `json:"devices,omitempty"` }
Definition holds the definition of a machine tag.
func Build ¶
func Build(m Machine, sys System) (merged Definition, err error)
Build takes the machina virtual machine definition present in m and merges it with the applicable tag definitions present in sys. It returns the merged definition.
func MergeDefinitions ¶
func MergeDefinitions(defs ...Definition) Definition
MergeDefinitions merges a set of definitions in order. If more than one volume exists with the same name, only the first is included.
func (*Definition) Config ¶
func (d *Definition) Config(info MachineInfo, out summary.Interface)
Config adds the attributes configuration to the summary.
type Device ¶
type Device struct { Name DeviceName `json:"name"` Class DeviceClass `json:"class"` ID DeviceID `json:"id,omitempty"` }
Device identifies a mediated or passthrough host device required by a machine.
The type of device is identified by its class, which must match a device classification on the system. The ID optionally provides a unique identifier in UUID format that can be used by some device types.
func MergeDevices ¶
MergeDevices merges a set of connections in order. If more than one device exists with the same ID, only the first is included.
type DeviceAddress ¶
type DeviceAddress string
DeviceAddress is a device address on the host system.
type DeviceClass ¶
type DeviceClass string
DeviceClass identifies a class of device on the host system that can be assigned to a virtual machine.
type DeviceID ¶
type DeviceID UUID
DeviceID is a universally uniqued identifer for a device.
func (DeviceID) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*DeviceID) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Enlightenments ¶
type Enlightenments struct {
Enabled bool `json:"enabled,omitempty"`
}
Enlightenments describe Hyper-V features for guests running Windows.
https://github.com/qemu/qemu/blob/master/docs/hyperv.txt
func (*Enlightenments) Config ¶
func (e *Enlightenments) Config(out summary.Interface)
Config adds the enlightenments configuration to the summary.
type FileSystemPrivileges ¶
type FileSystemPrivileges struct {
Group Group `json:"group,omitempty"`
}
FileSystemPrivileges describes the file system privileges of a machine.
func (*FileSystemPrivileges) Config ¶
func (fsp *FileSystemPrivileges) Config(out summary.Interface)
Config adds the firmware configuration to the summary.
type IntPattern ¶
type IntPattern string
IntPattern is a pattern that can undergo variable expansion to produce integer values.
func (IntPattern) Expand ¶
func (pattern IntPattern) Expand(mapper PatternMapper) (int, error)
Expand returns the expanded integer for the given mapper. If the expanded value cannot be converted to an integer, an error is returned.
type Machine ¶
type Machine struct { Name MachineName `json:"name,omitempty"` Description string `json:"description,omitempty"` ID MachineID `json:"id,omitempty"` Tags []Tag `json:"tags,omitempty"` Definition }
Machine describes an individual virtual machine in machina. It contains identity information, tags, and a definition.
If tags are present, the machine's definition can be merged with its tag definitions through use of the Build function.
The Machine structure is intended to be marshaled to and from JSON. It defines the format of files in the machina.conf.d directory.
func (Machine) Info ¶
func (m Machine) Info() MachineInfo
Info returns copy of the machine's entity information by itself.
type MachineConnection ¶
type MachineConnection struct { Machine MachineName Connection }
MachineConnection describes a connection for a machine.
type MachineID ¶
type MachineID UUID
MachineID is a universally unique identifer for a machine.
func (MachineID) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*MachineID) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type MachineInfo ¶
type MachineInfo struct { ID MachineID Description string Name MachineName }
MachineInfo holds identifying information for a machine.
func (MachineInfo) Seed ¶
func (info MachineInfo) Seed() Seed
Seed returns an identity generation seed for the machine info.
func (MachineInfo) Vars ¶
func (info MachineInfo) Vars() Vars
Vars returns a set of identifying machine variables. These can be used as variables for expansion.
type MachineName ¶
type MachineName string
MachineName is the name of a machina virtual machine.
TODO: Document restrictions on machine names and add validity checks. These names are used in various places when generating QEMU arguments. Spaces in particular could lead to argument parsing badness.
type MediatedDevice ¶
type MediatedDevice struct { Address DeviceAddress `json:"address"` Types MediatedDeviceTypes `json:"types,omitempty"` }
MediatedDevice describes a mediated device available on the host system.
func (MediatedDevice) Config ¶
func (dev MediatedDevice) Config(out summary.Interface)
Config adds the mediated device configuration to the summary.
type MediatedDeviceList ¶
type MediatedDeviceList []MediatedDevice
MediatedDeviceList holds a sortable list of mediated devices on the host system.
func (MediatedDeviceList) Len ¶
func (a MediatedDeviceList) Len() int
func (MediatedDeviceList) Less ¶
func (a MediatedDeviceList) Less(i, j int) bool
func (MediatedDeviceList) Swap ¶
func (a MediatedDeviceList) Swap(i, j int)
type MediatedDeviceMap ¶
type MediatedDeviceMap map[MediatedDeviceName]MediatedDevice
MediatedDeviceMap describes a set of mediated devices on the host system.
func (MediatedDeviceMap) WithClass ¶
func (m MediatedDeviceMap) WithClass(class DeviceClass) (devices MediatedDeviceList)
WithClass returns zero or more mediated devices that supply the given device class.
type MediatedDeviceName ¶
type MediatedDeviceName string
MediatedDeviceName is the name of a mediated device on the host system.
type MediatedDeviceType ¶
type MediatedDeviceType string
MediatedDeviceType is a device type offered by a mediated device.
type MediatedDeviceTypes ¶
type MediatedDeviceTypes map[DeviceClass]MediatedDeviceType
MediatedDeviceTypes map device classes to mediated device types on the host system.
type Memory ¶
type Memory struct {
RAM int `json:"ram,omitempty"`
}
Memory describes the attributes of a machine's memory.
type Network ¶
type Network struct { Device string `json:"device"` Up string `json:"up"` Down string `json:"down"` }
Network defines a network that a machine can be connected to.
type NetworkMap ¶
type NetworkMap map[NetworkName]Network
NetworkMap maps network names to networks on the local system.
type NetworkName ¶
type NetworkName string
NetworkName identifies a network on the local system by a well-known name.
TODO: Document restrictions on network names and add validity checks. These names are used in various places when generating QEMU arguments. Spaces in particular could lead to argument parsing badness.
type PatternMapper ¶
PatternMapper is a function that can map variables to values.
type PortPattern ¶
type PortPattern string
PortPattern is a pattern that can undergo variable expansion to produce network port numbers.
func (PortPattern) Expand ¶
func (pattern PortPattern) Expand(mapper PatternMapper) (int, error)
Expand returns the expanded integer for the given mapper. If the expanded value cannot be converted to an integer, an error is returned.
type Privileges ¶
type Privileges struct {
FileSystem FileSystemPrivileges `json:"filesystem,omitempty"`
}
Privileges describe various privileges of a machine.
func MergePrivileges ¶
func MergePrivileges(privs ...Privileges) Privileges
MergePrivileges merges a set of privileges in order. If a privilege value is defined more than once, the first definition is used.
func (*Privileges) Config ¶
func (p *Privileges) Config(info MachineInfo, vars Vars, out summary.Interface)
Config adds the privileges configuration to the summary.
func (Privileges) Populate ¶
func (p Privileges) Populate(seed Seed) Privileges
Populate returns a copy of the privileges with a file system access group name and ID, if not already present.
The provided machine seed is used to generate the group ID.
type Processor ¶
type Processor struct { Brand string `json:"brand"` Model string `json:"model"` ThreadsPerCore int `json:"threads"` Default bool `json:"default"` }
Processor describes a processor that a machine can run on.
type ProcessorMap ¶
type ProcessorMap map[ProcessorName]Processor
ProcessorMap maps processor names to processors on the local system.
func (ProcessorMap) Default ¶
func (m ProcessorMap) Default() ProcessorName
Default returns the name of a default processor from the map.
If the processor map is empty it returns an empty string.
type ProcessorName ¶
type ProcessorName string
ProcessorName identifies a processor on the local system by a well-known name.
type QEMUAgent ¶
type QEMUAgent struct { Enabled bool `json:"enabled,omitempty"` Port int `json:"port,omitempty"` PortPattern PortPattern `json:"port-pattern,omitempty"` }
QEMUAgent describes the attributes of a machine's QEMU guest agent.
type QMP ¶
type QMP struct { Enabled bool `json:"enabled,omitempty"` Sockets QMPSockets `json:"sockets,omitempty"` }
QMP describes the attributes of QEMU Machine Protocol support.
func (*QMP) AllSocketPaths ¶
func (q *QMP) AllSocketPaths(info MachineInfo) (paths []string)
AllSocketPaths returns the entire set of QMP socket paths for the given machine. The returned paths include the standard machina system and command socket paths, as well as any custom socket paths specified for the machine.
func (*QMP) CommandSocketPaths ¶
func (q *QMP) CommandSocketPaths(info MachineInfo) (paths []string)
CommandSocketPaths returns a set of QMP socket paths for use by command line utilities.
func (*QMP) Config ¶
func (q *QMP) Config(info MachineInfo, out summary.Interface)
Config adds the QEMU Machine Protocol configuration to the summary.
func (*QMP) CustomSocketPaths ¶
func (q *QMP) CustomSocketPaths(info MachineInfo) (paths []string)
CustomSocketPaths returns a set of QMP socket paths specified in the configuration. Named sockets will be returned as absolute paths in the standard machina socket directory. Pathed sockets will be retured verbatim.
func (*QMP) SystemSocketPaths ¶
func (q *QMP) SystemSocketPaths(info MachineInfo) []string
SystemSocketPaths returns a set of QMP socket paths for use by systemd.
type QMPSockets ¶
type QMPSockets struct { Names []string `json:"names,omitempty"` Paths []string `json:"paths,omitempty"` }
QMPSockets holds a set of custom QMP sockets that will be created for a virtual machine. These are in addition to the standard system and command sockets provided by machina.
Named sockets will be created in the standard machina socket directory following its socket naming convention.
Pathed sockets will be created at the given socket paths.
type Seed ¶
type Seed struct {
// contains filtered or unexported fields
}
Seed holds a seed state for generating various machina identities in a consistent and deterministic way.
func (Seed) DeviceID ¶
DeviceID constructs a device identifier from a hash of the seed and components.
func (Seed) GroupID ¶
GroupID constructs a POSIX group identifier from a hash of the seed and components.
The returned group ID will be between 65536 and 4294967295, placing it outside of the range of most standard tooling.
func (Seed) HardwareAddr ¶
func (s Seed) HardwareAddr(components ...[]byte) net.HardwareAddr
HardwareAddr constructs an IEEE 802 MAC-48/EUI-48 hardware address from a hash of the seed and components.
The address returned will have the well-known prefix of 52:54:00, which identifies it as a locally administered address issued to a KVM virtual machine. This leaves 24 bits of unique value per address, which may not be enough to avoid collisions on a large network.
For more details about locally administered addresses, see RFC 5342 Section 2.1. For an excellent treatment of MAC addresses in general, see the MAC Address FAQ from AllDataFeeds.
func (Seed) SerialNumber ¶
SerialNumber constructs a 128-bit serial number from a hash of the seed and components. The value is returned as a string encoded with Base 32 Encoding with Extended Hex Alphabet.
See RFC 4648 Section 7 for more details about the encoding.
func (Seed) WWN ¶
WWN constructs a 64-bit World Wide Name from a hash of the seed and components.
The name returned will use Network Address Authority type 5 and IEEE OUI value 52:54:00, which identifies it as a locally administered address issued to a KVM virtual machine. This leaves 36 bits of unique value per name.
For more details about locally administered addresses, see RFC 5342 Section 2.1.
type Spice ¶
type Spice struct { Enabled bool `json:"enabled,omitempty"` Port int `json:"port,omitempty"` PortPattern PortPattern `json:"port-pattern,omitempty"` Displays int `json:"displays,omitempty"` // TODO: Does this belong here? }
Spice describes the attributes of a machine's spice protocol configuration.
type Storage ¶
type Storage struct { Path StoragePath `json:"path"` Pattern StoragePattern `json:"pattern,omitempty"` Type StorageType `json:"type,omitempty"` ReadOnly bool `json:"readonly,omitempty"` }
Storage defines the common parameters for a storage pool.
func (Storage) Volume ¶
func (s Storage) Volume(machine MachineInfo, vars Vars, volume VolumeName) VolumePath
Volume returns the path of a volume.
type StorageMap ¶
type StorageMap map[StorageName]Storage
StorageMap maps storage names to storage pools on the local system.
type StorageName ¶
type StorageName string
StorageName is the name of a storage pool on the host system.
type StoragePath ¶
type StoragePath string
StoragePath is the path of a storage pool on the host system.
type StoragePattern ¶
type StoragePattern StringPattern
StoragePattern is a file storage naming pattern.
func (StoragePattern) Expand ¶
func (p StoragePattern) Expand(mapper PatternMapper) StoragePath
Expand returns the storage path for the given machine and volume.
TODO: Consider allowing other attributes or arbitrary values to be used as variables.
type StorageType ¶
type StorageType string
StorageType identifies the type of storage provided by a storage pool.
type StringPattern ¶
type StringPattern string
StringPattern is a pattern that can undergo variable expansion to produce string values.
func (StringPattern) Expand ¶
func (pattern StringPattern) Expand(mapper PatternMapper) string
Expand returns the expanded string for the given mapper.
type System ¶
type System struct { // Processor defines processors available on the host system. Processor ProcessorMap `json:"processor,omitempty"` // Storage defines storage pools available on the host system. Storage StorageMap `json:"storage,omitempty"` // Network defines network pools available on the host system. Network NetworkMap `json:"network,omitempty"` // MediatedDevices is a list of mediated devices available on the host // system. MediatedDevices MediatedDeviceMap `json:"mdev,omitempty"` // Tag defines tags available on the host system. Tag TagMap `json:"tag,omitempty"` }
System holds configuration for the virtual machine host system.
type TPM ¶
type TPM struct { Enabled bool `json:"enabled,omitempty"` Socket TPMSocket `json:"socket,omitempty"` }
TPM describes the attributes of a machine's Trusted Platform Module configuration.
func (*TPM) Config ¶
func (tpm *TPM) Config(info MachineInfo, out summary.Interface)
Config adds the Trusted Platform Module configuration to the summary.
func (*TPM) SocketPath ¶
func (tpm *TPM) SocketPath(info MachineInfo) string
SocketPath returns the TPM socket path for a machine.
type TPMSocket ¶
type TPMSocket struct {
Path string `json:"path,omitempty"`
}
TPMSocket holds a set of TPM socket settings for a virtual machine.
type Template ¶
Template describes a common set of values for a new virtual machine.
Templates are not fully implemented yet.
type Vars ¶
Vars hold a set of machine variables that can be expanded in various places.
type Volume ¶
type Volume struct { Name VolumeName `json:"name"` Storage StorageName `json:"storage"` WWN wwn.Value `json:"wwn"` SerialNumber VolumeSerialNumber `json:"serial"` Bootable bool `json:"bootable"` }
Volume describes a storage volume for a machine.
func MergeVolumes ¶
MergeVolumes merges a set of volumes in order. If more than one volume exists with the same name, only the first is included.
func (Volume) Populate ¶
Populate returns a copy of the volume with a world wide name and serial number, if not already present.
The provided machine seed is used to generate the identifiers.
type VolumeName ¶
type VolumeName string
VolumeName is the name of a volume on a machine.
func (VolumeName) Vars ¶
func (v VolumeName) Vars() Vars
Vars returns a volume name variable. This can be used a variable for expansion.
type VolumeSerialNumber ¶
type VolumeSerialNumber string
VolumeSerialNumber is the serial number of a volume on a machine.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
filesystem
|
|
mdevfs
Package mdevfs facilitates communication with mediated devices through the local sysfs file system.
|
Package mdevfs facilitates communication with mediated devices through the local sysfs file system. |
Package qemu provides fundamental types for describing options to QEMU.
|
Package qemu provides fundamental types for describing options to QEMU. |
qdev
Package qdev describes PCI Express device topologies of a QEMU guest.
|
Package qdev describes PCI Express device topologies of a QEMU guest. |
qguest
Package qguest describes non-device properties of a QEMU guest.
|
Package qguest describes non-device properties of a QEMU guest. |
qhost
Package qhost identifies and describes host resources that are contributed to a QEMU guest.
|
Package qhost identifies and describes host resources that are contributed to a QEMU guest. |
qhost/blockdev
Package blockdev articulates the QEMU block layer.
|
Package blockdev articulates the QEMU block layer. |
qhost/chardev
Package chardev describes the QEMU character device layer.
|
Package chardev describes the QEMU character device layer. |
qhost/tpmdev
Package tpmdev describes real and emulated Trusted Platform Module devices on the host.
|
Package tpmdev describes real and emulated Trusted Platform Module devices on the host. |
Package qemugen translates the high level concepts used by Machina into concrete virtual machine descriptions use by QEMU.
|
Package qemugen translates the high level concepts used by Machina into concrete virtual machine descriptions use by QEMU. |
Package qmp implments part of the QEMU Machine Protocol Specification.
|
Package qmp implments part of the QEMU Machine Protocol Specification. |
qmpcmd
Package qmpcmd defines a subset of possible QMP commands that are used by machina.
|
Package qmpcmd defines a subset of possible QMP commands that are used by machina. |
qmpmsg
Package qmpmsg defines types used to marshal and umarshal QMP messages.
|
Package qmpmsg defines types used to marshal and umarshal QMP messages. |
Package systemd facilitates systemd status queries via dbus.
|
Package systemd facilitates systemd status queries via dbus. |