mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-04 05:31:32 +00:00
@ -30,8 +30,9 @@ pub struct ZoneLaunchRequest {
|
||||
pub initrd: Vec<u8>,
|
||||
pub uuid: Option<Uuid>,
|
||||
pub name: Option<String>,
|
||||
pub vcpus: u32,
|
||||
pub mem: u64,
|
||||
pub cpus: u32,
|
||||
pub target_memory: u64,
|
||||
pub max_memory: u64,
|
||||
pub env: HashMap<String, String>,
|
||||
pub run: Option<Vec<String>>,
|
||||
pub pcis: Vec<PciDevice>,
|
||||
@ -194,8 +195,9 @@ impl ZoneLauncher {
|
||||
|
||||
let config = DomainConfig {
|
||||
base: BaseDomainConfig {
|
||||
max_vcpus: request.vcpus,
|
||||
mem_mb: request.mem,
|
||||
max_vcpus: request.cpus,
|
||||
max_mem_mb: request.max_memory,
|
||||
target_mem_mb: request.target_memory,
|
||||
kernel: request.kernel,
|
||||
initrd: request.initrd,
|
||||
cmdline,
|
||||
|
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user