feature(krata): dynamic resource allocation (closes #298) (#333)

This commit is contained in:
Alex Zenla
2024-08-14 01:14:49 -07:00
committed by GitHub
parent 1dca770091
commit 87530edf70
15 changed files with 251 additions and 31 deletions

View File

@ -226,6 +226,36 @@ impl Runtime {
Ok(uuid)
}
pub async fn set_max_memory(&self, domid: u32, max_memory_bytes: u64) -> Result<()> {
self.context
.xen
.call
.set_max_mem(domid, max_memory_bytes / 1024)
.await?;
let domain_path = self.context.xen.store.get_domain_path(domid).await?;
let max_memory_path = format!("{}/memory/static-max", domain_path);
self.context
.xen
.store
.write_string(max_memory_path, &(max_memory_bytes / 1024).to_string())
.await?;
Ok(())
}
pub async fn set_target_memory(&self, domid: u32, target_memory_bytes: u64) -> Result<()> {
let domain_path = self.context.xen.store.get_domain_path(domid).await?;
let target_memory_path = format!("{}/memory/target", domain_path);
self.context
.xen
.store
.write_string(
target_memory_path,
&(target_memory_bytes / 1024).to_string(),
)
.await?;
Ok(())
}
pub async fn list(&self) -> Result<Vec<ZoneInfo>> {
self.context.list().await
}