firecracker_sdk/firecracker/firercracker_process/
mod.rs

1use anyhow::Result;
2use tokio::process::Child;
3
4use crate::firecracker::firecracker_configuration::FirecrackerConfiguration;
5
6pub mod firecracker_startup;
7
8/// Structure for managing the Firecracker process created using `FirecrackerStartup`
9pub struct FirecrackerProcess {
10    process: Child,
11    configuration: FirecrackerConfiguration,
12}
13
14impl FirecrackerProcess {
15    pub(crate) fn new(child: Child, configuration: FirecrackerConfiguration) -> Self {
16        Self {
17            process: child,
18            configuration,
19        }
20    }
21
22    pub fn get_config(&self) -> &FirecrackerConfiguration {
23        &self.configuration
24    }
25
26    /// Correctly starts the process stop and waits for it to complete
27    pub async fn stop(&mut self) -> Result<()> {
28        self.process.kill().await?;
29        Ok(())
30    }
31}