mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-05 06:01:32 +00:00
feature(krata): first pass on cpu hotplug support (#340)
* fix(runtime): adjust memory resources inside a transaction * feature(krata): first pass on cpu hotplug support
This commit is contained in:
@ -664,22 +664,42 @@ impl ControlService for DaemonControlService {
|
||||
.into());
|
||||
}
|
||||
|
||||
let resources = request.resources.unwrap_or_default();
|
||||
let mut resources = request.resources.unwrap_or_default();
|
||||
if resources.target_memory > resources.max_memory {
|
||||
resources.max_memory = resources.target_memory;
|
||||
}
|
||||
|
||||
if resources.target_cpus < 1 {
|
||||
resources.target_cpus = 1;
|
||||
}
|
||||
|
||||
let initial_resources = zone
|
||||
.spec
|
||||
.clone()
|
||||
.unwrap_or_default()
|
||||
.initial_resources
|
||||
.unwrap_or_default();
|
||||
if resources.target_cpus > initial_resources.max_cpus {
|
||||
resources.target_cpus = initial_resources.max_cpus;
|
||||
}
|
||||
resources.max_cpus = initial_resources.max_cpus;
|
||||
|
||||
self.runtime
|
||||
.set_max_memory(status.domid, resources.max_memory * 1024 * 1024)
|
||||
.set_memory_resources(
|
||||
status.domid,
|
||||
resources.target_memory * 1024 * 1024,
|
||||
resources.max_memory * 1024 * 1024,
|
||||
)
|
||||
.await
|
||||
.map_err(|error| ApiError {
|
||||
message: format!("failed to set maximum memory: {}", error),
|
||||
message: format!("failed to set memory resources: {}", error),
|
||||
})?;
|
||||
|
||||
self.runtime
|
||||
.set_target_memory(status.domid, resources.target_memory * 1024 * 1024)
|
||||
.set_cpu_resources(status.domid, resources.target_cpus)
|
||||
.await
|
||||
.map_err(|error| ApiError {
|
||||
message: format!("failed to set target memory: {}", error),
|
||||
message: format!("failed to set cpu resources: {}", error),
|
||||
})?;
|
||||
|
||||
status.resource_status = Some(ZoneResourceStatus {
|
||||
active_resources: Some(resources),
|
||||
});
|
||||
|
Reference in New Issue
Block a user