mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-26 07:22:20 +00:00
sandbox: fix the issue of stop sandbox
Since stop sandbox would be called in multi path, thus it's better to set and check the sandbox's state. Fixes: #10042 Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
This commit is contained in:
parent
d7637f93f9
commit
e156516bde
@ -471,8 +471,15 @@ impl Sandbox for VirtSandbox {
|
||||
}
|
||||
|
||||
async fn stop(&self) -> Result<()> {
|
||||
info!(sl!(), "begin stop sandbox");
|
||||
self.hypervisor.stop_vm().await.context("stop vm")?;
|
||||
let mut sandbox_inner = self.inner.write().await;
|
||||
|
||||
if sandbox_inner.state != SandboxState::Stopped {
|
||||
info!(sl!(), "begin stop sandbox");
|
||||
self.hypervisor.stop_vm().await.context("stop vm")?;
|
||||
sandbox_inner.state = SandboxState::Stopped;
|
||||
info!(sl!(), "sandbox stopped");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user