-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathtokio_qmp_query.rs
More file actions
28 lines (22 loc) · 848 Bytes
/
Copy pathtokio_qmp_query.rs
File metadata and controls
28 lines (22 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::env::args;
use std::io;
#[tokio::main]
pub async fn main() -> io::Result<()> {
::env_logger::init();
let socket_addr = args().nth(1).expect("argument: QMP socket path");
#[cfg(unix)]
let stream = qapi::futures::QmpStreamTokio::open_uds(socket_addr).await?;
#[cfg(not(unix))]
let stream = qapi::futures::QmpStreamTokio::open_tcp(socket_addr).await?;
println!("{:#?}", stream.capabilities);
let stream = stream.negotiate().await?;
let (qmp, handle) = stream.spawn_tokio();
let status = qmp.execute(qapi::qmp::query_status { }).await?;
println!("VCPU status: {:#?}", status);
{
// NOTE: this isn't necessary, but to manually ensure the stream closes...
drop(qmp); // relinquish handle on the stream
handle.await?; // wait for event loop to exit
}
Ok(())
}