Documentation
¶
Index ¶
- Variables
- type AMDSEVCapabilities
- type AddFdInfo
- type BlockStats
- type CPU
- type CPUInstanceProperties
- type CPUModel
- type ChardevChangeInfo
- type FdsetFdInfo
- type FdsetInfo
- type HotpluggableCPU
- type MemDev
- type MemoryDevice
- type MigrationStatus
- type Monitor
- func (m *Monitor) AddBlockDevice(blockDev map[string]any, device map[string]any, attached bool, usb bool) error
- func (m *Monitor) AddCharDevice(device map[string]any) error
- func (m *Monitor) AddDevice(device map[string]any) error
- func (m *Monitor) AddNIC(netDev map[string]any, device map[string]any) error
- func (m *Monitor) AddObject(args map[string]any) error
- func (m *Monitor) AddSecret(id string, secret string) error
- func (m *Monitor) AgenStarted() bool
- func (m *Monitor) BlockCommit(deviceNodeName string) error
- func (m *Monitor) BlockDevMirror(deviceNodeName string, targetNodeName string) error
- func (m *Monitor) BlockDevSnapshot(deviceNodeName string, snapshotNodeName string) error
- func (m *Monitor) BlockJobCancel(deviceNodeName string) error
- func (m *Monitor) BlockJobComplete(deviceNodeName string) error
- func (m *Monitor) ChardevChange(device string, info ChardevChangeInfo) error
- func (m *Monitor) CheckPCIDevice(deviceID string) (bool, error)
- func (m *Monitor) CloseFile(name string) error
- func (m *Monitor) Disconnect()
- func (m *Monitor) DumpGuestMemory(path string, format string) error
- func (m *Monitor) GetBlockStats() (map[string]BlockStats, error)
- func (m *Monitor) GetCPUs() ([]int, error)
- func (m *Monitor) GetDimmDevices() ([]PCDimmDevice, error)
- func (m *Monitor) GetMemdev() ([]MemDev, error)
- func (m *Monitor) GetMemoryBalloonSizeBytes() (int64, error)
- func (m *Monitor) GetMemoryDevices() ([]MemoryDevice, error)
- func (m *Monitor) GetMemorySizeBytes() (int64, error)
- func (m *Monitor) IncreaseID() uint32
- func (m *Monitor) MachineDefinition() (string, error)
- func (m *Monitor) Migrate(name string) error
- func (m *Monitor) MigrateContinue(fromState string) error
- func (m *Monitor) MigrateIncoming(ctx context.Context, name string) error
- func (m *Monitor) MigrateSetCapabilities(caps map[string]bool) error
- func (m *Monitor) MigrateSetParameters(parameters map[string]any) error
- func (m *Monitor) MigrateWait(state string) error
- func (m *Monitor) NBDBlockExportAdd(deviceNodeName string) error
- func (m *Monitor) NBDServerStart() (net.Conn, error)
- func (m *Monitor) NBDServerStop() error
- func (m *Monitor) Pause() error
- func (m *Monitor) Powerdown() error
- func (m *Monitor) QueryCPUModel(model string) (*CPUModel, error)
- func (m *Monitor) QueryCPUs() ([]CPU, error)
- func (m *Monitor) QueryHotpluggableCPUs() ([]HotpluggableCPU, error)
- func (m *Monitor) QueryMigrate() (*MigrationStatus, error)
- func (m *Monitor) QueryPCI() ([]PCIDevice, error)
- func (m *Monitor) Quit() error
- func (m *Monitor) RemoveBlockDevice(blockDevName string) error
- func (m *Monitor) RemoveCharDevice(deviceID string) error
- func (m *Monitor) RemoveDevice(deviceID string) error
- func (m *Monitor) RemoveFDFromFDSet(name string) error
- func (m *Monitor) RemoveNIC(netDevID string) error
- func (m *Monitor) Reset() error
- func (m *Monitor) RingbufRead(device string) (string, error)
- func (m *Monitor) Run(cmd string, args any, resp any) error
- func (m *Monitor) RunJSON(request []byte, resp any, logCommand bool, id uint32) error
- func (m *Monitor) SEVCapabilities() (AMDSEVCapabilities, error)
- func (m *Monitor) Screendump(filename string) error
- func (m *Monitor) SendFile(name string, file *os.File) error
- func (m *Monitor) SendFileWithFDSet(name string, file *os.File, readonly bool) (*AddFdInfo, error)
- func (m *Monitor) SetAction(actions map[string]string) error
- func (m *Monitor) SetBlockThrottle(id string, bytesRead int, bytesWrite int, iopsRead int, iopsWrite int) error
- func (m *Monitor) SetMemoryBalloonSizeBytes(sizeBytes int64) error
- func (m *Monitor) SetOnDisconnectEvent(enable bool)
- func (m *Monitor) Start() error
- func (m *Monitor) Status() (string, error)
- func (m *Monitor) UpdateBlockSize(id string) error
- func (m *Monitor) Wait() (chan struct{}, error)
- type PCDimmDevice
- type PCIBridge
- type PCIClassInfo
- type PCIDevice
Constants ¶
This section is empty.
Variables ¶
var ErrMonitorBadConsole = errors.New("Requested console couldn't be found")
ErrMonitorBadConsole is returned when the requested console doesn't exist.
var ErrMonitorDisconnect = errors.New("Monitor is disconnected")
ErrMonitorDisconnect is returned when interacting with a disconnected Monitor.
var ErrNotARingbuf = errors.New("Requested device isn't a ring buffer")
ErrNotARingbuf is returned when the requested device isn't a ring buffer.
var EventAgentStarted = "AGENT-STARTED"
EventAgentStarted is the event sent once the agent has started.
var EventDiskEjected = "DEVICE_TRAY_MOVED"
EventDiskEjected is used to indicate that a disk device was ejected by the guest.
var EventRTCChange = "RTC_CHANGE"
EventRTCChange is used to get RTC adjustment.
var EventVMShutdown = "SHUTDOWN"
EventVMShutdown is the event sent when VM guest shuts down.
var EventVMShutdownReasonDisconnect = "disconnect"
EventVMShutdownReasonDisconnect is used as the reason when the shutdown event is triggered by a QMP disconnect.
var ExcludedCommands = []string{"ringbuf-read"}
ExcludedCommands is used to filter verbose commands from the QMP logs.
var RingbufSize = 16
RingbufSize is the size of the agent serial ringbuffer in bytes.
Functions ¶
This section is empty.
Types ¶
type AMDSEVCapabilities ¶
type AMDSEVCapabilities struct { PDH string `json:"pdh"` // Platform Diffie-Hellman key (base64-encoded) CertChain string `json:"cert-chain"` // PDH certificate chain (base64-encoded) CPU0Id string `json:"cpu0-id"` // Unique ID of CPU0 (base64-encoded) CBitPos int `json:"cbitpos"` // C-bit location in page table entry ReducedPhysBits int `json:"reduced-phys-bits"` // Number of physical address bit reduction when SEV is enabled }
AMDSEVCapabilities represents the SEV capabilities of QEMU.
type AddFdInfo ¶
AddFdInfo contains information about a file descriptor that was added to an fd set.
type BlockStats ¶
type BlockStats struct { BytesWritten int `json:"wr_bytes"` WritesCompleted int `json:"wr_operations"` BytesRead int `json:"rd_bytes"` ReadsCompleted int `json:"rd_operations"` }
BlockStats represents block device stats.
type CPU ¶
type CPU struct { Index int `json:"cpu-index,omitempty"` QOMPath string `json:"qom-path,omitempty"` ThreadID int `json:"thread-id,omitempty"` Target string `json:"target,omitempty"` Props CPUInstanceProperties `json:"props"` }
CPU contains information about a CPU.
type CPUInstanceProperties ¶
type CPUInstanceProperties struct { NodeID int `json:"node-id,omitempty"` SocketID int `json:"socket-id,omitempty"` DieID int `json:"die-id,omitempty"` ClusterID int `json:"cluster-id,omitempty"` CoreID int `json:"core-id,omitempty"` ThreadID int `json:"thread-id,omitempty"` }
CPUInstanceProperties contains CPU instance properties.
type ChardevChangeInfo ¶ added in v6.0.3
type ChardevChangeInfo struct { Type string `json:"type"` File *os.File `json:"file,omitempty"` FDName string `json:"fdname,omitempty"` }
ChardevChangeInfo contains information required to change the backend of a chardev.
type FdsetFdInfo ¶
FdsetFdInfo contains information about a file descriptor that belongs to an FD set.
type FdsetInfo ¶
type FdsetInfo struct { ID int `json:"fdset-id"` FDs []FdsetFdInfo `json:"fds"` }
FdsetInfo contains information about an FD set.
type HotpluggableCPU ¶
type HotpluggableCPU struct { Type string `json:"type"` VCPUsCount int `json:"vcpus-count"` QOMPath string `json:"qom-path,omitempty"` Props CPUInstanceProperties `json:"props"` }
HotpluggableCPU contains information about a hotpluggable CPU.
type MemDev ¶ added in v6.0.5
type MemDev struct { ID string `json:"id"` Size int `json:"size"` Merge bool `json:"merge"` Dump bool `json:"dump"` Prealloc bool `json:"prealloc"` Reserve bool `json:"reserve"` HostNodes []int `json:"host-nodes"` }
MemDev contains information about a memory device.
type MemoryDevice ¶ added in v6.0.5
type MemoryDevice struct { Type string `json:"type"` Data json.RawMessage `json:"data"` }
MemoryDevice contains information about a memory device.
type MigrationStatus ¶ added in v6.0.5
type MigrationStatus struct { Status string `json:"status"` RAM struct { Transferred int64 `json:"transferred"` Remaining int64 `json:"remaining"` Total int64 `json:"total"` Duplicate int64 `json:"duplicate"` Normal int64 `json:"normal"` NormalBytes int64 `json:"normal-bytes"` DirtyPagesRate int64 `json:"diry-pages-rate"` MBps float64 `json:"mbps"` DirtySyncCount int64 `json:"diry-sync-count"` PostcopyRequests int64 `json:"postcopy-requests"` PageSize int64 `json:"page-size"` MultiFDBytes int64 `json:"multifd-bytes"` PagesPerSecond int64 `json:"pages-per-second"` PrecopyBytes int64 `json:"precopy-bytes"` DowntimeBytes int64 `json:"downtime-bytes"` PostcopyBytes int64 `json:"postcopy-bytes"` DirtySyncMissedZeroCopy int64 `json:"diry-sync-missed-zero-copy"` } `json:"ram"` TotalTime int64 `json:"total-time"` DownTime int64 `json:"down-time"` ExpectedDowntime int64 `json:"expected-downtime"` SetupTime int64 `json:"setup-time"` CPUThrottlePercentage int64 `json:"cpu-throttle-percentage"` PostcopyBlocktime int64 `json:"postcopy-blocktime"` PostcopyVCPUBlocktime []int64 `json:"postcopy-vcpu-blocktime"` DirtyLimitThrottleTimePerRound int64 `json:"dirty-limit-throttle-time-per-round"` DirtyLimitRingFullTime int64 `json:"dirty-limit-ring-full-time"` }
MigrationStatus contains information about the ongoing migration.
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor represents a QMP monitor.
func Connect ¶
func Connect(path string, serialCharDev string, eventHandler func(name string, data map[string]any), logFile string, detachDisk func(name string) error) (*Monitor, error)
Connect creates or retrieves an existing QMP monitor for the path.
func (*Monitor) AddBlockDevice ¶
func (m *Monitor) AddBlockDevice(blockDev map[string]any, device map[string]any, attached bool, usb bool) error
AddBlockDevice adds a block device.
func (*Monitor) AddCharDevice ¶
AddCharDevice adds a new character device.
func (*Monitor) AddSecret ¶
AddSecret adds a secret object with the given ID and secret. This function won't return an error if the secret object already exists.
func (*Monitor) AgenStarted ¶
AgenStarted indicates whether an agent has been detected.
func (*Monitor) BlockCommit ¶
BlockCommit merges a snapshot device back into its parent device.
func (*Monitor) BlockDevMirror ¶
BlockDevMirror mirrors the top device to the target device.
func (*Monitor) BlockDevSnapshot ¶
BlockDevSnapshot creates a snapshot of a device using the specified snapshot device.
func (*Monitor) BlockJobCancel ¶
BlockJobCancel cancels an ongoing block job.
func (*Monitor) BlockJobComplete ¶
BlockJobComplete completes a block job that is in reader state.
func (*Monitor) ChardevChange ¶ added in v6.0.3
func (m *Monitor) ChardevChange(device string, info ChardevChangeInfo) error
ChardevChange changes the backend of a specified chardev. Currently supports the socket and ringbuf backends.
func (*Monitor) CheckPCIDevice ¶ added in v6.0.2
CheckPCIDevice checks if the deviceID exists as a bridged PCI device.
func (*Monitor) CloseFile ¶
CloseFile closes an existing file descriptor in the QMP fd table associated to name.
func (*Monitor) Disconnect ¶
func (m *Monitor) Disconnect()
Disconnect forces a disconnection from QEMU.
func (*Monitor) DumpGuestMemory ¶ added in v6.0.4
DumpGuestMemory dumps guest memory to a file.
func (*Monitor) GetBlockStats ¶
func (m *Monitor) GetBlockStats() (map[string]BlockStats, error)
GetBlockStats return block device stats.
func (*Monitor) GetDimmDevices ¶ added in v6.0.5
func (m *Monitor) GetDimmDevices() ([]PCDimmDevice, error)
GetDimmDevices returns a list of memory devices of type pc-dimm.
func (*Monitor) GetMemdev ¶ added in v6.0.5
GetMemdev retrieves memory devices by executing the query-memdev QMP command.
func (*Monitor) GetMemoryBalloonSizeBytes ¶
GetMemoryBalloonSizeBytes returns effective size of the memory in bytes (considering the current balloon size).
func (*Monitor) GetMemoryDevices ¶ added in v6.0.5
func (m *Monitor) GetMemoryDevices() ([]MemoryDevice, error)
GetMemoryDevices retrieves memory devices by executing the query-memory-devices QMP command.
func (*Monitor) GetMemorySizeBytes ¶
GetMemorySizeBytes returns the current size of the base memory in bytes.
func (*Monitor) IncreaseID ¶ added in v6.0.5
IncreaseID returns on auto increment uint32 id.
func (*Monitor) MachineDefinition ¶ added in v6.0.4
MachineDefinition returns the current QEMU machine definition name.
func (*Monitor) MigrateContinue ¶
MigrateContinue continues a migration stream.
func (*Monitor) MigrateIncoming ¶
MigrateIncoming starts the receiver of a migration stream.
func (*Monitor) MigrateSetCapabilities ¶
MigrateSetCapabilities sets the capabilities used during migration.
func (*Monitor) MigrateSetParameters ¶ added in v6.0.5
MigrateSetParameters sets the parameters used during migration.
func (*Monitor) MigrateWait ¶
MigrateWait waits until migration job reaches the specified status. Returns nil if the migraton job reaches the specified status or an error if the migration job is in the failed status.
func (*Monitor) NBDBlockExportAdd ¶
NBDBlockExportAdd exports a writable device via the NBD server.
func (*Monitor) NBDServerStart ¶
NBDServerStart starts internal NBD server and returns a connection to it.
func (*Monitor) NBDServerStop ¶
NBDServerStop stops the internal NBD server.
func (*Monitor) QueryCPUModel ¶ added in v6.0.2
QueryCPUModel returns a CPUModel for the specified model name.
func (*Monitor) QueryHotpluggableCPUs ¶
func (m *Monitor) QueryHotpluggableCPUs() ([]HotpluggableCPU, error)
QueryHotpluggableCPUs returns a list of hotpluggable CPUs.
func (*Monitor) QueryMigrate ¶ added in v6.0.5
func (m *Monitor) QueryMigrate() (*MigrationStatus, error)
QueryMigrate gets the current migration status.
func (*Monitor) RemoveBlockDevice ¶
RemoveBlockDevice removes a block device.
func (*Monitor) RemoveCharDevice ¶
RemoveCharDevice removes a character device.
func (*Monitor) RemoveDevice ¶
RemoveDevice removes a device.
func (*Monitor) RemoveFDFromFDSet ¶
RemoveFDFromFDSet removes an FD with the given name from an FD set.
func (*Monitor) RingbufRead ¶ added in v6.0.3
RingbufRead returns the complete contents of the specified ring buffer.
func (*Monitor) SEVCapabilities ¶
func (m *Monitor) SEVCapabilities() (AMDSEVCapabilities, error)
SEVCapabilities is used to get the SEV capabilities, and is supported on AMD X86 platforms only.
func (*Monitor) Screendump ¶ added in v6.0.3
Screendump takes a screenshot of the current VGA console. The screendump is stored to the filename provided as argument.
func (*Monitor) SendFile ¶
SendFile adds a new file descriptor to the QMP fd table associated to name.
func (*Monitor) SendFileWithFDSet ¶
SendFileWithFDSet adds a new file descriptor to an FD set.
func (*Monitor) SetBlockThrottle ¶
func (m *Monitor) SetBlockThrottle(id string, bytesRead int, bytesWrite int, iopsRead int, iopsWrite int) error
SetBlockThrottle applies an I/O limit on a disk.
func (*Monitor) SetMemoryBalloonSizeBytes ¶
SetMemoryBalloonSizeBytes sets the size of the memory in bytes (which will resize the balloon as needed).
func (*Monitor) SetOnDisconnectEvent ¶
SetOnDisconnectEvent enables or disables the on disconnect event.
func (*Monitor) UpdateBlockSize ¶ added in v6.0.2
UpdateBlockSize updates the size of a disk.
type PCDimmDevice ¶ added in v6.0.5
type PCDimmDevice struct { ID string `json:"id"` Addr uint64 `json:"addr"` Slot int `json:"slot"` Node int `json:"node"` Memdev string `json:"memdev"` Hotpluggable bool `json:"hotpluggable"` Hotplugged bool `json:"hotplugged"` }
PCDimmDevice contains information about a memory device of type pc-dimm.
type PCIBridge ¶
type PCIBridge struct {
Devices []PCIDevice `json:"devices"`
}
PCIBridge represents a PCI bridge.
type PCIClassInfo ¶
PCIClassInfo info about a device's class.