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:
Alex Zenla
2024-08-15 01:06:04 -07:00
committed by GitHub
parent 506d2ccf46
commit 18bf370f74
10 changed files with 144 additions and 41 deletions

View File

@ -39,20 +39,32 @@ pub struct ZoneLaunchCommand {
pull_update: bool,
#[arg(short, long, help = "Name of the zone")]
name: Option<String>,
#[arg(short, long, default_value_t = 1, help = "vCPUs available to the zone")]
cpus: u32,
#[arg(
short = 'C',
long = "max-cpus",
default_value_t = 4,
help = "Maximum vCPUs available for the zone"
)]
max_cpus: u32,
#[arg(
short = 'c',
long = "target-cpus",
default_value_t = 1,
help = "Target vCPUs for the zone to use"
)]
target_cpus: u32,
#[arg(
short = 'M',
long = "max-memory",
default_value_t = 512,
default_value_t = 1024,
help = "Maximum memory available to the zone, in megabytes"
)]
max_memory: u64,
#[arg(
short = 'm',
long = "target-memory",
default_value_t = 512,
help = "Memory target for the zone, in megabytes"
default_value_t = 1024,
help = "Target memory for the zone to use, in megabytes"
)]
target_memory: u64,
#[arg[short = 'D', long = "device", help = "Devices to request for the zone"]]
@ -131,9 +143,10 @@ impl ZoneLaunchCommand {
kernel,
initrd,
initial_resources: Some(ZoneResourceSpec {
cpus: self.cpus,
max_memory: self.max_memory,
target_memory: self.target_memory,
max_cpus: self.max_cpus,
target_cpus: self.target_cpus,
}),
task: Some(ZoneTaskSpec {
environment: env_map(&self.env.unwrap_or_default())

View File

@ -14,20 +14,32 @@ use tonic::{transport::Channel, Request};
pub struct ZoneUpdateResourcesCommand {
#[arg(help = "Zone to update resources of, either the name or the uuid")]
zone: String,
#[arg(short, long, default_value_t = 0, help = "vCPUs available to the zone")]
cpus: u32,
#[arg(
short = 'C',
long = "max-cpus",
default_value_t = 0,
help = "Maximum vCPUs available to the zone (0 means previous value)"
)]
max_cpus: u32,
#[arg(
short = 'c',
long = "target-cpus",
default_value_t = 0,
help = "Target vCPUs for the zone to use (0 means previous value)"
)]
target_cpus: u32,
#[arg(
short = 'M',
long = "max-memory",
default_value_t = 0,
help = "Maximum memory available to the zone, in megabytes"
help = "Maximum memory available to the zone, in megabytes (0 means previous value)"
)]
max_memory: u64,
#[arg(
short = 'm',
long = "target-memory",
default_value_t = 0,
help = "Memory target for the zone, in megabytes"
help = "Target memory for the zone to use, in megabytes (0 means previous value)"
)]
target_memory: u64,
}
@ -63,10 +75,15 @@ impl ZoneUpdateResourcesCommand {
} else {
self.target_memory
},
cpus: if self.cpus == 0 {
active_resources.cpus
max_cpus: if self.max_cpus == 0 {
active_resources.max_cpus
} else {
self.cpus
self.max_cpus
},
target_cpus: if self.target_cpus == 0 {
active_resources.target_cpus
} else {
self.target_cpus
},
}),
}))