Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigureParams(config *Config, logger QMPLog) ([]string, error)
- func CopyFileBits(src, dest string) error
- func CreateCloudInitISO(ctx context.Context, scratchDir, isoPath string, userData, metaData []byte, ...) error
- func GetSocketPaths(config *Config) ([]string, error)
- func LaunchCustomQemu(ctx context.Context, path string, params []string, fds []*os.File, ...) (string, error)
- func LaunchQemu(config *Config, logger QMPLog) (string, error)
- func MarshalConfig(config *Config) ([]byte, error)
- func PathExists(d string) bool
- func QMPStart(ctx context.Context, socket string, cfg QMPConfig, ...) (*QMP, *QMPVersion, error)
- func VMFPathBase() string
- func VMFPrefix() string
- func WriteConfig(configFile string, config *Config) error
- type BalloonDevice
- type BlockDevice
- type BlockDeviceAIO
- type BlockDeviceFormat
- type BlockDeviceInterface
- type BridgeDevice
- type BridgeType
- type CPUInfo
- type CPUInfoFast
- type CPUProperties
- type CacheMode
- type CharDevice
- type CharDeviceBackend
- type Config
- type DetectZeroesMode
- type Device
- type DeviceDriver
- type DiscardMode
- type FSDevice
- type FSDriver
- type FwCfg
- type HotpluggableCPU
- type IDEControllerDevice
- type IOThread
- type Incoming
- type IommuDev
- type Kernel
- type Knobs
- type LegacySerialDevice
- type LoaderDevice
- type Machine
- type Memory
- type MemoryDevices
- type MemoryDevicesData
- type MigrationDisk
- type MigrationRAM
- type MigrationStatus
- type MigrationXbzrleCache
- type MonitorDevice
- type NetDevice
- type NetDeviceMcastSocket
- type NetDeviceTap
- type NetDeviceType
- type NetDeviceUser
- type Object
- type ObjectType
- type PCIBus
- type PCIeRootPortDevice
- type PVPanicDevice
- type Port
- type PortRule
- type QMP
- func (q *QMP) ExecHotplugMemory(ctx context.Context, qomtype, id, mempath string, size int, share bool) error
- func (q *QMP) ExecMemdevAdd(ctx context.Context, qomtype, id, mempath string, size int, share bool, ...) error
- func (q *QMP) ExecQomGet(ctx context.Context, path, property string) (interface{}, error)
- func (q *QMP) ExecQomSet(ctx context.Context, path, property string, value uint64) error
- func (q *QMP) ExecQueryCpus(ctx context.Context) ([]CPUInfo, error)
- func (q *QMP) ExecQueryCpusFast(ctx context.Context) ([]CPUInfoFast, error)
- func (q *QMP) ExecQueryMemoryDevices(ctx context.Context) ([]MemoryDevices, error)
- func (q *QMP) ExecQueryQmpSchema(ctx context.Context) ([]SchemaInfo, error)
- func (q *QMP) ExecSetMigrateArguments(ctx context.Context, url string) error
- func (q *QMP) ExecSetMigrationCaps(ctx context.Context, caps []map[string]interface{}) error
- func (q *QMP) ExecuteAPVFIOMediatedDeviceAdd(ctx context.Context, sysfsdev string) error
- func (q *QMP) ExecuteBalloon(ctx context.Context, bytes uint64) error
- func (q *QMP) ExecuteBlockdevAdd(ctx context.Context, device, blockdevID string, ro bool) error
- func (q *QMP) ExecuteBlockdevAddWithCache(ctx context.Context, device, blockdevID string, direct, noFlush, ro bool) error
- func (q *QMP) ExecuteBlockdevAddWithDriverCache(ctx context.Context, driver, device, blockdevID string, ...) error
- func (q *QMP) ExecuteBlockdevDel(ctx context.Context, blockdevID string) error
- func (q *QMP) ExecuteCPUDeviceAdd(ctx context.Context, ...) error
- func (q *QMP) ExecuteCharDevUnixSocketAdd(ctx context.Context, id, path string, wait, server bool) error
- func (q *QMP) ExecuteChardevDel(ctx context.Context, chardevID string) error
- func (q *QMP) ExecuteCont(ctx context.Context) error
- func (q *QMP) ExecuteDeviceAdd(ctx context.Context, blockdevID, devID, driver, bus, romfile string, ...) error
- func (q *QMP) ExecuteDeviceDel(ctx context.Context, devID string) error
- func (q *QMP) ExecuteDumpGuestMemory(ctx context.Context, protocol string, paging bool, format string) error
- func (q *QMP) ExecuteGetFD(ctx context.Context, fdname string, fd *os.File) error
- func (q *QMP) ExecuteMigrationIncoming(ctx context.Context, uri string) error
- func (q *QMP) ExecuteNVDIMMDeviceAdd(ctx context.Context, id, mempath string, size int64, pmem *bool) error
- func (q *QMP) ExecuteNetCCWDeviceAdd(ctx context.Context, netdevID, devID, macAddr, bus string, queues int) error
- func (q *QMP) ExecuteNetPCIDeviceAdd(ctx context.Context, netdevID, devID, macAddr, addr, bus, romfile string, ...) error
- func (q *QMP) ExecuteNetdevAdd(ctx context.Context, netdevType, netdevID, ifname, downscript, script string, ...) error
- func (q *QMP) ExecuteNetdevAddByFds(ctx context.Context, netdevType, netdevID string, ...) error
- func (q *QMP) ExecuteNetdevChardevAdd(ctx context.Context, netdevType, netdevID, chardev string, queues int) error
- func (q *QMP) ExecuteNetdevDel(ctx context.Context, netdevID string) error
- func (q *QMP) ExecutePCIDeviceAdd(ctx context.Context, blockdevID, devID, driver, addr, bus, romfile string, ...) error
- func (q *QMP) ExecutePCIVFIODeviceAdd(ctx context.Context, devID, bdf, addr, bus, romfile string) error
- func (q *QMP) ExecutePCIVFIOMediatedDeviceAdd(ctx context.Context, devID, sysfsdev, addr, bus, romfile string) error
- func (q *QMP) ExecutePCIVSockAdd(ctx context.Context, id, guestCID, vhostfd, addr, bus, romfile string, ...) error
- func (q *QMP) ExecutePCIVhostUserDevAdd(ctx context.Context, driver, devID, chardevID, addr, bus string) error
- func (q *QMP) ExecuteQMPCapabilities(ctx context.Context) error
- func (q *QMP) ExecuteQueryHotpluggableCPUs(ctx context.Context) ([]HotpluggableCPU, error)
- func (q *QMP) ExecuteQueryMigration(ctx context.Context) (MigrationStatus, error)
- func (q *QMP) ExecuteQueryStatus(ctx context.Context) (StatusInfo, error)
- func (q *QMP) ExecuteQuit(ctx context.Context) error
- func (q *QMP) ExecuteSCSIDeviceAdd(ctx context.Context, blockdevID, devID, driver, bus, romfile string, ...) error
- func (q *QMP) ExecuteStop(ctx context.Context) error
- func (q *QMP) ExecuteSystemPowerdown(ctx context.Context) error
- func (q *QMP) ExecuteVFIODeviceAdd(ctx context.Context, devID, bdf, bus, romfile string) error
- func (q *QMP) ExecuteVirtSerialPortAdd(ctx context.Context, id, name, chardev string) error
- func (q *QMP) Shutdown()
- type QMPConfig
- type QMPEvent
- type QMPLog
- type QMPSocket
- type QMPSocketType
- type QMPVersion
- type QemuIndex
- type QemuTypeIndex
- func (qti QemuTypeIndex) Next(qtype string) int
- func (qti QemuTypeIndex) NextBootIndex() int
- func (qti QemuTypeIndex) NextDriveIndex() int
- func (qti QemuTypeIndex) NextNetIndex() int
- func (qti QemuTypeIndex) Set(qtype string, index int) error
- func (qti QemuTypeIndex) SetBootIndex(index int) error
- func (qti QemuTypeIndex) SetDriveIndex(index int) error
- func (qti QemuTypeIndex) SetNetIndex(index int) error
- type RTC
- type RTCBaseType
- type RTCClock
- type RTCDriftFix
- type RngDevice
- type RunState
- type SCSIControllerDevice
- type SMBIOSInfo
- type SMP
- type SMTableBIOS
- type SMTableBaseboard
- type SMTableChassis
- type SMTableMemory
- type SMTableProcessor
- type SMTableSystem
- type SchemaInfo
- type SecurityModelType
- type SerialDevice
- type SpiceDevice
- type StatusInfo
- type TPMDevice
- type UEFIFirmwareDevice
- type USBControllerDevice
- type VFIODevice
- type VMConfigContainer
- type VSOCKDevice
- type VhostUserDevice
- func (vhostuserDev VhostUserDevice) QemuBlkParams(config *Config) []string
- func (vhostuserDev VhostUserDevice) QemuFSParams(config *Config) []string
- func (vhostuserDev VhostUserDevice) QemuNetParams(config *Config) []string
- func (vhostuserDev VhostUserDevice) QemuParams(config *Config) []string
- func (vhostuserDev VhostUserDevice) QemuSCSIParams(config *Config) []string
- func (vhostuserDev VhostUserDevice) Valid() error
- type Virtio9PMultidev
- type VirtioTransport
Constants ¶
const ( // MachineTypeMicrovm is the QEMU microvm machine type for amd64 MachineTypeMicrovm string = "microvm" MachineTypePC35 string = "q35" MachineTypePC string = "pc" MachineTypeVirt string = "virt" MachineAccelerationKVM string = "kvm" )
const ( // MigrationFD is the migration incoming type based on open file descriptor. // Skip default 0 so that it must be set on purpose. MigrationFD = 1 // MigrationExec is the migration incoming type based on commands. MigrationExec = 2 // MigrationDefer is the defer incoming type MigrationDefer = 3 )
const ( RngDeviceType = "rngdevice" RngDevRandom = "/dev/random" RngDevUrandom = "/dev/urandom" )
const ( RunStateDebugStr string = "debug" RunStateFinishMigrateStr string = "finish-migrate" RunStateInMigrateStr string = "inmigrate" RunStateInternalErrorStr string = "internal-error" RunStateIOErrorStr string = "io-error" RunStatePausedStr string = "paused" RunStatePostMigrateStr string = "postmigrate" RunStatePreLaunchStr string = "prelaunch" RunStateRestoreVMStr string = "restore-vm" RunStateRunningStr string = "running" RunStateSaveVMStr string = "save-vm" RunStateShutdownStr string = "shutdown" RunStateSuspendedStr string = "suspended" RunStateWatchdogStr string = "watchdog" RunStateGuestPanickedStr string = "guest-panicked" RunStateColoStr string = "colo" RunStateUnknownStr string = "unknown" )
const ( TPMEmulatorDevice = "emulator" TPMPassthroughDevice = "passthrough" )
const ( UEFIVarsFileName = "uefi-nvram.fd" VMFCode = "VMF_CODE" // OVMF_CODE , AAVMF_CODE VMFVars = "VMF_VARS" VMFMs = ".ms" VMFSecboot = ".secboot" VMF4MB = "_4M" VMFSuffix = ".fd" VMF32Bit = "32" )
const ( // MinimalGuestCID is the smallest valid context ID for a guest. MinimalGuestCID uint64 = 3 // MaxGuestCID is the largest valid context ID for a guest. MaxGuestCID uint64 = 1<<32 - 1 )
const EmptyPortRule = "::0-:0"
const PCISlotMax int = 31
32 slots available, place auto-created devices starting at the end and decrement as needed to avoid impacting
const PCISlotOffset = 3
slot 0, 1, and 2 are always taken
const RemoteDisplayPortBase = 5900
const SMTableBIOSType = 0
const SMTableBaseboardType = 2
const SMTableChassisType = 3
const SMTableMemoryType = 17
const SMTableProcessorType = 4
const SMTableSystemType = 1
const SpiceCharDevDriver = "spicevmc"
const SpiceCharDevName = "vdagent"
const SpiceSerialNamespace = "com.redhat.spice.0"
const (
// VSOCKGuestCID is the VSOCK guest CID parameter.
VSOCKGuestCID = "guest-cid"
)
Variables ¶
var BalloonDeviceTransport = map[VirtioTransport]string{
TransportPCI: "virtio-balloon-pci",
TransportCCW: "virtio-balloon-ccw",
TransportMMIO: "virtio-balloon-device",
}
BalloonDeviceTransport is a map of the virtio-balloon device name that corresponds to each transport.
var SCSIControllerTransport = map[VirtioTransport]string{
TransportPCI: "virtio-scsi-pci",
TransportCCW: "virtio-scsi-ccw",
TransportMMIO: "virtio-scsi-device",
}
SCSIControllerTransport is a map of the virtio-scsi device name that corresponds to each transport.
var VFIODeviceTransport = map[VirtioTransport]string{
TransportPCI: "vfio-pci",
TransportCCW: "vfio-ccw",
TransportMMIO: "vfio-device",
}
VFIODeviceTransport is a map of the vfio device name that corresponds to each transport.
var VMFHostPrefix = "/usr/share"
var VSOCKDeviceTransport = map[VirtioTransport]string{
TransportPCI: "vhost-vsock-pci",
TransportCCW: "vhost-vsock-ccw",
TransportMMIO: "vhost-vsock-device",
}
VSOCKDeviceTransport is a map of the vhost-vsock device name that corresponds to each transport.
var VhostUserBlkTransport = map[VirtioTransport]string{
TransportPCI: "vhost-user-blk-pci",
TransportCCW: "vhost-user-blk-ccw",
TransportMMIO: "vhost-user-blk-device",
}
VhostUserBlkTransport is a map of the vhost-user-blk device name that corresponds to each transport.
var VhostUserFSTransport = map[VirtioTransport]string{
TransportPCI: "vhost-user-fs-pci",
TransportCCW: "vhost-user-fs-ccw",
TransportMMIO: "vhost-user-fs-device",
}
VhostUserFSTransport is a map of the vhost-user-fs device name that corresponds to each transport.
var VhostUserNetTransport = map[VirtioTransport]string{
TransportPCI: "virtio-net-pci",
TransportCCW: "virtio-net-ccw",
TransportMMIO: "virtio-net-device",
}
VhostUserNetTransport is a map of the virtio-net device name that corresponds to each transport.
var VhostUserSCSITransport = map[VirtioTransport]string{
TransportPCI: "vhost-user-scsi-pci",
TransportCCW: "vhost-user-scsi-ccw",
TransportMMIO: "vhost-user-scsi-device",
}
VhostUserSCSITransport is a map of the vhost-user-scsi device name that corresponds to each transport.
var Virtio9PTransport = map[VirtioTransport]string{
TransportPCI: "virtio-9p-pci",
TransportCCW: "virtio-9p-ccw",
TransportMMIO: "virtio-9p-device",
}
Virtio9PTransport is a map of the virtio-9p device name that corresponds to each transport.
var VirtioBlockTransport = map[VirtioTransport]string{
TransportPCI: "virtio-blk-pci",
TransportCCW: "virtio-blk-ccw",
TransportMMIO: "virtio-blk-device",
}
VirtioBlockTransport is a map of the virtio-blk device name that corresponds to each transport.
var VirtioNetTransport = map[VirtioTransport]string{
TransportPCI: "virtio-net-pci",
TransportCCW: "virtio-net-ccw",
TransportMMIO: "virtio-net-device",
}
VirtioNetTransport is a map of the virtio-net device name that corresponds to each transport.
var VirtioSerialTransport = map[VirtioTransport]string{
TransportPCI: "virtio-serial-pci",
TransportCCW: "virtio-serial-ccw",
TransportMMIO: "virtio-serial-device",
}
VirtioSerialTransport is a map of the virtio-serial device name that corresponds to each transport.
Functions ¶
func CopyFileBits ¶
CopyFileBits - copy file content from a to b differs from CopyFile in:
- does not do permissions - new files created with 0644
- if src is a symlink, copies content, not link.
- does not invoke sh.
func CreateCloudInitISO ¶
func CreateCloudInitISO(ctx context.Context, scratchDir, isoPath string, userData, metaData []byte, attr *syscall.SysProcAttr) error
CreateCloudInitISO creates a cloud-init ConfigDrive ISO image. This is useful for configuring newly booted VMs. Before it can create the ISO image it needs to create a file tree with the various files that will make up the image. This directory is created under scratchDir and is deleted when when the function returns, successfully or otherwise. ctx is a context that can be used to timeout or cancel the image creation. isoPath contains the desired path of the ISO image to be created. The userdata and metadata parameters are byte slices that contain the ConfigDrive userdata and metadata that will be stored with the ISO image. The attrs parameter can be used to control aspects of the newly created qemu process, such as the user and group under which it runs. It may be nil.
func GetSocketPaths ¶
GetSocketPaths seaches config for Chardev,Serial,Monitor and QMP sockets
func LaunchCustomQemu ¶
func LaunchCustomQemu(ctx context.Context, path string, params []string, fds []*os.File, attr *syscall.SysProcAttr, logger QMPLog) (string, error)
LaunchCustomQemu can be used to launch a new qemu instance.
The path parameter is used to pass the qemu executable path.
params is a slice of options to pass to qemu-system-x86_64 and fds is a list of open file descriptors that are to be passed to the spawned qemu process. The attrs parameter can be used to control aspects of the newly created qemu process, such as the user and group under which it runs. It may be nil.
This function writes its log output via logger parameter.
The function will block until the launched qemu process exits. "", nil will be returned if the launch succeeds. Otherwise a string containing the contents of stderr + a Go error object will be returned.
func LaunchQemu ¶
LaunchQemu can be used to launch a new qemu instance.
The Config parameter contains a set of qemu parameters and settings.
This function writes its log output via logger parameter.
The function will block until the launched qemu process exits. "", nil will be returned if the launch succeeds. Otherwise a string containing the contents of stderr + a Go error object will be returned.
func MarshalConfig ¶
func PathExists ¶
func QMPStart ¶
func QMPStart(ctx context.Context, socket string, cfg QMPConfig, disconnectedCh chan struct{}) (*QMP, *QMPVersion, error)
QMPStart connects to a unix domain socket maintained by a QMP instance. It waits to receive the QMP welcome message via the socket and spawns some go routines to manage the socket. The function returns a *QMP which can be used by callers to send commands to the QEMU instance or to close the socket and all the go routines that have been spawned to monitor it. A *QMPVersion is also returned. This structure contains the version and capabilities information returned by the QEMU instance in its welcome message.
socket contains the path to the domain socket. cfg contains some options that can be specified by the caller, namely where the qemu package should send logs and QMP events. disconnectedCh is a channel that must be supplied by the caller. It is closed when an error occurs openning or writing to or reading from the unix domain socket. This implies that the QEMU instance that opened the socket has closed.
If this function returns without error, callers should call QMP.Shutdown when they wish to stop monitoring the QMP instance. This is not strictly necessary if the QEMU instance exits and the disconnectedCh is closed, but doing so will not cause any problems.
Commands can be sent to the QEMU instance via the QMP.Execute methods. These commands are executed serially, even if the QMP.Execute methods are called from different go routines. The QMP.Execute methods will block until they have received a success or failure message from QMP, i.e., {"return": {}} or {"error":{}}, and in some cases certain events are received.
QEMU currently requires that the "qmp_capabilties" command is sent before any other command. Therefore you must call qmp.ExecuteQMPCapabilities() before you execute any other command.
func VMFPathBase ¶
func VMFPathBase() string
func WriteConfig ¶
Types ¶
type BalloonDevice ¶
type BalloonDevice struct {
DeflateOnOOM bool `yaml:"deflate-on-oom"`
DisableModern bool `yaml:"disable-modern"`
ID string `yaml:"id"`
// ROMFile specifies the ROM file being used for this device.
ROMFile string `yaml:"rom-file"`
// DevNo identifies the ccw devices for s390x architecture
DevNo string `yaml:"ccw-dev-no"`
// Transport is the virtio transport for this device.
Transport VirtioTransport `yaml:"transport"`
}
BalloonDevice represents a memory balloon device.
func (BalloonDevice) QemuParams ¶
func (b BalloonDevice) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of the BalloonDevice.
func (BalloonDevice) Valid ¶
func (b BalloonDevice) Valid() error
Valid returns true if the balloonDevice structure is valid and complete.
type BlockDevice ¶
type BlockDevice struct {
Driver DeviceDriver `yaml:"driver"`
ID string `yaml:"id"`
File string `yaml:"file"`
Interface BlockDeviceInterface `yaml:"interface"`
AIO BlockDeviceAIO `yaml:"aio"`
Format BlockDeviceFormat `yaml:"format"`
SCSI bool `yaml:"scsi"`
WCE bool `yaml:"write-cache"`
BootIndex string `yaml:"bootindex"`
// Media is a hint about the what type of content on the disk, e.g media=cdrom
Media string `yaml:"media"`
// BlockSize is the linux kernel block {physical,logical}_block_size value
BlockSize int `yaml:"blocksize-bytes"`
// RotationRate is the linux kernel block rotation_rate value
RotationRate int `yaml:"rotation-rate"`
// BusAddr is the bus address for some block devices (virtio-blk-pci)
BusAddr string `yaml:"busaddr"`
Bus string `yaml:"bus"`
// Serial is the 21-character disk serial value
Serial string `yaml:"serial"`
// Cache mode for the disk
Cache CacheMode `yaml:"cache-mode"`
// DisableModern prevents qemu from relying on fast MMIO.
DisableModern bool `yaml:"disable-modern"`
// ROMFile specifies the ROM file being used for this device.
ROMFile string `yaml:"rom-file"`
// DevNo identifies the ccw devices for s390x architecture
DevNo string `yaml:"ccw-dev-no"`
ShareRW bool `yaml:"share-rw"`
// ReadOnly sets the block device in readonly mode
ReadOnly bool `yaml:"read-only"`
// Transport is the virtio transport for this device.
Transport VirtioTransport `yaml:"transport"`
Discard DiscardMode `yaml:"discard-mode"`
DetectZeroes DetectZeroesMode `yaml:"detect-zeros-mode"`
// DriveOnly is a boolean to skip any -device paramters
// This is currently used for OVMF/UEFI pflash disk only devices
DriveOnly bool `yaml:"emit-drive-only"`
}
BlockDevice represents a qemu block device.
func (BlockDevice) QemuParams ¶
func (blkdev BlockDevice) QemuParams(config *Config) []string
FIXME: this should use -blockdev, instead of -drive QemuParams returns the qemu parameters built out of this block device.
func (BlockDevice) Valid ¶
func (blkdev BlockDevice) Valid() error
Valid returns true if the BlockDevice structure is valid and complete.
type BlockDeviceAIO ¶
type BlockDeviceAIO string
BlockDeviceAIO defines the type of asynchronous I/O the block device should use.
const ( // Threads is the pthread asynchronous I/O implementation. Threads BlockDeviceAIO = "threads" // Native is the pthread asynchronous I/O implementation. Native BlockDeviceAIO = "native" )
type BlockDeviceFormat ¶
type BlockDeviceFormat string
BlockDeviceFormat defines the image format used on a block device.
const ( // QCOW2 is the Qemu Copy On Write v2 image format. QCOW2 BlockDeviceFormat = "qcow2" // RAW is the direct indexing image format RAW BlockDeviceFormat = "raw" )
type BlockDeviceInterface ¶
type BlockDeviceInterface string
BlockDeviceInterface defines the type of interface the device is connected to.
const ( // NoInterface for block devices with no interfaces. NoInterface BlockDeviceInterface = "none" // SCSI represents a SCSI block device interface. SCSI BlockDeviceInterface = "scsi" PFlashInterface BlockDeviceInterface = "pflash" )
type BridgeDevice ¶
type BridgeDevice struct {
// Type of the bridge
Type BridgeType `yaml:"type"`
// Bus number where the bridge is plugged, typically pci.0 or pcie.0
Bus string `yaml:"bus"`
// ID is used to identify the bridge in qemu
ID string `yaml:"id"`
// Chassis number
Chassis int `yaml:"chassis"`
// SHPC is used to enable or disable the standard hot plug controller
SHPC bool `yaml:"standard-hotplug-controller"`
// PCI Slot
Addr string `yaml:"address"`
// ROMFile specifies the ROM file being used for this device.
ROMFile string `yaml:"rom-file"`
// Address range reservations for devices behind the bridge
// NB: strings seem an odd choice, but if they were integers,
// they'd default to 0 by Go's rules in all the existing users
// who don't set them. 0 is a valid value for certain cases,
// but not you want by default.
IOReserve string `yaml:"io-reserve"`
MemReserve string `yaml:"mem-reserve"`
Pref64Reserve string `yaml:"pref64-reserve"`
}
BridgeDevice represents a qemu bridge device like pci-bridge, pxb, etc.
func (BridgeDevice) QemuParams ¶
func (bridgeDev BridgeDevice) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of this bridge device.
func (BridgeDevice) Valid ¶
func (bridgeDev BridgeDevice) Valid() error
Valid returns nil if the BridgeDevice structure is valid and complete.
type BridgeType ¶
type BridgeType uint
BridgeType is the type of the bridge
const ( // PCIBridge is a pci bridge PCIBridge BridgeType = iota // PCIEBridge is a pcie bridge PCIEBridge )
type CPUInfo ¶
type CPUInfo struct {
CPU int `json:"CPU"`
Current bool `json:"current"`
Halted bool `json:"halted"`
QomPath string `json:"qom_path"`
Arch string `json:"arch"`
Pc int `json:"pc"`
ThreadID int `json:"thread_id"`
Props CPUProperties `json:"props"`
}
CPUInfo represents information about each virtual CPU
type CPUInfoFast ¶
type CPUInfoFast struct {
CPUIndex int `json:"cpu-index"`
QomPath string `json:"qom-path"`
Arch string `json:"arch"`
ThreadID int `json:"thread-id"`
Target string `json:"target"`
Props CPUProperties `json:"props"`
}
CPUInfoFast represents information about each virtual CPU
type CPUProperties ¶
type CPUProperties struct {
Node int `json:"node-id"`
Socket int `json:"socket-id"`
Die int `json:"die-id"`
Core int `json:"core-id"`
Thread int `json:"thread-id"`
}
CPUProperties contains the properties of a CPU instance
type CharDevice ¶
type CharDevice struct {
Backend CharDeviceBackend `yaml:"backend"`
// Driver is the qemu device driver
Driver DeviceDriver `yaml:"driver"`
// Bus is the serial bus associated to this device.
Bus string `yaml:"bus"`
// DeviceID is the user defined device ID.
DeviceID string `yaml:"device-id"`
ID string `yaml:"id"`
Path string `yaml:"path"`
Name string `yaml:"name"`
// DisableModern prevents qemu from relying on fast MMIO.
DisableModern bool `yaml:"disable-modern"`
// ROMFile specifies the ROM file being used for this device.
ROMFile string `yaml:"rom-file"`
// DevNo identifies the ccw devices for s390x architecture
DevNo string `yaml:"ccw-dev-no"`
// Transport is the virtio transport for this device.
Transport VirtioTransport `yaml:"transport"`
// Mux will multiplex output if value is 'on', 'off' disables, default value
Mux string `yaml:"multiplex"`
// Signal will enable signal processing if 'on', or not if 'off'
Signal string `yaml:"signal"`
}
CharDevice represents a qemu character device.
func (CharDevice) QemuParams ¶
func (cdev CharDevice) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of this character device.
func (CharDevice) Valid ¶
func (cdev CharDevice) Valid() error
Valid returns nil if the CharDevice structure is valid and complete.
type CharDeviceBackend ¶
type CharDeviceBackend string
CharDeviceBackend is the character device backend for qemu
const ( // Pipe creates a 2 way connection to the guest. Pipe CharDeviceBackend = "pipe" // Socket creates a 2 way stream socket (TCP or Unix). Socket CharDeviceBackend = "socket" // CharConsole sends traffic from the guest to QEMU's standard output. CharConsole CharDeviceBackend = "console" // Serial sends traffic from the guest to a serial device on the host. Serial CharDeviceBackend = "serial" // TTY is an alias for Serial. TTY CharDeviceBackend = "tty" // PTY creates a new pseudo-terminal on the host and connect to it. PTY CharDeviceBackend = "pty" // File sends traffic from the guest to a file on the host. File CharDeviceBackend = "file" // Stdio creates a 2 way connection to guest via stdio Stdio CharDeviceBackend = "stdio" // SpiceVMC creates a spice-protocol char device over a virtserialport SpiceVMC CharDeviceBackend = "spicevmc" )
type Config ¶
type Config struct {
// Path is the qemu binary path.
Path string `yaml:"qemu-binary-path"`
// StateDir is the directory where VM state will be stored
StateDir string `yaml:"state-dir"`
// Ctx is the context used when launching qemu.
Ctx context.Context
// User ID.
Uid uint32 `yaml:"user-id,omitempty"`
// Group ID.
Gid uint32 `yaml:"group-id,omitempty"`
// Supplementary group IDs.
Groups []uint32 `yaml:"groups,omitempty"`
// Name is the qemu guest name
Name string `yaml:"name"`
// UUID is the qemu process UUID.
UUID string `yaml:"uuid"`
// CPUModel is the CPU model to be used by qemu.
CPUModel string `yaml:"cpu-model"`
// CPUModelFlags auguments the capabilities of the cpu
CPUModelFlags []string `yaml:"cpu-model-flags"`
// SeccompSandbox is the qemu function which enables the seccomp feature
SeccompSandbox string `yaml:"seccomp-sandbox"`
// Machine
Machine Machine `yaml:"machine"`
// SMBIOS
SMBIOS SMBIOSInfo `yaml:"smbios"`
// QMPSockets is a slice of QMP socket description.
QMPSockets []QMPSocket `yaml:"qmp-sockets"`
RngDevices []RngDevice `yaml:"rng-devices"`
BlkDevices []BlockDevice `yaml:"blk-devices"`
NetDevices []NetDevice `yaml:"net-devices"`
CharDevices []CharDevice `yaml:"char-devices"`
LegacySerialDevices []LegacySerialDevice `yaml:"legacy-serial-devices"`
SerialDevices []SerialDevice `yaml:"serial-devices"`
MonitorDevices []MonitorDevice `yaml:"monitor-devices"`
PCIeRootPortDevices []PCIeRootPortDevice `yaml:"pcie-root-port-devices"`
UEFIFirmwareDevices []UEFIFirmwareDevice `yaml:"uefi-firmware-devices"`
SCSIControllerDevices []SCSIControllerDevice `yaml:"scsi-controller-devices"`
IDEControllerDevices []IDEControllerDevice `yaml:"ide-controller-devices"`
USBControllerDevices []USBControllerDevice `yaml:"usb-controller-devices"`
// RTC is the qemu Real Time Clock configuration
RTC RTC `yaml:"real-time-clock"`
// VGA is the qemu VGA mode.
VGA string `yaml:"vga-mode"`
// SpiceDevice is the qemu spice protocol device for remote display
SpiceDevice SpiceDevice `yaml:"spice"`
// TPMDevice is a QEMU TPM device for guest OS use
TPM TPMDevice `yaml:"tpm"`
// Kernel is the guest kernel configuration.
Kernel Kernel `yaml:"kernel"`
// Memory is the guest memory configuration.
Memory Memory `yaml:"memory"`
// SMP is the quest multi processors configuration.
SMP SMP `yaml:"smp"`
// GlobalParams is for -global parameter
GlobalParams []string `yaml:"global-params"`
// Knobs is a set of qemu boolean settings.
Knobs Knobs `yaml:"qemu-knobs"`
// Bios is the -bios parameter
Bios string `yaml:"bios-path"`
// PFlash specifies the parallel flash images (-pflash parameter)
PFlash []string `yaml:"pflash-images"`
// Incoming controls migration source preparation
Incoming Incoming `yaml:"incoming"`
// FwCfg is the -fw_cfg parameter
FwCfg []FwCfg `yaml:"firmware-config"`
IOThreads []IOThread `yaml:"iothreads"`
// PidFile is the -pidfile parameter
PidFile string `yaml:"pid-file"`
// LogFile is the -D parameter
LogFile string `yaml:"log-file"`
// contains filtered or unexported fields
}
Config is the qemu configuration structure. It allows for passing custom settings and parameters to the qemu API.
func ReadConfig ¶
func UnmarshalConfig ¶
type DetectZeroesMode ¶
type DetectZeroesMode string
const ( DetectZeroesOn DetectZeroesMode = "on" DetectZeroesOff DetectZeroesMode = "off" DetectZeroesUnmap DetectZeroesMode = "unmap" )
type DeviceDriver ¶
type DeviceDriver string
DeviceDriver is the device driver string.
const ( // LegacySerial is the legacy serial device driver LegacySerial DeviceDriver = "serial" // NVDIMM is the Non Volatile DIMM device driver. NVDIMM DeviceDriver = "nvdimm" // VirtioNet is the virtio networking device driver. VirtioNet DeviceDriver = "virtio-net" // VirtioNetPCI is the virt-io pci networking device driver. VirtioNetPCI DeviceDriver = "virtio-net-pci" // VirtioNetCCW is the virt-io ccw networking device driver. VirtioNetCCW DeviceDriver = "virtio-net-ccw" // E1000 is the emulated Intel E1000 networking device driver E1000 DeviceDriver = "e1000" // VirtioBlock is the block device driver. VirtioBlock DeviceDriver = "virtio-blk" // IDEHardDisk is the block device driver IDEHardDisk DeviceDriver = "ide-hd" // IDECDROM is the block device driver IDECDROM DeviceDriver = "ide-cd" // SCSIHD is the block device driver SCSIHD DeviceDriver = "scsi-hd" // SCSICD is the block device driver SCSICD DeviceDriver = "scsi-cd" // NVME is the block device driver NVME DeviceDriver = "nvme" // USBStorage is the block device driver USBStorage DeviceDriver = "usb-storage" // Console is the console device driver. Console DeviceDriver = "virtconsole" // Virtio9P is the 9pfs device driver. Virtio9P DeviceDriver = "virtio-9p" // VirtioScsi is the scsi controller over virtio driver VirtioScsi DeviceDriver = "virtio-scsi-pci" // VirtioSerial is the serial device driver. VirtioSerial DeviceDriver = "virtio-serial" // VirtioSerialPort is the serial port device driver. VirtioSerialPort DeviceDriver = "virtserialport" // VirtioRng is the paravirtualized RNG device driver. VirtioRng DeviceDriver = "virtio-rng" // VirtioRngPCI is the paravirtualized RNG device driver on PCI bus VirtioRngPCI DeviceDriver = "virtio-rng-pci" // VirtioRngPCI is the paravirtualized RNG device driver on CCW bus VirtioRngCCW DeviceDriver = "virtio-rng-ccw" // VirtioBalloon is the memory balloon device driver. VirtioBalloon DeviceDriver = "virtio-balloon" //VhostUserSCSI represents a SCSI vhostuser device type. VhostUserSCSI DeviceDriver = "vhost-user-scsi" //VhostUserNet represents a net vhostuser device type. VhostUserNet DeviceDriver = "virtio-net" //VhostUserBlk represents a block vhostuser device type. VhostUserBlk DeviceDriver = "vhost-user-blk" //VhostUserFS represents a virtio-fs vhostuser device type VhostUserFS DeviceDriver = "vhost-user-fs" // PCIBridgeDriver represents a PCI bridge device type. PCIBridgeDriver DeviceDriver = "pci-bridge" // PCIePCIBridgeDriver represents a PCIe to PCI bridge device type. PCIePCIBridgeDriver DeviceDriver = "pcie-pci-bridge" // VfioPCI is the vfio driver with PCI transport. VfioPCI DeviceDriver = "vfio-pci" // VfioCCW is the vfio driver with CCW transport. VfioCCW DeviceDriver = "vfio-ccw" // VfioAP is the vfio driver with AP transport. VfioAP DeviceDriver = "vfio-ap" // VHostVSockPCI is a generic Vsock vhost device with PCI transport. VHostVSockPCI DeviceDriver = "vhost-vsock-pci" // PCIeRootPort is a PCIe Root Port, the PCIe device should be hotplugged to this port. PCIeRootPort DeviceDriver = "pcie-root-port" // Loader is the Loader device driver. Loader DeviceDriver = "loader" // SpaprTPMProxy is used for enabling guest to run in secure mode on ppc64le. SpaprTPMProxy DeviceDriver = "spapr-tpm-proxy" // PFlash PFlash DeviceDriver = "pflash" // USB-XHCI-Controller USBXHCIController DeviceDriver = "qemu-xhci" // AHCI ICH9 Controller ICH9AHCIController DeviceDriver = "ich9-ahci" // PIIX3 IDE Controller PIIX3IDEController DeviceDriver = "piix3-ide" // PIIX4 IDE Controller PIIX4IDEController DeviceDriver = "piix4-ide" // TPM-TIS TPM Device TPMTISDevice DeviceDriver = "tpm-tis" // TPM-CRB TPM Device TPMCRBDebice DeviceDriver = "tpm-crb" // PCI Serial Device PCISerialDevice DeviceDriver = "pci-serial" )
type DiscardMode ¶
type DiscardMode string
const ( DiscardIgnore DiscardMode = "ignore" DiscardUnmap DiscardMode = "unmap" )
type FSDevice ¶
type FSDevice struct {
// Driver is the qemu device driver
Driver DeviceDriver `yaml:"driver"`
// FSDriver is the filesystem driver backend.
FSDriver FSDriver `yaml:"fs-driver"`
// ID is the filesystem identifier.
ID string `yaml:"id"`
// Path is the host root path for this filesystem.
Path string `yaml:"path"`
// MountTag is the device filesystem mount point tag.
MountTag string `yaml:"mount-tag"`
// SecurityModel is the security model for this filesystem device.
SecurityModel SecurityModelType `yaml:"security-model"`
// DisableModern prevents qemu from relying on fast MMIO.
DisableModern bool `yaml:"disable-modern"`
// ROMFile specifies the ROM file being used for this device.
ROMFile string `yaml:"rom-file"`
// DevNo identifies the ccw devices for s390x architecture
DevNo string `yaml:"ccw-dev-no"`
// Transport is the virtio transport for this device.
Transport VirtioTransport `yaml:"transport"`
// Multidev is the filesystem behaviour to deal
// with multiple devices being shared with a 9p export
Multidev Virtio9PMultidev `yaml:"multidev"`
}
FSDevice represents a qemu filesystem configuration.
func (FSDevice) QemuParams ¶
QemuParams returns the qemu parameters built out of this filesystem device.
type FwCfg ¶
type FwCfg struct {
Name string `yaml:"name"`
File string `yaml:"file"`
Str string `yaml:"string"`
}
FwCfg allows QEMU to pass entries to the guest File and Str are mutually exclusive
func (FwCfg) QemuParams ¶
QemuParams returns the qemu parameters built out of the FwCfg object
type HotpluggableCPU ¶
type HotpluggableCPU struct {
Type string `json:"type"`
VcpusCount int `json:"vcpus-count"`
Properties CPUProperties `json:"props"`
QOMPath string `json:"qom-path"`
}
HotpluggableCPU represents a hotpluggable CPU
type IDEControllerDevice ¶
type IDEControllerDevice struct {
ID string `yaml:"id"`
Driver DeviceDriver `yaml:"driver"`
Bus string `yaml:"bus,omitempty"`
Addr string `yaml:"addr,omitempty"`
FailoverPairID string `yaml:"failover-pair-id,omitempty"`
ROMFile string `yaml:"romfile,omitempty"`
ROMBar string `yaml:"rombar,omitempty"`
Multifunction bool `yaml:"multifunction,omitempty"`
XPCIELinkStateDLLLA bool `yaml:"x-pcie-lnksta-dllla,omitempty"`
XPCIeExternalCapInit bool `yaml:"x-pcie-extcap-init,omitempty"`
CommandSerrEnable bool `yaml:"command-seer-enable,omitempty"`
}
IDEController represents an IDE controller device.
func (IDEControllerDevice) QemuParams ¶
func (ideCon IDEControllerDevice) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of this IDEController device.
func (IDEControllerDevice) Valid ¶
func (ideCon IDEControllerDevice) Valid() error
Valid returns true if the IDEController structure is valid and complete.
type IOThread ¶
type IOThread struct {
ID string `yaml:"id"`
}
IOThread allows IO to be performed on a separate thread.
type Incoming ¶
type Incoming struct {
// Possible values are MigrationFD, MigrationExec
MigrationType int `yaml:"type"`
// Only valid if MigrationType == MigrationFD
FD *os.File
// Only valid if MigrationType == MigrationExec
Exec string `yaml:"exec"`
}
Incoming controls migration source preparation
type IommuDev ¶
type IommuDev struct {
Intremap bool `yaml:"interupt-remap"`
DeviceIotlb bool `yaml:"device-iotlb"`
CachingMode bool `yaml:"caching-mode"`
}
IommuDev represents a Intel IOMMU Device
func (IommuDev) QemuParams ¶
QemuParams returns the qemu parameters built out of the IommuDev.
type Kernel ¶
type Kernel struct {
// Path is the guest kernel path on the host filesystem.
Path string `yaml:"path"`
// InitrdPath is the guest initrd path on the host filesystem.
InitrdPath string `yaml:"initrd-path"`
// Params is the kernel parameters string.
Params string `yaml:"params-string"`
}
Kernel is the guest kernel configuration structure.
type Knobs ¶
type Knobs struct {
// NoUserConfig prevents qemu from loading user config files.
NoUserConfig bool `yaml:"no-user-config"`
// NoDefaults prevents qemu from creating default devices.
NoDefaults bool `yaml:"no-defaults"`
// NoGraphic completely disables graphic output.
NoGraphic bool `yaml:"no-graphic"`
// Daemonize will turn the qemu process into a daemon
Daemonize bool `yaml:"daemonize"`
// Both HugePages and MemPrealloc require the Memory.Size of the VM
// to be set, as they need to reserve the memory upfront in order
// for the VM to boot without errors.
//
// HugePages always results in memory pre-allocation.
// However the setup is different from normal pre-allocation.
// Hence HugePages has precedence over MemPrealloc
// HugePages will pre-allocate all the RAM from huge pages
HugePages bool `yaml:"hugepages"`
// MemPrealloc will allocate all the RAM upfront
MemPrealloc bool `yaml:"memory-preallocate"`
// FileBackedMem requires Memory.Size and Memory.Path of the VM to
// be set.
FileBackedMem bool `yaml:"file-backed-memory"`
MemShared bool `yaml:"mem-shared"`
// Mlock will control locking of memory
Mlock bool `yaml:"mlock"`
// Stopped will not start guest CPU at startup
Stopped bool `yaml:"create-but-do-not-start"`
// Exit instead of rebooting
// Prevents QEMU from rebooting in the event of a Triple Fault.
NoReboot bool `yaml:"no-reboot"`
// Don’t exit QEMU on guest shutdown, but instead only stop the emulation.
NoShutdown bool `yaml:"no-shutdown"`
// IOMMUPlatform will enable IOMMU for supported devices
IOMMUPlatform bool `yaml:"iommu-platform-enable"`
// Disable the HPET clocksource
NoHPET bool `yaml:"no-hpet-clocksource"`
// Snapshot will create temporary writable disks to avoid modifying originals
Snapshot bool `yaml:"snapshot-enable"`
}
Knobs regroups a set of qemu boolean settings
type LegacySerialDevice ¶
type LegacySerialDevice struct {
// specify a chardev-id of an existing CharDev, and use the name
ChardevID string `yaml:"chardev-id"`
Name string `yaml:"name"`
MonMux bool `yaml:"mon-mux-enable"`
// Set if needing to multiplex serial and HMP monitor output togeter on stdio
Backend CharDeviceBackend `yaml:"backend"`
Path string `yaml:"path"`
}
LegacySerialDevice represents a qemu legacy serial device.
func (LegacySerialDevice) QemuParams ¶
func (dev LegacySerialDevice) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of this serial device.
func (LegacySerialDevice) Valid ¶
func (dev LegacySerialDevice) Valid() error
Valid returns true if the LegacySerialDevice structure is valid and complete.
type LoaderDevice ¶
LoaderDevice represents a qemu loader device.
func (LoaderDevice) QemuParams ¶
func (dev LoaderDevice) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of this loader device.
func (LoaderDevice) Valid ¶
func (dev LoaderDevice) Valid() error
Valid returns true if there is a valid structure defined for LoaderDevice
type Machine ¶
type Machine struct {
// Type is the machine type to be used by qemu.
Type string `yaml:"type"`
// Acceleration are the machine acceleration options to be used by qemu.
Acceleration string `yaml:"acceleration"`
// Options are options for the machine type
// For example gic-version=host and usb=off
// FIXME: remove this
Options string `yaml:"options"`
// on|off
SMM string `yaml:"smm"`
// KernelIRQChip controls accelerated IRQChip, value is on|off|split
KernelIRQChip string `yaml:"kernel-irq-chip"`
// Emulate VMPort, value is on|off|auto
VMPort string `yaml:"vm-port"`
KVMShadowMemSizeBytes int64 `yaml:"kvm-shadow-mem-size-bytes"`
// on|off
DumpGuestCore string `yaml:"dump-guest-core"`
// on|off
MemoryMerge string `yaml:"memory-merge"`
// on|off
IGDPassthrough string `yaml:"igd-passthrough"`
// on|off
AESKeyWrap string `yaml:"aes-key-wrap"`
// on|off
DEAKeyWrap string `yaml:"dea-key-wrap"`
// on|off
SuppressVMDescription string `yaml:"suppress-vm-description"`
// on|off
NVDIMM string `yaml:"nvdimm"`
// on|off
EnforceConfigSection string `yaml:"enforce-config-section"`
}
Machine describes the machine type qemu will emulate.
type Memory ¶
type Memory struct {
// Size is the amount of memory made available to the guest.
// It should be suffixed with M or G for sizes in megabytes or
// gigabytes respectively.
Size string `yaml:"size-string"`
// Slots is the amount of memory slots made available to the guest.
Slots uint8 `yaml:"slots"`
// MaxMem is the maximum amount of memory that can be made available
// to the guest through e.g. hot pluggable memory.
MaxMem string `yaml:"max-mem-string"`
// Path is the file path of the memory device. It points to a local
// file path used by FileBackedMem.
Path string `yaml:"path"`
}
Memory is the guest memory configuration structure.
type MemoryDevices ¶
type MemoryDevices struct {
Data MemoryDevicesData `json:"data"`
Type string `json:"type"`
}
MemoryDevices represents memory devices of vm
type MemoryDevicesData ¶
type MemoryDevicesData struct {
Slot int `json:"slot"`
Node int `json:"node"`
Addr uint64 `json:"addr"`
Memdev string `json:"memdev"`
ID string `json:"id"`
Hotpluggable bool `json:"hotpluggable"`
Hotplugged bool `json:"hotplugged"`
Size uint64 `json:"size"`
}
MemoryDevicesData cotains the data describes a memory device
type MigrationDisk ¶
type MigrationDisk struct {
Total int64 `json:"total"`
Remaining int64 `json:"remaining"`
Transferred int64 `json:"transferred"`
}
MigrationDisk represents migration disk status
type MigrationRAM ¶
type MigrationRAM struct {
Total int64 `json:"total"`
Remaining int64 `json:"remaining"`
Transferred int64 `json:"transferred"`
TotalTime int64 `json:"total-time"`
SetupTime int64 `json:"setup-time"`
ExpectedDowntime int64 `json:"expected-downtime"`
Duplicate int64 `json:"duplicate"`
Normal int64 `json:"normal"`
NormalBytes int64 `json:"normal-bytes"`
DirtySyncCount int64 `json:"dirty-sync-count"`
}
MigrationRAM represents migration ram status
type MigrationStatus ¶
type MigrationStatus struct {
Status string `json:"status"`
Capabilities []map[string]interface{} `json:"capabilities,omitempty"`
RAM MigrationRAM `json:"ram,omitempty"`
Disk MigrationDisk `json:"disk,omitempty"`
XbzrleCache MigrationXbzrleCache `json:"xbzrle-cache,omitempty"`
}
MigrationStatus represents migration status of a vm
type MigrationXbzrleCache ¶
type MigrationXbzrleCache struct {
CacheSize int64 `json:"cache-size"`
Bytes int64 `json:"bytes"`
Pages int64 `json:"pages"`
CacheMiss int64 `json:"cache-miss"`
CacheMissRate int64 `json:"cache-miss-rate"`
Overflow int64 `json:"overflow"`
}
MigrationXbzrleCache represents migration XbzrleCache status
type MonitorDevice ¶
type MonitorDevice struct {
Name string `yaml:"name"`
ChardevID string `yaml:"chardev-id"`
Backend CharDeviceBackend `yaml:"backend"`
Path string `yaml:"path"`
}
MonitorDevice represents a qemu legacy human monitor device.
func (MonitorDevice) QemuParams ¶
func (dev MonitorDevice) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of this monitor device.
func (MonitorDevice) Valid ¶
func (dev MonitorDevice) Valid() error
Valid returns true if the MonitorDevice structure is valid and complete.
type NetDevice ¶
type NetDevice struct {
// Type is the netdev type (e.g. tap).
Type NetDeviceType `yaml:"type"`
// Driver is the qemu device driver
Driver DeviceDriver `yaml:"driver"`
// ID is the netdevice identifier.
ID string `yaml:"id"`
// Bus is the bus path name of a PCI device.
Bus string `yaml:"bus"`
// Addr is the address offset of a PCI device.
Addr string `yaml:"address"`
// FDs represents the list of already existing file descriptors to be used.
// This is mostly useful for mq support.
FDs []*os.File
VhostFDs []*os.File
// VHost enables virtio device emulation from the host kernel instead of from qemu.
VHost bool `yaml:"vhost-enable"`
// MACAddress is the networking device interface MAC address.
MACAddress string `yaml:"macaddress"`
// DisableModern prevents qemu from relying on fast MMIO.
DisableModern bool `yaml:"disable-modern"`
// ROMFile specifies the ROM file being used for this device.
ROMFile string `yaml:"rom-file"`
// DevNo identifies the ccw devices for s390x architecture
DevNo string `yaml:"ccw-dev-no"`
// Transport is the virtio transport for this device.
Transport VirtioTransport `yaml:"transport"`
// -netdev tap,.*
Tap NetDeviceTap `yaml:"tap-device"`
// -netdev user,.*
User NetDeviceUser `yaml:"user-device"`
// -netdev socket,mcast=
McastSocket NetDeviceMcastSocket `yaml:"mcast-socket"`
// bootindex
BootIndex string `yaml:"bootindex"`
}
NetDevice represents a guest networking device
func (NetDevice) QemuDeviceParams ¶
QemuDeviceParams returns the -device parameters for this network device
func (NetDevice) QemuNetdevParams ¶
QemuNetdevParams returns the -netdev parameters for this network device
func (NetDevice) QemuParams ¶
QemuParams returns the qemu parameters built out of this network device.
type NetDeviceMcastSocket ¶
-netdev socket,listen=
type NetDeviceTap ¶
type NetDeviceTap struct {
// IfName is the interface name,
IFName string `yaml:"ifname"`
// DownScript is the tap interface deconfiguration script.
DownScript string `yaml:"downscript-file"`
// Script is the tap interface configuration script.
Script string `yaml:"upscript-file"`
}
-netdev tap,ifname=,downscript=,script=
type NetDeviceType ¶
type NetDeviceType string
NetDeviceType is a qemu networking device type.
const ( // USER is SLIRP user-space networking device type USER NetDeviceType = "user" // MCASTSOCKET is a socket networking device type MCASTSOCKET NetDeviceType = "mcastsocket" // TAP is a TAP networking device type. TAP NetDeviceType = "tap" // MACVTAP is a macvtap networking device type. MACVTAP NetDeviceType = "macvtap" // IPVTAP is a ipvtap virtual networking device type. IPVTAP NetDeviceType = "ipvtap" // VETHTAP is a veth-tap virtual networking device type. VETHTAP NetDeviceType = "vethtap" // VFIO is a direct assigned PCI device or PCI VF VFIO NetDeviceType = "VFIO" // VHOSTUSER is a vhost-user port (socket) VHOSTUSER NetDeviceType = "vhostuser" DisabledNetDeviceROMFile = "off" )
func (NetDeviceType) QemuDeviceParam ¶
func (n NetDeviceType) QemuDeviceParam(netdev *NetDevice, config *Config) DeviceDriver
QemuDeviceParam converts to the QEMU -device parameter notation
func (NetDeviceType) QemuNetdevParam ¶
func (n NetDeviceType) QemuNetdevParam(netdev *NetDevice, config *Config) string
QemuNetdevParam converts to the QEMU -netdev parameter notation
type NetDeviceUser ¶
type NetDeviceUser struct {
IPV4 bool `yaml:"ipv4-enable"`
IPV4NetAddr string `yaml:"ipv4-network-address"`
HostForward []PortRule `yaml:"host-port-rules"`
}
-netdev user,
type Object ¶
type Object struct {
// Driver is the qemu device driver
Driver DeviceDriver `yaml:"driver"`
// Type is the qemu object type.
Type ObjectType `yaml:"type"`
// ID is the user defined object ID.
ID string `yaml:"id"`
// DeviceID is the user defined device ID.
DeviceID string `yaml:"device-id"`
// MemPath is the object's memory path.
// This is only relevant for memory objects
MemPath string `yaml:"mem-path"`
// Size is the object size in bytes
Size uint64 `yaml:"size-bytes"`
// Debug this is a debug object
Debug bool `yaml:"debug-enable"`
// File is the device file
File string `yaml:"file"`
// CBitPos is the location of the C-bit in a guest page table entry
// This is only relevant for sev-guest objects
CBitPos uint32 `yaml:"c-bit-position"`
// ReducedPhysBits is the reduction in the guest physical address space
// This is only relevant for sev-guest objects
ReducedPhysBits uint32 `yaml:"reduce-phys-bits"`
// ReadOnly specifies whether `MemPath` is opened read-only or read/write (default)
ReadOnly bool `yaml:"read-only"`
// Prealloc enables memory preallocation
Prealloc bool `yaml:"pre-allocate"`
}
Object is a qemu object representation.
func (Object) QemuParams ¶
QemuParams returns the qemu parameters built out of this Object device.
type ObjectType ¶
type ObjectType string
ObjectType is a string representing a qemu object type.
const ( // MemoryBackendFile represents a guest memory mapped file. MemoryBackendFile ObjectType = "memory-backend-file" // MemoryBackendEPC represents a guest memory backend EPC for SGX. MemoryBackendEPC ObjectType = "memory-backend-epc" // TDXGuest represents a TDX object TDXGuest ObjectType = "tdx-guest" // SEVGuest represents an SEV guest object SEVGuest ObjectType = "sev-guest" // SecExecGuest represents an s390x Secure Execution (Protected Virtualization in QEMU) object SecExecGuest ObjectType = "s390-pv-guest" // PEFGuest represent ppc64le PEF(Protected Execution Facility) object. PEFGuest ObjectType = "pef-guest" LegacyMemPath ObjectType = "legacy-mem-path" )
type PCIBus ¶
type PCIBus [PCISlotMax]bool
type PCIeRootPortDevice ¶
type PCIeRootPortDevice struct {
ID string `yaml:"id"` // format: rp{n}, n>=0
Bus string `yaml:"bus"` // default is pcie.0
Chassis string `yaml:"chassis"` // (slot, chassis) pair is mandatory and must be unique for each pcie-root-port, >=0, default is 0x00
Slot string `yaml:"slot"` // >=0, default is 0x00
Port string `yaml:"port"` // specify which port of the PCIeRootBus (pcie.0 bus) to use.
Multifunction bool `yaml:"multifunction"` // true => "on", false => "off", default is off
Addr string `yaml:"addr"` // >=0, default is 0x00
// The PCIE-PCI bridge can be hot-plugged only into pcie-root-port that has 'bus-reserve' property value to
// provide secondary bus for the hot-plugged bridge.
BusReserve string `yaml:"bus-reserve"`
Pref64Reserve string `yaml:"pref64-reserve"` // reserve prefetched MMIO aperture, 64-bit
Pref32Reserve string `yaml:"pref32-reserve"` // reserve prefetched MMIO aperture, 32-bit
MemReserve string `yaml:"memory-reserve"` // reserve non-prefetched MMIO aperture, 32-bit *only*
IOReserve string `yaml:"io-reserve"` // IO reservation
ROMFile string `yaml:"rom-file"` // ROMFile specifies the ROM file being used for this device.
// Transport is the virtio transport for this device.
Transport VirtioTransport `yaml:"transport"`
}
PCIeRootPortDevice represents a memory balloon device.
func (PCIeRootPortDevice) QemuParams ¶
func (b PCIeRootPortDevice) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of the PCIeRootPortDevice.
func (PCIeRootPortDevice) Valid ¶
func (b PCIeRootPortDevice) Valid() error
Valid returns true if the PCIeRootPortDevice structure is valid and complete.
type PVPanicDevice ¶
type PVPanicDevice struct {
NoShutdown bool `yaml:"no-shutdown-enable"`
}
PVPanicDevice represents a qemu pvpanic device.
func (PVPanicDevice) QemuParams ¶
func (dev PVPanicDevice) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of this serial device.
func (PVPanicDevice) Valid ¶
func (dev PVPanicDevice) Valid() error
Valid always returns true for pvpanic device
type PortRule ¶
type QMP ¶
type QMP struct {
// contains filtered or unexported fields
}
QMP is a structure that contains the internal state used by startQMPLoop and the go routines it spwans. All the contents of this structure are private.
func (*QMP) ExecHotplugMemory ¶
func (q *QMP) ExecHotplugMemory(ctx context.Context, qomtype, id, mempath string, size int, share bool) error
ExecHotplugMemory adds size of MiB memory to the guest
func (*QMP) ExecMemdevAdd ¶
func (q *QMP) ExecMemdevAdd(ctx context.Context, qomtype, id, mempath string, size int, share bool, driver, driverID, addr, bus string) error
ExecMemdevAdd adds size of MiB memory device to the guest
func (*QMP) ExecQomGet ¶
ExecQomGet qom-get path property
func (*QMP) ExecQomSet ¶
ExecQomSet qom-set path property value
func (*QMP) ExecQueryCpus ¶
ExecQueryCpus returns a slice with the list of `CpuInfo` Since qemu 2.12, we have `query-cpus-fast` as a better choice in production we can still choose `ExecQueryCpus` for compatibility though not recommended.
func (*QMP) ExecQueryCpusFast ¶
func (q *QMP) ExecQueryCpusFast(ctx context.Context) ([]CPUInfoFast, error)
ExecQueryCpusFast returns a slice with the list of `CpuInfoFast` This is introduced since 2.12, it does not incur a performance penalty and should be used in production instead of query-cpus.
func (*QMP) ExecQueryMemoryDevices ¶
func (q *QMP) ExecQueryMemoryDevices(ctx context.Context) ([]MemoryDevices, error)
ExecQueryMemoryDevices returns a slice with the list of memory devices
func (*QMP) ExecQueryQmpSchema ¶
func (q *QMP) ExecQueryQmpSchema(ctx context.Context) ([]SchemaInfo, error)
ExecQueryQmpSchema query all QMP wire ABI and returns a slice
func (*QMP) ExecSetMigrateArguments ¶
ExecSetMigrateArguments sets the command line used for migration
func (*QMP) ExecSetMigrationCaps ¶
ExecSetMigrationCaps sets migration capabilities
func (*QMP) ExecuteAPVFIOMediatedDeviceAdd ¶
ExecuteAPVFIOMediatedDeviceAdd adds a VFIO mediated AP device to a QEMU instance using the device_add command.
func (*QMP) ExecuteBalloon ¶
ExecuteBalloon sets the size of the balloon, hence updates the memory allocated for the VM.
func (*QMP) ExecuteBlockdevAdd ¶
ExecuteBlockdevAdd sends a blockdev-add to the QEMU instance. device is the path of the device to add, e.g., /dev/rdb0, and blockdevID is an identifier used to name the device. As this identifier will be passed directly to QMP, it must obey QMP's naming rules, e,g., it must start with a letter.
func (*QMP) ExecuteBlockdevAddWithCache ¶
func (q *QMP) ExecuteBlockdevAddWithCache(ctx context.Context, device, blockdevID string, direct, noFlush, ro bool) error
ExecuteBlockdevAddWithCache has two more parameters direct and noFlush than ExecuteBlockdevAdd. They are cache-related options for block devices that are described in https://github.com/qemu/qemu/blob/master/qapi/block-core.json. direct denotes whether use of O_DIRECT (bypass the host page cache) is enabled. noFlush denotes whether flush requests for the device are ignored.
func (*QMP) ExecuteBlockdevAddWithDriverCache ¶
func (q *QMP) ExecuteBlockdevAddWithDriverCache(ctx context.Context, driver, device, blockdevID string, direct, noFlush, ro bool) error
ExecuteBlockdevAddWithDriverCache has three one parameter driver than ExecuteBlockdevAddWithCache. Parameter driver can set the driver of block device.
func (*QMP) ExecuteBlockdevDel ¶
ExecuteBlockdevDel deletes a block device by sending blockdev-del command. blockdevID is the id of the block device to be deleted. Typically, this will match the id passed to ExecuteBlockdevAdd. It must be a valid QMP id.
func (*QMP) ExecuteCPUDeviceAdd ¶
func (q *QMP) ExecuteCPUDeviceAdd(ctx context.Context, driver, cpuID, socketID, dieID, coreID, threadID, romfile string) error
ExecuteCPUDeviceAdd adds a CPU to a QEMU instance using the device_add command. driver is the CPU model, cpuID must be a unique ID to identify the CPU, socketID is the socket number within node/board the CPU belongs to, coreID is the core number within socket the CPU belongs to, threadID is the thread number within core the CPU belongs to. Note that socketID and threadID are not a requirement for architecures like ppc64le.
func (*QMP) ExecuteCharDevUnixSocketAdd ¶
func (q *QMP) ExecuteCharDevUnixSocketAdd(ctx context.Context, id, path string, wait, server bool) error
ExecuteCharDevUnixSocketAdd adds a character device using as backend a unix socket, id is an identifier for the device, path specifies the local path of the unix socket, wait is to block waiting for a client to connect, server specifies that the socket is a listening socket.
func (*QMP) ExecuteChardevDel ¶
ExecuteChardevDel deletes a char device by sending a chardev-remove command. chardevID is the id of the char device to be deleted. Typically, this will match the id passed to ExecuteCharDevUnixSocketAdd. It must be a valid QMP id.
func (*QMP) ExecuteCont ¶
ExecuteCont sends the cont command to the instance.
func (*QMP) ExecuteDeviceAdd ¶
func (q *QMP) ExecuteDeviceAdd(ctx context.Context, blockdevID, devID, driver, bus, romfile string, shared, disableModern bool) error
ExecuteDeviceAdd adds the guest portion of a device to a QEMU instance using the device_add command. blockdevID should match the blockdevID passed to a previous call to ExecuteBlockdevAdd. devID is the id of the device to add. Both strings must be valid QMP identifiers. driver is the name of the driver,e.g., virtio-blk-pci, and bus is the name of the bus. bus is optional. shared denotes if the drive can be shared allowing it to be passed more than once. disableModern indicates if virtio version 1.0 should be replaced by the former version 0.9, as there is a KVM bug that occurs when using virtio 1.0 in nested environments.
func (*QMP) ExecuteDeviceDel ¶
ExecuteDeviceDel deletes guest portion of a QEMU device by sending a device_del command. devId is the identifier of the device to delete. Typically it would match the devID parameter passed to an earlier call to ExecuteDeviceAdd. It must be a valid QMP identidier.
This method blocks until a DEVICE_DELETED event is received for devID.
func (*QMP) ExecuteDumpGuestMemory ¶
func (q *QMP) ExecuteDumpGuestMemory(ctx context.Context, protocol string, paging bool, format string) error
ExecuteDumpGuestMemory dump guest memory to host
func (*QMP) ExecuteGetFD ¶
ExecuteGetFD sends a file descriptor via SCM rights and assigns it a name
func (*QMP) ExecuteMigrationIncoming ¶
ExecuteMigrationIncoming start migration from incoming uri.
func (*QMP) ExecuteNVDIMMDeviceAdd ¶
func (q *QMP) ExecuteNVDIMMDeviceAdd(ctx context.Context, id, mempath string, size int64, pmem *bool) error
ExecuteNVDIMMDeviceAdd adds a block device to a QEMU instance using a NVDIMM driver with the device_add command. id is the id of the device to add. It must be a valid QMP identifier. mempath is the path of the device to add, e.g., /dev/rdb0. size is the data size of the device. pmem is to guarantee the persistence of QEMU writes to the vNVDIMM backend.
func (*QMP) ExecuteNetCCWDeviceAdd ¶
func (q *QMP) ExecuteNetCCWDeviceAdd(ctx context.Context, netdevID, devID, macAddr, bus string, queues int) error
ExecuteNetCCWDeviceAdd adds a Net CCW device to a QEMU instance using the device_add command. devID is the id of the device to add. Must be valid QMP identifier. netdevID is the id of nic added by previous netdev_add. queues is the number of queues of a nic.
func (*QMP) ExecuteNetPCIDeviceAdd ¶
func (q *QMP) ExecuteNetPCIDeviceAdd(ctx context.Context, netdevID, devID, macAddr, addr, bus, romfile string, queues int, disableModern bool) error
ExecuteNetPCIDeviceAdd adds a Net PCI device to a QEMU instance using the device_add command. devID is the id of the device to add. Must be valid QMP identifier. netdevID is the id of nic added by previous netdev_add. queues is the number of queues of a nic. disableModern indicates if virtio version 1.0 should be replaced by the former version 0.9, as there is a KVM bug that occurs when using virtio 1.0 in nested environments.
func (*QMP) ExecuteNetdevAdd ¶
func (q *QMP) ExecuteNetdevAdd(ctx context.Context, netdevType, netdevID, ifname, downscript, script string, queues int) error
ExecuteNetdevAdd adds a Net device to a QEMU instance using the netdev_add command. netdevID is the id of the device to add. Must be valid QMP identifier.
func (*QMP) ExecuteNetdevAddByFds ¶
func (q *QMP) ExecuteNetdevAddByFds(ctx context.Context, netdevType, netdevID string, fdNames, vhostFdNames []string) error
ExecuteNetdevAddByFds adds a Net device to a QEMU instance using the netdev_add command by fds and vhostfds. netdevID is the id of the device to add. Must be valid QMP identifier.
func (*QMP) ExecuteNetdevChardevAdd ¶
func (q *QMP) ExecuteNetdevChardevAdd(ctx context.Context, netdevType, netdevID, chardev string, queues int) error
ExecuteNetdevChardevAdd adds a Net device to a QEMU instance using the netdev_add command. netdevID is the id of the device to add. Must be valid QMP identifier.
func (*QMP) ExecuteNetdevDel ¶
ExecuteNetdevDel deletes a Net device from a QEMU instance using the netdev_del command. netdevID is the id of the device to delete.
func (*QMP) ExecutePCIDeviceAdd ¶
func (q *QMP) ExecutePCIDeviceAdd(ctx context.Context, blockdevID, devID, driver, addr, bus, romfile string, queues int, shared, disableModern bool) error
ExecutePCIDeviceAdd is the PCI version of ExecuteDeviceAdd. This function can be used to hot plug PCI devices on PCI(E) bridges, unlike ExecuteDeviceAdd this function receive the device address on its parent bus. bus is optional. queues specifies the number of queues of a block device. shared denotes if the drive can be shared allowing it to be passed more than once. disableModern indicates if virtio version 1.0 should be replaced by the former version 0.9, as there is a KVM bug that occurs when using virtio 1.0 in nested environments.
func (*QMP) ExecutePCIVFIODeviceAdd ¶
func (q *QMP) ExecutePCIVFIODeviceAdd(ctx context.Context, devID, bdf, addr, bus, romfile string) error
ExecutePCIVFIODeviceAdd adds a VFIO device to a QEMU instance using the device_add command. This function can be used to hot plug VFIO devices on PCI(E) bridges, unlike ExecuteVFIODeviceAdd this function receives the bus and the device address on its parent bus. bus is optional. devID is the id of the device to add.Must be valid QMP identifier. bdf is the PCI bus-device-function of the pci device.
func (*QMP) ExecutePCIVFIOMediatedDeviceAdd ¶
func (q *QMP) ExecutePCIVFIOMediatedDeviceAdd(ctx context.Context, devID, sysfsdev, addr, bus, romfile string) error
ExecutePCIVFIOMediatedDeviceAdd adds a VFIO mediated device to a QEMU instance using the device_add command. This function can be used to hot plug VFIO mediated devices on PCI(E) bridges or root bus, unlike ExecuteVFIODeviceAdd this function receives the bus and the device address on its parent bus. devID is the id of the device to add. Must be valid QMP identifier. sysfsdev is the VFIO mediated device. Both bus and addr are optional. If they are both set to be empty, the system will pick up an empty slot on root bus.
func (*QMP) ExecutePCIVSockAdd ¶
func (q *QMP) ExecutePCIVSockAdd(ctx context.Context, id, guestCID, vhostfd, addr, bus, romfile string, disableModern bool) error
ExecutePCIVSockAdd adds a vhost-vsock-pci bus disableModern indicates if virtio version 1.0 should be replaced by the former version 0.9, as there is a KVM bug that occurs when using virtio 1.0 in nested environments.
func (*QMP) ExecutePCIVhostUserDevAdd ¶
func (q *QMP) ExecutePCIVhostUserDevAdd(ctx context.Context, driver, devID, chardevID, addr, bus string) error
ExecutePCIVhostUserDevAdd adds a vhost-user device to a QEMU instance using the device_add command. This function can be used to hot plug vhost-user devices on PCI(E) bridges. It receives the bus and the device address on its parent bus. bus is optional. devID is the id of the device to add.Must be valid QMP identifier. chardevID is the QMP identifier of character device using a unix socket as backend. driver is the name of vhost-user driver, like vhost-user-blk-pci.
func (*QMP) ExecuteQMPCapabilities ¶
ExecuteQMPCapabilities executes the qmp_capabilities command on the instance.
func (*QMP) ExecuteQueryHotpluggableCPUs ¶
func (q *QMP) ExecuteQueryHotpluggableCPUs(ctx context.Context) ([]HotpluggableCPU, error)
ExecuteQueryHotpluggableCPUs returns a slice with the list of hotpluggable CPUs
func (*QMP) ExecuteQueryMigration ¶
func (q *QMP) ExecuteQueryMigration(ctx context.Context) (MigrationStatus, error)
ExecuteQueryMigration queries migration progress.
func (*QMP) ExecuteQueryStatus ¶
func (q *QMP) ExecuteQueryStatus(ctx context.Context) (StatusInfo, error)
ExecuteQueryStatus queries guest status
func (*QMP) ExecuteQuit ¶
ExecuteQuit sends the quit command to the instance, terminating the QMP instance immediately.
func (*QMP) ExecuteSCSIDeviceAdd ¶
func (q *QMP) ExecuteSCSIDeviceAdd(ctx context.Context, blockdevID, devID, driver, bus, romfile string, scsiID, lun int, shared, disableModern bool) error
ExecuteSCSIDeviceAdd adds the guest portion of a block device to a QEMU instance using a SCSI driver with the device_add command. blockdevID should match the blockdevID passed to a previous call to ExecuteBlockdevAdd. devID is the id of the device to add. Both strings must be valid QMP identifiers. driver is the name of the scsi driver,e.g., scsi-hd, and bus is the name of a SCSI controller bus. scsiID is the SCSI id, lun is logical unit number. scsiID and lun are optional, a negative value for scsiID and lun is ignored. shared denotes if the drive can be shared allowing it to be passed more than once. disableModern indicates if virtio version 1.0 should be replaced by the former version 0.9, as there is a KVM bug that occurs when using virtio 1.0 in nested environments.
func (*QMP) ExecuteStop ¶
ExecuteStop sends the stop command to the instance.
func (*QMP) ExecuteSystemPowerdown ¶
ExecuteSystemPowerdown sends the system_powerdown command to the instance. This function will block until the SHUTDOWN event is received.
func (*QMP) ExecuteVFIODeviceAdd ¶
ExecuteVFIODeviceAdd adds a VFIO device to a QEMU instance using the device_add command. devID is the id of the device to add. Must be valid QMP identifier. bdf is the PCI bus-device-function of the pci device. bus is optional. When hot plugging a PCIe device, the bus can be the ID of the pcie-root-port.
func (*QMP) ExecuteVirtSerialPortAdd ¶
ExecuteVirtSerialPortAdd adds a virtserialport. id is an identifier for the virtserialport, name is a name for the virtserialport and it will be visible in the VM, chardev is the character device id previously added.
func (*QMP) Shutdown ¶
func (q *QMP) Shutdown()
Shutdown closes the domain socket used to monitor a QEMU instance and terminates all the go routines spawned by QMPStart to manage that instance. QMP.Shutdown does not shut down the running instance. Calling QMP.Shutdown will result in the disconnectedCh channel being closed, indicating that we have lost connection to the QMP instance. In this case it does not indicate that the instance has quit.
QMP.Shutdown should not be called concurrently with other QMP methods. It should not be called twice on the same QMP instance.
Calling QMP.Shutdown after the disconnectedCh channel is closed is permitted but will not have any effect.
type QMPConfig ¶
type QMPConfig struct {
// eventCh can be specified by clients who wish to receive QMP
// events.
EventCh chan<- QMPEvent
// logger is used by the qmpStart function and all the go routines
// it spawns to log information.
Logger QMPLog
// specify the capacity of buffer used by receive QMP response.
MaxCapacity int
}
QMPConfig is a configuration structure that can be used to specify a logger and a channel to which logs and QMP events are to be sent. If neither of these fields are specified, or are set to nil, no logs will be written and no QMP events will be reported to the client.
type QMPEvent ¶
type QMPEvent struct {
// The name of the event, e.g., DEVICE_DELETED
Name string
// The data associated with the event. The contents of this map are
// unprocessed by the qemu package. It is simply the result of
// unmarshalling the QMP json event. Here's an example map
// map[string]interface{}{
// "driver": "virtio-blk-pci",
// "drive": "drive_3437843748734873483",
// }
Data map[string]interface{}
// The event's timestamp converted to a time.Time object.
Timestamp time.Time
}
QMPEvent contains a single QMP event, sent on the QMPConfig.EventCh channel.
type QMPLog ¶
type QMPLog interface {
// V returns true if the given argument is less than or equal
// to the implementation's defined verbosity level.
V(int32) bool
// Infof writes informational output to the log. A newline will be
// added to the output if one is not provided.
Infof(string, ...interface{})
// Warningf writes warning output to the log. A newline will be
// added to the output if one is not provided.
Warningf(string, ...interface{})
// Errorf writes error output to the log. A newline will be
// added to the output if one is not provided.
Errorf(string, ...interface{})
}
QMPLog is a logging interface used by the qemu package to log various interesting pieces of information. Rather than introduce a dependency on a given logging package, qemu presents this interface that allows clients to provide their own logging type which they can use to seamlessly integrate qemu's logs into their own logs. A QMPLog implementation can be specified in the QMPConfig structure.
type QMPSocket ¶
type QMPSocket struct {
// Type is the socket type (e.g. "unix").
Type QMPSocketType `yaml:"type" default:"unix"`
// Name is the socket name.
Name string `yaml:"name"`
// Server tells if this is a server socket.
Server bool `yaml:"server"`
// NoWait tells if qemu should block waiting for a client to connect.
NoWait bool `yaml:"no-wait"`
}
QMPSocket represents a qemu QMP socket configuration.
type QMPSocketType ¶
type QMPSocketType string
QMPSocketType is the type of socket used for QMP communication.
const ( // Unix socket for QMP. Unix QMPSocketType = "unix" )
type QMPVersion ¶
QMPVersion contains the version number and the capabailities of a QEMU instance, as reported in the QMP greeting message.
type QemuIndex ¶
type QemuIndex struct {
// contains filtered or unexported fields
}
func NewQemuIndex ¶
func NewQemuIndex() *QemuIndex
type QemuTypeIndex ¶
func NewQemuTypeIndex ¶
func NewQemuTypeIndex() *QemuTypeIndex
func (QemuTypeIndex) Next ¶
func (qti QemuTypeIndex) Next(qtype string) int
func (QemuTypeIndex) NextBootIndex ¶
func (qti QemuTypeIndex) NextBootIndex() int
func (QemuTypeIndex) NextDriveIndex ¶
func (qti QemuTypeIndex) NextDriveIndex() int
func (QemuTypeIndex) NextNetIndex ¶
func (qti QemuTypeIndex) NextNetIndex() int
func (QemuTypeIndex) SetBootIndex ¶
func (qti QemuTypeIndex) SetBootIndex(index int) error
func (QemuTypeIndex) SetDriveIndex ¶
func (qti QemuTypeIndex) SetDriveIndex(index int) error
func (QemuTypeIndex) SetNetIndex ¶
func (qti QemuTypeIndex) SetNetIndex(index int) error
type RTC ¶
type RTC struct {
// Base is the RTC start time.
Base RTCBaseType
// Clock is the is the RTC clock driver.
Clock RTCClock
// DriftFix is the drift fixing mechanism.
DriftFix RTCDriftFix
}
RTC represents a qemu Real Time Clock configuration.
type RTCBaseType ¶
type RTCBaseType string
RTCBaseType is the qemu RTC base time type.
const ( // UTC is the UTC base time for qemu RTC. UTC RTCBaseType = "utc" // LocalTime is the local base time for qemu RTC. LocalTime RTCBaseType = "localtime" )
type RTCDriftFix ¶
type RTCDriftFix string
RTCDriftFix is the qemu RTC drift fix type.
const ( // Slew is the qemu RTC Drift fix mechanism. Slew RTCDriftFix = "slew" // NoDriftFix means we don't want/need to fix qemu's RTC drift. NoDriftFix RTCDriftFix = "none" )
type RngDevice ¶
type RngDevice struct {
// ID is the device ID
ID string `yaml:"id"`
// Driver is the device driver
Driver DeviceDriver `yaml:"driver"`
// Bus is the bus path name of a this device.
Bus string `yaml:"bus"`
// Addr is the address offset of this device on the bus.
Addr string `yaml:"address"`
// Filename is entropy source on the host
Filename string `yaml:"filename"`
// MaxBytes is the bytes allowed to guest to get from the host’s entropy per period
MaxBytes uint `yaml:"max-bytes"`
// Period is duration of a read period in seconds
Period uint `yaml:"period"`
// ROMFile specifies the ROM file being used for this device.
ROMFile string `yaml:"rom-file"`
// DevNo identifies the ccw devices for s390x architecture
DevNo string `yaml:"ccw-dev-no"`
// Transport is the virtio transport for this device.
Transport VirtioTransport `yaml:"transport"`
}
RngDevice represents a random number generator device.
func (RngDevice) QemuParams ¶
QemuParams returns the qemu parameters built out of the RngDevice.
type RunState ¶
type RunState int
const ( RunStateDebug RunState = iota RunStateFinishMigrate RunStateInMigrate RunStateInternalError RunStateIOError RunStatePaused RunStatePostMigrate RunStatePreLaunch RunStateRestoreVM RunStateRunning RunStateSaveVM RunStateShutdown RunStateSuspended RunStateWatchdog RunStateGuestPanicked RunStateColo RunStateUnknown )
func ToRunState ¶
type SCSIControllerDevice ¶
type SCSIControllerDevice struct {
ID string `yaml:"id"`
// Bus on which the SCSI controller is attached, this is optional
Bus string `yaml:"bus,omitempty"`
// Addr is the PCI address offset, this is optional
Addr string `yaml:"addr,omitempty"`
// DisableModern prevents qemu from relying on fast MMIO.
DisableModern bool `yaml:"disable-modern,omitempty"`
// IOThread is the IO thread on which IO will be handled
IOThread string `yaml:"iothread,omitempty"`
// IOThread object tunables
IOThreadPoll int `yaml:"iothread-poll,omitempty"`
IOThreadMaxNS int `yaml:"iothread-max-ns,omitempty"`
IOThreadShrink int `yaml:"iothread-shrink,omitempty"`
// ROMFile specifies the ROM file being used for this device.
ROMFile string `yaml:"romfile,omitempty"`
// DevNo identifies the ccw devices for s390x architecture
DevNo string `yaml:"devno,omitempty"`
// Transport is the virtio transport for this device.
Transport VirtioTransport
}
SCSIController represents a SCSI controller device.
func (SCSIControllerDevice) QemuParams ¶
func (scsiCon SCSIControllerDevice) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of this SCSIController device.
func (SCSIControllerDevice) Valid ¶
func (scsiCon SCSIControllerDevice) Valid() error
Valid returns true if the SCSIController structure is valid and complete.
type SMBIOSInfo ¶
type SMBIOSInfo struct {
File string `yaml:"file,omitempty"` // -smbios file
BIOS SMTableBIOS `yaml:"bios,omitempty"` // -smbios type=0
System SMTableSystem `yaml:"system,omitempty"` // -smbios type=1
Baseboard SMTableBaseboard `yaml:"baseboard,omitempty"` // -smbios type=2
Chassis SMTableChassis `yaml:"chassis,omitempty"` // -smbios type=3
Processors []SMTableProcessor `yaml:"processors,omitempty"` // -smbios type=4
Memory []SMTableMemory `yaml:"memory,omitempty"` // -smbios type=17
}
func (SMBIOSInfo) QemuParams ¶
func (smb SMBIOSInfo) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of the SMBIOSInfo object
func (SMBIOSInfo) Valid ¶
func (smb SMBIOSInfo) Valid() error
Valid returns true if the SMBIOSInfo structure is valid and complete.
type SMP ¶
type SMP struct {
// CPUs is the number of VCPUs made available to qemu.
CPUs uint32 `yaml:"cpus"`
// Cores is the number of cores made available to qemu.
Cores uint32 `yaml:"cores"`
// Threads is the number of threads made available to qemu.
Threads uint32 `yaml:"threads"`
// Sockets is the number of sockets made available to qemu.
Sockets uint32 `yaml:"sockets"`
// MaxCPUs is the maximum number of VCPUs that a VM can have.
// This value, if non-zero, MUST BE equal to or greater than CPUs
MaxCPUs uint32 `yaml:"max-cpus"`
}
SMP is the multi processors configuration structure.
type SMTableBIOS ¶
type SMTableBIOS struct {
Vendor string `yaml:"vendor,omitempty"`
Version string `yaml:"version,omitempty"`
Date string `yaml:"date,omitempty"`
Release string `yaml:"release,omitempty"`
UEFI string `yaml:"uefi,omitempty"`
}
func (SMTableBIOS) QemuParams ¶
func (table SMTableBIOS) QemuParams(config *Config) []string
func (SMTableBIOS) Valid ¶
func (table SMTableBIOS) Valid() error
type SMTableBaseboard ¶
type SMTableBaseboard struct {
Manufacturer string `yaml:"manufacturer,omitempty"`
Product string `yaml:"product,omitempty"`
Version string `yaml:"version,omitempty"`
Serial string `yaml:"serial,omitempty"`
Asset string `yaml:"asset,omitempty"`
Location string `yaml:"location,omitempty"`
}
func (SMTableBaseboard) QemuParams ¶
func (table SMTableBaseboard) QemuParams(config *Config) []string
func (SMTableBaseboard) Valid ¶
func (table SMTableBaseboard) Valid() error
type SMTableChassis ¶
type SMTableChassis struct {
Manufacturer string `yaml:"manufacturer,omitempty"`
Version string `yaml:"version,omitempty"`
Serial string `yaml:"serial,omitempty"`
Asset string `yaml:"asset,omitempty"`
SKU string `yaml:"sku,omitempty"`
}
func (SMTableChassis) QemuParams ¶
func (table SMTableChassis) QemuParams(config *Config) []string
func (SMTableChassis) Valid ¶
func (table SMTableChassis) Valid() error
type SMTableMemory ¶
type SMTableMemory struct {
LocationPrefix string `yaml:"location-prefix,omitempty"`
Bank string `yaml:"bank,omitempty"`
Manufacturer string `yaml:"manufacturer,omitempty"`
Serial string `yaml:"serial,omitempty"`
Asset string `yaml:"asset,omitempty"`
Part string `yaml:"part,omitempty"`
Speed string `yaml:"speed,omitempty"`
}
func (SMTableMemory) QemuParams ¶
func (table SMTableMemory) QemuParams(config *Config) []string
func (SMTableMemory) Valid ¶
func (table SMTableMemory) Valid() error
type SMTableProcessor ¶
type SMTableProcessor struct {
SocketPrefix string `yaml:"socket-prefix,omitempty"`
Manufacturer string `yaml:"manufacturer,omitempty"`
Version string `yaml:"version,omitempty"`
Serial string `yaml:"serial,omitempty"`
Asset string `yaml:"asset,omitempty"`
Part string `yaml:"part,omitempty"`
}
func (SMTableProcessor) QemuParams ¶
func (table SMTableProcessor) QemuParams(config *Config) []string
func (SMTableProcessor) Valid ¶
func (table SMTableProcessor) Valid() error
type SMTableSystem ¶
type SMTableSystem struct {
Manufacturer string `yaml:"manufacturer,omitempty"`
Product string `yaml:"product,omitempty"`
Version string `yaml:"version,omitempty"`
Serial string `yaml:"serial,omitempty"`
UUID string `yaml:"uuid,omitempty"`
SKU string `yaml:"sku,omitempty"`
Family string `yaml:"family,omitempty"`
}
func (SMTableSystem) QemuParams ¶
func (table SMTableSystem) QemuParams(config *Config) []string
func (SMTableSystem) Valid ¶
func (table SMTableSystem) Valid() error
type SchemaInfo ¶
SchemaInfo represents all QMP wire ABI
type SecurityModelType ¶
type SecurityModelType string
SecurityModelType is a qemu filesystem security model type.
const ( // None is like passthrough without failure reports. None SecurityModelType = "none" // PassThrough uses the same credentials on both the host and guest. PassThrough SecurityModelType = "passthrough" // MappedXattr stores some files attributes as extended attributes. MappedXattr SecurityModelType = "mapped-xattr" // MappedFile stores some files attributes in the .virtfs directory. MappedFile SecurityModelType = "mapped-file" )
type SerialDevice ¶
type SerialDevice struct {
// Driver is the qemu device driver
Driver DeviceDriver
// ID is the serial device identifier.
ID string
// PCI Slot
Addr string
// ROMFile specifies the ROM file being used for this device.
ROMFile string
// MaxPorts is the maximum number of ports for this device. (note: 1, 2, or 4 for pci-serial driver)
MaxPorts uint
//Enable Multifunction
Multifunction bool
//virtio-serial specific attributes
// DisableModern prevents qemu from relying on fast MMIO.
DisableModern bool
// DevNo identifies the ccw devices for s390x architecture
DevNo string
// Transport is the virtio transport for this device.
Transport VirtioTransport
//pci-serial specific attributes
//Chardev associated with PCISerialDevice
ChardevIDs []string
}
SerialDevice represents a qemu serial device.
func (SerialDevice) QemuParams ¶
func (dev SerialDevice) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of this serial device.
func (SerialDevice) Valid ¶
func (dev SerialDevice) Valid() error
Valid returns true if the SerialDevice structure is valid and complete.
type SpiceDevice ¶
type SpiceDevice struct {
ID string `yaml:"id"`
Port string `yaml:"port"`
HostAddress string `yaml:"host-address"`
TLSPort string `yaml:"tls-port"`
DisableTicketing bool `yaml:"disable-ticketing"`
}
SpiceDevice represents a qemu spice protocol device.
func (SpiceDevice) QemuParams ¶
func (dev SpiceDevice) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of this spice device.
func (SpiceDevice) Valid ¶
func (dev SpiceDevice) Valid() error
Valid returns true if there is a valid structure defined for SpiceDevice
type StatusInfo ¶
type StatusInfo struct {
Running bool `json:"running"`
SingleStep bool `json:"singlestep"`
Status string `json:"status"`
}
StatusInfo represents guest running status
type TPMDevice ¶
type TPMDevice struct {
ID string `yaml:"id"`
Driver DeviceDriver `yaml:"driver"`
Type string `yaml:"type"`
Path string `yaml:"path,omitempty"`
}
TPM represents a qemu tpm device.
func (TPMDevice) QemuParams ¶
QemuParams returns the qemu parameters built out of this tpm device.
type UEFIFirmwareDevice ¶
func NewSystemUEFIFirmwareDevice ¶
func NewSystemUEFIFirmwareDevice(useSecureBoot bool) (*UEFIFirmwareDevice, error)
NewSystemUEFIFirmwareDevice looks at the local system to collect expected OVMF firmware files, callers will need to make a copy of the of the Vars template file before using it in a running VM.
func (UEFIFirmwareDevice) Exists ¶
func (u UEFIFirmwareDevice) Exists() (bool, error)
func (UEFIFirmwareDevice) Is4MB ¶
func (u UEFIFirmwareDevice) Is4MB() bool
func (UEFIFirmwareDevice) IsSecureBoot ¶
func (u UEFIFirmwareDevice) IsSecureBoot() bool
func (UEFIFirmwareDevice) QemuParams ¶
func (u UEFIFirmwareDevice) QemuParams(config *Config) []string
func (UEFIFirmwareDevice) Valid ¶
func (u UEFIFirmwareDevice) Valid() error
type USBControllerDevice ¶
type USBControllerDevice struct {
ID string `yaml:"id"`
Driver DeviceDriver `yaml:"driver"`
Addr string `yaml:"addr,omitempty"`
FailoverPairID string `yaml:"failover-pair-id,omitempty"`
ROMFile string `yaml:"romfile,omitempty"`
ROMBar string `yaml:"rombar,omitempty"`
Multifunction bool `yaml:"multifunction,omitempty"`
XPCIELinkStateDLLLA bool `yaml:"x-pcie-lnksta-dllla,omitempty"`
XPCIeExternalCapInit bool `yaml:"x-pcie-extcap-init,omitempty"`
CommandSerrEnable bool `yaml:"command-seer-enable,omitempty"`
}
USBController represents an USB controller device.
func (USBControllerDevice) QemuParams ¶
func (usbCon USBControllerDevice) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of this USBController device.
func (USBControllerDevice) Valid ¶
func (usbCon USBControllerDevice) Valid() error
Valid returns true if the USBController structure is valid and complete.
type VFIODevice ¶
type VFIODevice struct {
// Bus-Device-Function of device
BDF string
// ROMFile specifies the ROM file being used for this device.
ROMFile string
// DevNo identifies the ccw devices for s390x architecture
DevNo string
// VendorID specifies vendor id
VendorID string
// DeviceID specifies device id
DeviceID string
// Bus specifies device bus
Bus string
// Transport is the virtio transport for this device.
Transport VirtioTransport
}
VFIODevice represents a qemu vfio device meant for direct access by guest OS.
func (VFIODevice) QemuParams ¶
func (vfioDev VFIODevice) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of this vfio device.
func (VFIODevice) Valid ¶
func (vfioDev VFIODevice) Valid() error
Valid returns true if the VFIODevice structure is valid and complete.
type VMConfigContainer ¶
type VMConfigContainer struct {
VMConfig Config `yaml:"config"`
}
VMConfigContainer holds a single VM config
type VSOCKDevice ¶
type VSOCKDevice struct {
ID string
ContextID uint64
// VHostFD vhost file descriptor that holds the ContextID
VHostFD *os.File
// DisableModern prevents qemu from relying on fast MMIO.
DisableModern bool
// ROMFile specifies the ROM file being used for this device.
ROMFile string
// DevNo identifies the ccw devices for s390x architecture
DevNo string
// Transport is the virtio transport for this device.
Transport VirtioTransport
}
VSOCKDevice represents a AF_VSOCK socket.
func (VSOCKDevice) QemuParams ¶
func (vsock VSOCKDevice) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of the VSOCK device.
func (VSOCKDevice) Valid ¶
func (vsock VSOCKDevice) Valid() error
Valid returns true if the VSOCKDevice structure is valid and complete.
type VhostUserDevice ¶
type VhostUserDevice struct {
SocketPath string //path to vhostuser socket on host
CharDevID string
TypeDevID string //variable QEMU parameter based on value of VhostUserType
Address string //used for MAC address in net case
Tag string //virtio-fs volume id for mounting inside guest
CacheSize uint32 //virtio-fs DAX cache size in MiB
VhostUserType DeviceDriver
// ROMFile specifies the ROM file being used for this device.
ROMFile string
// DevNo identifies the CCW device for s390x.
DevNo string
// Transport is the virtio transport for this device.
Transport VirtioTransport
}
VhostUserDevice represents a qemu vhost-user device meant to be passed in to the guest
func (VhostUserDevice) QemuBlkParams ¶
func (vhostuserDev VhostUserDevice) QemuBlkParams(config *Config) []string
QemuBlkParams builds QEMU device parameters for a VhostUserBlk device
func (VhostUserDevice) QemuFSParams ¶
func (vhostuserDev VhostUserDevice) QemuFSParams(config *Config) []string
QemuFSParams builds QEMU device parameters for a VhostUserFS device
func (VhostUserDevice) QemuNetParams ¶
func (vhostuserDev VhostUserDevice) QemuNetParams(config *Config) []string
QemuNetParams builds QEMU netdev and device parameters for a VhostUserNet device
func (VhostUserDevice) QemuParams ¶
func (vhostuserDev VhostUserDevice) QemuParams(config *Config) []string
QemuParams returns the qemu parameters built out of this vhostuser device.
func (VhostUserDevice) QemuSCSIParams ¶
func (vhostuserDev VhostUserDevice) QemuSCSIParams(config *Config) []string
QemuSCSIParams builds QEMU device parameters for a VhostUserSCSI device
func (VhostUserDevice) Valid ¶
func (vhostuserDev VhostUserDevice) Valid() error
Valid returns true if there is a valid structure defined for VhostUserDevice
type Virtio9PMultidev ¶
type Virtio9PMultidev string
Virtio9PMultidev filesystem behaviour to deal with multiple devices being shared with a 9p export.
const ( // Remap shares multiple devices with only one export. Remap Virtio9PMultidev = "remap" // Warn assumes that only one device is shared by the same export. // Only a warning message is logged (once) by qemu on host side. // This is the default behaviour. Warn Virtio9PMultidev = "warn" // Forbid like "warn" but also deny access to additional devices on guest. Forbid Virtio9PMultidev = "forbid" )
type VirtioTransport ¶
type VirtioTransport string
VirtioTransport is the transport in use for a virtio device.
const ( // TransportPCI is the PCI transport for virtio device. TransportPCI VirtioTransport = "pci" // TransportCCW is the CCW transport for virtio devices. TransportCCW VirtioTransport = "ccw" // TransportMMIO is the MMIO transport for virtio devices. TransportMMIO VirtioTransport = "mmio" )
Source Files
¶
- balloondevice.go
- blockdev.go
- bridgedevice.go
- chardevice.go
- device.go
- fsdev.go
- fwcfg.go
- ide-controller.go
- image.go
- iommu.go
- loaderdevice.go
- machine.go
- monitor.go
- netdevice.go
- object.go
- pciexpress.go
- pvpanic.go
- qemu.go
- qemuindex.go
- qmp.go
- qmpsocket.go
- rngdevice.go
- rtc.go
- runstate.go
- scsi-controller.go
- serialdevice.go
- smbios.go
- spice.go
- tpm.go
- uefi.go
- usb-controller.go
- utils.go
- vfiodevice.go
- vhost.go
- virtio-transport.go
- vsockdevice.go