@@ -108,6 +108,11 @@ pub struct Process {
108
108
#[ getset( get = "pub" , set = "pub" ) ]
109
109
/// Scheduler specifies the scheduling attributes for a process
110
110
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 > ,
111
116
}
112
117
113
118
// Default impl for processes in the container
@@ -152,6 +157,7 @@ impl Default for Process {
152
157
command_line : None ,
153
158
// Empty IOPriority, no default iopriority
154
159
io_priority : Default :: default ( ) ,
160
+ exec_cpu_affinity : Default :: default ( ) ,
155
161
}
156
162
}
157
163
}
@@ -555,6 +561,33 @@ impl Default for LinuxSchedulerFlag {
555
561
}
556
562
}
557
563
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
+
558
591
#[ cfg( test) ]
559
592
mod tests {
560
593
use super :: * ;
0 commit comments