Skip to main content

QmpClient

Struct QmpClient 

Source
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

Source

pub async fn connect(path: &str) -> Result<Self>

Source

pub async fn execute(&mut self, payload: Json) -> Result<Json>

Source

pub async fn live_overlay( &mut self, node: &str, overlay_path: &str, ) -> Result<()>

Zero-downtime pivot to a new overlay (modern node-name form).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.)

Source

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.

Source

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.

Source

pub async fn screendump(&mut self, filename: &str) -> Result<()>

Screenshot of the virtual framebuffer (preferred over monitor nc -U).

Source

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.

Source

pub fn check_no_error(res: &Json) -> Result<()>

Build (but do not send) a response-check helper for unit tests.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more