pub struct QmpClient {
pub events: UnboundedReceiver<Value>,
/* private fields */
}Expand description
Hand-rolled QMP client: transport-agnostic socket + newline-delimited
JSON. No qapi dependency; id-based demux of responses vs async
events. One client = one session: single-client transports
(Windows named pipes) refuse overlap, so callers connect, act, and
drop — never hold two clients to the same endpoint.
Fields§
§events: UnboundedReceiver<Value>Implementations§
Source§impl QmpClient
impl QmpClient
pub async fn connect(path: &str) -> Result<Self>
pub async fn execute(&mut self, payload: Json) -> Result<Json>
Sourcepub async fn live_overlay(
&mut self,
node: &str,
overlay_path: &str,
) -> Result<()>
pub async fn live_overlay( &mut self, node: &str, overlay_path: &str, ) -> Result<()>
Zero-downtime pivot to a new overlay (modern node-name form).
Sourcepub async fn savevm(&mut self, name: &str) -> Result<String>
pub async fn savevm(&mut self, name: &str) -> Result<String>
HMP escape hatch for full state checkpoints. Returns the HMP output text: success prints nothing, so ANY output is suspect (a refusal like the pflash veto surfaces here rather than as a QMP error — observed live as a silent no-op save). Callers check the text.
Sourcepub async fn migrate_to_file(&mut self, file: &Path) -> Result<()>
pub async fn migrate_to_file(&mut self, file: &Path) -> Result<()>
Live RAM + device migration to a file (snapshot --live): unlike
savevm, migration transfers pflash content instead of refusing
it, so the writable-VARS veto does not apply. Async job — poll
QmpClient::query_migrate_status until completed.
Sourcepub async fn query_migrate_status(&mut self) -> Result<String>
pub async fn query_migrate_status(&mut self) -> Result<String>
Migration job status (active, completed, failed, cancelled,
…). Bails on unexpected shapes — a status we cannot parse is not
a status we should wait on.
Sourcepub async fn query_vm_status(&mut self) -> Result<String>
pub async fn query_vm_status(&mut self) -> Result<String>
VM run state (running, paused, …). After a migration the guest
must be running — a completed job can still leave it paused, which
reads as a lockup from the outside.
Sourcepub async fn resume_vm(&mut self) -> Result<()>
pub async fn resume_vm(&mut self) -> Result<()>
Resume a paused VM. No-op against a running one is an error from
QEMU, so callers check QmpClient::query_vm_status first.
Sourcepub async fn pause_vm(&mut self) -> Result<()>
pub async fn pause_vm(&mut self) -> Result<()>
Pause a running VM. Used post-restore as half of a stop/cont cycle: HVF can fail to re-arm halted-vCPU timers on the incoming path, and a pause/resume round-trip re-arms them (observed downstream fix).
Sourcepub async fn loadvm(&mut self, name: &str) -> Result<String>
pub async fn loadvm(&mut self, name: &str) -> Result<String>
HMP escape hatch for state restore. Same output-text contract as
QmpClient::savevm: empty is success, anything else is a refusal.
(Kept for forensics; the live path resumes via -incoming, not this.)
Sourcepub async fn powerdown(&mut self) -> Result<()>
pub async fn powerdown(&mut self) -> Result<()>
ACPI power-button event: the guest OS shuts itself down cleanly
(no NTFS dirty bit), then QEMU exits on its own. Prefer over quit
for Windows guests; quit is the last resort.
Sourcepub async fn quit(&mut self) -> Result<()>
pub async fn quit(&mut self) -> Result<()>
Graceful shutdown: QEMU exits, usually without sending a response,
so drain until EOF instead of waiting for a matching id.
Sourcepub async fn screendump(&mut self, filename: &str) -> Result<()>
pub async fn screendump(&mut self, filename: &str) -> Result<()>
Screenshot of the virtual framebuffer (preferred over monitor nc -U).
Sourcepub async fn send_keys(&mut self, keys: &[&str]) -> Result<()>
pub async fn send_keys(&mut self, keys: &[&str]) -> Result<()>
Tap guest keys (QMP send-key), e.g. ["ret"] to answer the
Windows ISO’s “press any key to boot from CD” prompt.
Sourcepub fn check_no_error(res: &Json) -> Result<()>
pub fn check_no_error(res: &Json) -> Result<()>
Build (but do not send) a response-check helper for unit tests.