Documentation
¶
Overview ¶
Package qemu implements the hypervisor.Hypervisor interface for QEMU.
Index ¶
- func BuildArgs(cfg hypervisor.VMConfig) []string
- func NewVsockDialer(vsockSocket string, vsockCID int64) hypervisor.VsockDialer
- func Remove(socketPath string)
- type Client
- func (c *Client) Close() error
- func (c *Client) Continue() error
- func (c *Client) Events() (chan qmp.Event, chan struct{}, error)
- func (c *Client) Migrate(uri string) error
- func (c *Client) QueryMigration() (raw.MigrationInfo, error)
- func (c *Client) Quit() error
- func (c *Client) Run(cmd qmp.Command) ([]byte, error)
- func (c *Client) Status() (qemu.Status, error)
- func (c *Client) StatusInfo() (raw.StatusInfo, error)
- func (c *Client) Stop() error
- func (c *Client) SystemPowerdown() error
- func (c *Client) SystemReset() error
- func (c *Client) Version() (string, error)
- func (c *Client) WaitMigration(ctx context.Context, timeout time.Duration) error
- func (c *Client) WaitVMReady(ctx context.Context, timeout time.Duration) error
- type QEMU
- func (q *QEMU) Capabilities() hypervisor.Capabilities
- func (q *QEMU) DeleteVM(ctx context.Context) error
- func (q *QEMU) GetVMInfo(ctx context.Context) (*hypervisor.VMInfo, error)
- func (q *QEMU) Pause(ctx context.Context) error
- func (q *QEMU) ResizeMemory(ctx context.Context, bytes int64) error
- func (q *QEMU) ResizeMemoryAndWait(ctx context.Context, bytes int64, timeout time.Duration) error
- func (q *QEMU) Resume(ctx context.Context) error
- func (q *QEMU) Shutdown(ctx context.Context) error
- func (q *QEMU) Snapshot(ctx context.Context, destPath string) error
- type Starter
- func (s *Starter) GetBinaryPath(p *paths.Paths, version string) (string, error)
- func (s *Starter) GetVersion(p *paths.Paths) (string, error)
- func (s *Starter) RestoreVM(ctx context.Context, p *paths.Paths, version string, socketPath string, ...) (int, hypervisor.Hypervisor, error)
- func (s *Starter) SocketName() string
- func (s *Starter) StartVM(ctx context.Context, p *paths.Paths, version string, socketPath string, ...) (int, hypervisor.Hypervisor, error)
- type VsockDialer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildArgs ¶
func BuildArgs(cfg hypervisor.VMConfig) []string
BuildArgs converts hypervisor.VMConfig to QEMU command-line arguments.
func NewVsockDialer ¶
func NewVsockDialer(vsockSocket string, vsockCID int64) hypervisor.VsockDialer
NewVsockDialer creates a new VsockDialer for QEMU. The vsockSocket parameter is unused for QEMU (it uses CID instead). The vsockCID is the guest's Context ID assigned via vhost-vsock-pci.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps go-qemu's Domain and raw.Monitor with convenience methods.
func (*Client) Migrate ¶
Migrate initiates a migration to the given URI (typically "file:///path"). This is used for saving VM state to a file for snapshot/standby.
func (*Client) QueryMigration ¶
func (c *Client) QueryMigration() (raw.MigrationInfo, error)
QueryMigration returns the current migration status.
func (*Client) StatusInfo ¶
func (c *Client) StatusInfo() (raw.StatusInfo, error)
StatusInfo returns detailed status information from the raw monitor.
func (*Client) SystemPowerdown ¶
SystemPowerdown sends ACPI power button event (graceful shutdown).
func (*Client) SystemReset ¶
SystemReset resets the VM (hard reset).
func (*Client) WaitMigration ¶
WaitMigration polls until an outgoing migration completes or times out. Used for snapshot/standby operations where we initiate the migration. Returns nil if migration completed successfully, error otherwise.
func (*Client) WaitVMReady ¶
WaitVMReady polls until the VM is ready after an incoming migration. Used for restore operations where QEMU was started with -incoming. The VM transitions from "inmigrate" to "paused" when migration data is loaded. Returns nil when VM is ready for resume, error on timeout or failure.
type QEMU ¶
type QEMU struct {
// contains filtered or unexported fields
}
QEMU implements hypervisor.Hypervisor for QEMU VMM.
func GetOrCreate ¶
GetOrCreate returns an existing QEMU client for the socket path, or creates a new one if none exists.
func New ¶
New returns a QEMU client for the given socket path. Uses a connection pool to ensure only one connection per socket exists.
func (*QEMU) Capabilities ¶
func (q *QEMU) Capabilities() hypervisor.Capabilities
Capabilities returns the features supported by QEMU.
func (*QEMU) DeleteVM ¶
DeleteVM removes the VM configuration from QEMU. This sends a graceful shutdown signal to the guest.
func (*QEMU) ResizeMemory ¶
ResizeMemory changes the VM's memory allocation. Not implemented in first pass.
func (*QEMU) ResizeMemoryAndWait ¶
ResizeMemoryAndWait changes the VM's memory allocation and waits for it to stabilize. Not implemented in first pass.
type Starter ¶
type Starter struct{}
Starter implements hypervisor.VMStarter for QEMU.
func (*Starter) GetBinaryPath ¶
GetBinaryPath returns the path to the QEMU binary. QEMU is expected to be installed on the system.
func (*Starter) GetVersion ¶
GetVersion returns the version of the installed QEMU binary. Parses the output of "qemu-system-* --version" to extract the version string.
func (*Starter) RestoreVM ¶
func (s *Starter) RestoreVM(ctx context.Context, p *paths.Paths, version string, socketPath string, snapshotPath string) (int, hypervisor.Hypervisor, error)
RestoreVM starts QEMU and restores VM state from a snapshot. The VM is in paused state after restore; caller should call Resume() to continue execution.
func (*Starter) SocketName ¶
SocketName returns the socket filename for QEMU.
func (*Starter) StartVM ¶
func (s *Starter) StartVM(ctx context.Context, p *paths.Paths, version string, socketPath string, config hypervisor.VMConfig) (int, hypervisor.Hypervisor, error)
StartVM launches QEMU with the VM configuration and returns a Hypervisor client. QEMU receives all configuration via command-line arguments at process start.
type VsockDialer ¶
type VsockDialer struct {
// contains filtered or unexported fields
}
VsockDialer implements hypervisor.VsockDialer for QEMU. QEMU with vhost-vsock-pci uses the kernel's native AF_VSOCK socket family. Connections are made using the guest's CID (Context ID) and port number.
func (*VsockDialer) DialVsock ¶
DialVsock connects to the guest on the specified port using AF_VSOCK. This uses the kernel's vsock infrastructure with the guest's CID.
func (*VsockDialer) Key ¶
func (d *VsockDialer) Key() string
Key returns a unique identifier for this dialer, used for connection pooling.