container: implement exit code xenbus notification

This commit is contained in:
Alex Zenla
2024-02-23 04:48:44 +00:00
parent 79acf4e814
commit 496cdd37be
6 changed files with 19 additions and 17 deletions

View File

@ -25,8 +25,8 @@ features = ["process"]
[dependencies.krata]
path = "../shared"
[dependencies.xenevtchn]
path = "../libs/xen/xenevtchn"
[dependencies.xenstore]
path = "../libs/xen/xenstore"
[lib]
path = "src/lib.rs"

View File

@ -4,6 +4,7 @@ use crate::childwait::{ChildEvent, ChildWait};
use anyhow::Result;
use nix::{libc::c_int, unistd::Pid};
use tokio::{select, time::sleep};
use xenstore::client::{XsdClient, XsdInterface};
pub struct ContainerBackground {
child: Pid,
@ -40,8 +41,11 @@ impl ContainerBackground {
}
async fn death(&mut self, code: c_int) -> Result<()> {
println!("[krata] container process exited: status = {}", code);
println!("[krata] looping forever");
let mut store = XsdClient::open().await?;
store
.write_string("krata/guest/exit-code", &code.to_string())
.await?;
drop(store);
loop {
sleep(Duration::from_secs(1)).await;
}