Crate qmp

Crate qmp 

Source
Expand description

qmp - Async-first QEMU/QMP client library.

This crate is designed for:

  • QEMU QMP sockets (Unix / TCP)
  • PVE / Proxmox scenarios where you want observability and automation without invasive changes

It provides:

  • socket connection management (Unix/TCP)
  • handshake + qmp_capabilities negotiation
  • typed JSON (serde) request/response handling
  • subscribable event stream
  • per-call timeout and cooperative cancellation
  • an optional “safe ops” layer with allow-lists, idempotency, mutex, and retry/backoff

§Quick start (Unix socket)

use qmp::{Client, Endpoint};
let client = Client::connect(Endpoint::unix("/var/run/qemu-server/100.qmp")).await?;

// Low-level (generic) call:
let status: serde_json::Value = client.execute("query-status", Option::<()>::None).await?;
println!("status = {status}");

// Subscribe to events:
let mut events = client.events();
if let Ok(ev) = events.recv().await {
    println!("event: {}", ev.name);
}

Re-exports§

pub use error::Error;
pub use error::Result;

Modules§

error
Error model for the qmp crate.
ops
“Safe ops” layer.
types
Public data types.

Structs§

CallOptions
Options for a single command call.
CancelToken
A clonable cancellation token.
Client
An async-first QMP client.
ClientBuilder
QMP client builder.
ConnectOptions
Options controlling how the QMP connection is established.
EventStream
A clonable subscription stream of QMP events.

Enums§

Endpoint
QMP endpoint.