diff --git a/src/libs/shim-interface/src/lib.rs b/src/libs/shim-interface/src/lib.rs index 2c94a3e5d4..a952b10db2 100644 --- a/src/libs/shim-interface/src/lib.rs +++ b/src/libs/shim-interface/src/lib.rs @@ -73,8 +73,11 @@ fn get_uds_with_sid(short_id: &str, path: &str) -> Result { } // return sandbox's storage path -pub fn sb_storage_path() -> String { - String::from(KATA_PATH) +pub fn sb_storage_path() -> Result<&'static str> { + //make sure the path existed + std::fs::create_dir_all(KATA_PATH).context(format!("failed to create dir: {}", KATA_PATH))?; + + Ok(KATA_PATH) } // returns the address of the unix domain socket(UDS) for communication with shim @@ -87,7 +90,7 @@ pub fn mgmt_socket_addr(sid: &str) -> Result { )); } - get_uds_with_sid(sid, &sb_storage_path()) + get_uds_with_sid(sid, &sb_storage_path()?) } #[cfg(test)]