Skip to content

Commit a3d8805

Browse files
authored
Merge pull request #174 from keisku/issue168
2 parents 4f7f2fb + 6e72c7d commit a3d8805

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/runtime/process.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ pub struct Process {
108108
#[getset(get = "pub", set = "pub")]
109109
/// Scheduler specifies the scheduling attributes for a process
110110
scheduler: Option<Scheduler>,
111+
112+
#[serde(default, skip_serializing_if = "Option::is_none")]
113+
#[getset(get = "pub", set = "pub")]
114+
/// ExecCPUAffinity specifies the cpu affinity for a process
115+
exec_cpu_affinity: Option<ExecCPUAffinity>,
111116
}
112117

113118
// Default impl for processes in the container
@@ -152,6 +157,7 @@ impl Default for Process {
152157
command_line: None,
153158
// Empty IOPriority, no default iopriority
154159
io_priority: Default::default(),
160+
exec_cpu_affinity: Default::default(),
155161
}
156162
}
157163
}
@@ -555,6 +561,33 @@ impl Default for LinuxSchedulerFlag {
555561
}
556562
}
557563

564+
#[derive(
565+
Builder, Clone, Debug, Default, Deserialize, Getters, Setters, Eq, PartialEq, Serialize,
566+
)]
567+
#[builder(
568+
default,
569+
pattern = "owned",
570+
setter(into, strip_option),
571+
build_fn(error = "OciSpecError")
572+
)]
573+
#[getset(get = "pub", set = "pub")]
574+
/// ExecCPUAffinity specifies CPU affinity used to execute the process.
575+
/// This setting is not applicable to the container's init process.
576+
pub struct ExecCPUAffinity {
577+
#[serde(default, skip_serializing_if = "Option::is_none")]
578+
/// cpu_affinity_initial is a list of CPUs a runtime parent process to be run on
579+
/// initially, before the transition to container's cgroup.
580+
/// This is a a comma-separated list, with dashes to represent ranges.
581+
/// For example, `0-3,7` represents CPUs 0,1,2,3, and 7.
582+
cpu_affinity_initial: Option<String>,
583+
584+
#[serde(default, skip_serializing_if = "Option::is_none")]
585+
/// cpu_affinity_final is a list of CPUs the process will be run on after the transition
586+
/// to container's cgroup. The format is the same as for `initial`. If omitted or empty,
587+
/// the container's default CPU affinity, as defined by cpu.cpus property, is used.
588+
cpu_affinity_final: Option<String>,
589+
}
590+
558591
#[cfg(test)]
559592
mod tests {
560593
use super::*;

0 commit comments

Comments
 (0)