2024-05-08 21:33:09 -04:00
|
|
|
use cvm12_rs::{guac, qmp};
|
2024-03-28 11:02:14 -04:00
|
|
|
|
2024-05-08 21:33:09 -04:00
|
|
|
use tokio::net::{UnixSocket, UnixStream};
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() {
|
|
|
|
|
|
|
|
let subscriber = tracing_subscriber::FmtSubscriber::builder()
|
|
|
|
.with_max_level(tracing::Level::TRACE)
|
|
|
|
.finish();
|
|
|
|
|
|
|
|
tracing::subscriber::set_global_default(subscriber).expect("You Banned");
|
|
|
|
|
|
|
|
|
2024-05-09 00:48:42 -04:00
|
|
|
// Create a stream to connect
|
2024-05-08 21:33:09 -04:00
|
|
|
let stream = UnixStream::connect("/home/lily/vms/xpiss/qmp.sock")
|
|
|
|
.await
|
|
|
|
.expect("Could not connect");
|
|
|
|
|
|
|
|
|
|
|
|
let client = qmp::QmpClient::new(stream);
|
|
|
|
|
2024-05-09 00:48:42 -04:00
|
|
|
// Handshake QMP
|
2024-05-08 21:33:09 -04:00
|
|
|
client.handshake().await.expect("Could not handshake QMP");
|
|
|
|
|
|
|
|
println!("handshook QMP");
|
|
|
|
|
2024-05-09 00:48:42 -04:00
|
|
|
// let's try to get all STOP events from QMP now.
|
|
|
|
let mut rx = client.subscribe_to_event("STOP".into()).await.unwrap();
|
2024-05-08 21:33:09 -04:00
|
|
|
|
2024-05-09 00:48:42 -04:00
|
|
|
// If this worked, then now we can recieve all the events.
|
|
|
|
// This code here allows running a VM with the -no-shutdown option,
|
|
|
|
// automatially resetting it on shutdown.
|
2024-05-08 21:33:09 -04:00
|
|
|
while let Some(message) = rx.recv().await {
|
2024-05-09 00:48:42 -04:00
|
|
|
println!("Got stop event! {:?}", message);
|
|
|
|
|
|
|
|
let res1 = client.execute("system_reset".into(), None).await.expect("FUCK");
|
|
|
|
let res2 = client.execute("cont".into(), None).await.expect("FUCK");
|
|
|
|
|
|
|
|
println!("Result of running: {:?}, {:?}", res1, res2);
|
2024-05-08 21:33:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//println!("Hello, world!");
|
2024-03-28 11:02:14 -04:00
|
|
|
}
|