diff --git a/src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs b/src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs index cd61d52439..2007461fcd 100644 --- a/src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs +++ b/src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs @@ -77,7 +77,7 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; use std::time::SystemTime; use strum::Display; -use tokio::sync::{mpsc::Sender, Mutex, RwLock}; +use tokio::sync::{mpsc::Sender, watch, Mutex, RwLock}; use tracing::instrument; pub(crate) const VIRTCONTAINER: &str = "virt_container"; @@ -118,6 +118,7 @@ pub struct VirtSandbox { agent: Arc, hypervisor: Arc, monitor: Arc, + exit_notify_tx: watch::Sender, sandbox_config: Option, shm_size: u64, factory: Option, @@ -133,6 +134,7 @@ impl std::fmt::Debug for VirtSandbox { .field("agent", &"") .field("hypervisor", &self.hypervisor) .field("monitor", &"") + .field("exit_notify_tx", &">") .field("sandbox_config", &self.sandbox_config) .field("factory", &self.factory) .finish() @@ -151,6 +153,7 @@ impl VirtSandbox { ) -> Result { let config = resource_manager.config().await; let keep_abnormal = config.runtime.keep_abnormal; + let (exit_notify_tx, _) = watch::channel(false); Ok(Self { sid: sid.to_string(), msg_sender: Arc::new(Mutex::new(msg_sender)), @@ -159,6 +162,7 @@ impl VirtSandbox { hypervisor, resource_manager, monitor: Arc::new(HealthCheck::new(true, keep_abnormal)), + exit_notify_tx, shm_size: sandbox_config.shm_size, sandbox_config: Some(sandbox_config), factory: Some(factory), @@ -1254,6 +1258,7 @@ impl Persist for VirtSandbox { hypervisor, resource_manager, monitor: Arc::new(HealthCheck::new(true, keep_abnormal)), + exit_notify_tx: watch::channel(false).0, sandbox_config: None, shm_size: DEFAULT_SHM_SIZE, factory: None,