pub struct Machine {
pub name: String,
pub ssh_host: String,
pub ssh_port: u16,
pub work_dir: PathBuf,
/* private fields */
}Expand description
A running QEMU VM for E2E testing.
Fields§
§name: String§ssh_host: String§ssh_port: u16§work_dir: PathBufImplementations§
Source§impl Machine
impl Machine
pub async fn assert_service_active(&self, unit: &str) -> Result<()>
pub async fn assert_service_inactive(&self, unit: &str) -> Result<()>
pub async fn assert_curl(&self, url: &str, expected_status: u16) -> Result<()>
pub async fn assert_journal_clean(&self, unit: &str) -> Result<()>
pub async fn assert_file_exists(&self, path: &str) -> Result<()>
pub async fn assert_file_not_exists(&self, path: &str) -> Result<()>
pub async fn wait_for_service( &self, unit: &str, timeout: Duration, ) -> Result<()>
Source§impl Machine
impl Machine
pub async fn spawn( image: &Image, test_id: &str, ssh_port: u16, opts: &SpawnOpts, ) -> Result<Self>
Sourcepub async fn exec(&self, cmd: &str) -> Result<ExecOutput>
pub async fn exec(&self, cmd: &str) -> Result<ExecOutput>
Run a command inside the VM via SSH.
Sourcepub async fn exec_streaming(
&self,
cmd: &str,
prefix: &str,
) -> Result<ExecOutput>
pub async fn exec_streaming( &self, cmd: &str, prefix: &str, ) -> Result<ExecOutput>
Run a command inside the VM via SSH, streaming stdout/stderr to the terminal. Returns the exit status (Ok if success, Err if non-zero).
Sourcepub async fn wait_for_exit(&mut self, timeout: Duration)
pub async fn wait_for_exit(&mut self, timeout: Duration)
Wait for the qemu process to exit on its own (e.g., after a clean
sudo poweroff). Returns once the process is gone or timeout elapses.
Used before snapshotting so the disk is fully released.
Sourcepub fn keep_alive(self)
pub fn keep_alive(self)
Print SSH connection info for debugging, then detach. VM keeps running until the user kills it or the process exits.
Trait Implementations§
Source§impl Drop for Machine
impl Drop for Machine
Source§fn drop(&mut self)
fn drop(&mut self)
Kill the QEMU process if it’s still alive. Needed because tokio’s
Child::drop does NOT reap the process by default, so any early
return from spawn_* (e.g. SSH timeout during wait_for_ssh) would
otherwise orphan a QEMU holding the forwarded SSH port. Async destroy
paths that want to survive this (keep_alive) use std::mem::forget
to skip Drop entirely.