Documentation
¶
Overview ¶
Package vmhost implements the control protocol between the mb daemon and per-VM vmhost child processes. Each vmhost process manages exactly one VM and exposes a JSON-RPC control socket (vmhost.sock) for lifecycle operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client communicates with a vmhost process over its control socket.
func (*Client) IsAlive ¶
IsAlive checks if the vmhost process is reachable by sending a status request. Returns true if the vmhost responds, false otherwise.
type Request ¶
type Request struct {
Method Method `json:"method"`
// Stop parameters
TimeoutSeconds int `json:"timeout_seconds,omitempty"`
}
Request is the wire format for daemon -> vmhost RPC calls.
type Response ¶
type Response struct {
OK bool `json:"ok"`
Error string `json:"error,omitempty"`
// Status/Info fields
State string `json:"state,omitempty"`
SSHPort int `json:"ssh_port,omitempty"`
Backend string `json:"backend,omitempty"`
}
Response is the wire format for vmhost -> daemon responses.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the vmhost control socket server. It listens on vmhost.sock and dispatches requests to the VMController.
type VMController ¶
type VMController interface {
// State returns the current VM lifecycle state as a string
// ("running", "stopped", "error").
State() string
// Stop gracefully shuts down the VM within the given timeout.
// It should attempt stereosd shutdown, then ACPI, then force kill.
Stop(ctx context.Context, timeout time.Duration) error
// ForceStop immediately terminates the VM.
ForceStop(ctx context.Context) error
// SSHPort returns the host-side SSH port for this VM.
SSHPort() int
// Backend returns the backend name ("qemu" or "applevirt").
Backend() string
// Wait blocks until the VM exits. It returns nil on clean exit
// or an error if the VM crashed.
Wait() error
}
VMController is the interface that the vmhost server uses to interact with the underlying VM. Each backend (QEMU, Apple Virt) implements this to provide lifecycle control.