Skip to content

Commit

Permalink
Add execCPUAffinity to the runtime process spec
Browse files Browse the repository at this point in the history
Signed-off-by: keisku <[email protected]>
  • Loading branch information
keisku committed Jun 28, 2024
1 parent da761c5 commit a5b7a17
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/runtime/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ pub struct Process {
#[getset(get = "pub", set = "pub")]
/// Scheduler specifies the scheduling attributes for a process
scheduler: Option<Scheduler>,

#[serde(default, skip_serializing_if = "Option::is_none")]
#[getset(get = "pub", set = "pub")]
/// ExecCPUAffinity specifies the cpu affinity for a process
exec_cpu_affinity: Option<ExecCPUAffinity>,
}

// Default impl for processes in the container
Expand Down Expand Up @@ -151,6 +156,7 @@ impl Default for Process {
command_line: None,
// Empty IOPriority, no default iopriority
io_priority: Default::default(),
exec_cpu_affinity: Default::default(),
}
}
}
Expand Down Expand Up @@ -549,3 +555,37 @@ impl Default for LinuxSchedulerFlag {
LinuxSchedulerFlag::SchedResetOnFork
}
}

#[derive(Builder, Clone, Debug, Deserialize, Getters, Setters, Eq, PartialEq, Serialize)]
#[builder(
default,
pattern = "owned",
setter(into, strip_option),
build_fn(error = "OciSpecError")
)]
#[getset(get = "pub", set = "pub")]
/// ExecCPUAffinity specifies CPU affinity used to execute the process.
/// This setting is not applicable to the container's init process.
pub struct ExecCPUAffinity {
#[serde(default, skip_serializing_if = "Option::is_none")]
/// cpu_affinity_initial is a list of CPUs a runtime parent process to be run on
/// initially, before the transition to container's cgroup.
/// This is a a comma-separated list, with dashes to represent ranges.
/// For example, `0-3,7` represents CPUs 0,1,2,3, and 7.
cpu_affinity_initial: Option<String>,

#[serde(default, skip_serializing_if = "Option::is_none")]
/// cpu_affinity_final is a list of CPUs the process will be run on after the transition
/// to container's cgroup. The format is the same as for initial. If omitted or empty,
/// the container's default CPU affinity, as defined by cpu.cpus property, is used.
cpu_affinity_final: Option<String>,
}

impl Default for ExecCPUAffinity {
fn default() -> Self {
Self {
cpu_affinity_initial: None,
cpu_affinity_final: None,
}
}
}

0 comments on commit a5b7a17

Please sign in to comment.