@@ -20,6 +20,7 @@ import (
2020 "fmt"
2121 "os"
2222 "path/filepath"
23+ "slices"
2324 "sort"
2425 "strings"
2526
@@ -189,6 +190,7 @@ func (g *Generator) Adjust(adjust *nri.ContainerAdjustment) error {
189190 if err := g .AdjustRdtClass (resources .GetRdtClass ().Get ()); err != nil {
190191 return err
191192 }
193+ g .AdjustRdt (adjust .GetLinux ().GetRdt ())
192194
193195 if err := g .AdjustMounts (adjust .GetMounts ()); err != nil {
194196 return err
@@ -388,6 +390,38 @@ func (g *Generator) AdjustRdtClass(rdtClass *string) error {
388390 return nil
389391}
390392
393+ // AdjustRdt adjusts the intelRdt object in the OCI Spec.
394+ func (g * Generator ) AdjustRdt (r * nri.LinuxRdt ) {
395+ if r == nil {
396+ return
397+ }
398+
399+ g .AdjustRdtClosID (r .ClosId .Get ())
400+ g .AdjustRdtSchemata (r .Schemata .Get ())
401+ g .AdjustRdtEnableMonitoring (r .EnableMonitoring .Get ())
402+ }
403+
404+ // AdjustRdtClosID adjusts the RDT CLOS id in the OCI Spec.
405+ func (g * Generator ) AdjustRdtClosID (value * string ) {
406+ if value != nil {
407+ g .SetLinuxIntelRdtClosID (* value )
408+ }
409+ }
410+
411+ // AdjustRdtSchemata adjusts the RDT schemata in the OCI Spec.
412+ func (g * Generator ) AdjustRdtSchemata (value * []string ) {
413+ if value != nil {
414+ g .SetLinuxIntelRdtSchemata (* value )
415+ }
416+ }
417+
418+ // AdjustRdtEnableMonitoring adjusts the RDT monitoring in the OCI Spec.
419+ func (g * Generator ) AdjustRdtEnableMonitoring (value * bool ) {
420+ if value != nil {
421+ g .SetLinuxIntelRdtEnableMonitoring (* value )
422+ }
423+ }
424+
391425// AdjustCgroupsPath adjusts the cgroup pseudofs path in the OCI Spec.
392426func (g * Generator ) AdjustCgroupsPath (path string ) {
393427 if path != "" {
@@ -682,6 +716,24 @@ func (g *Generator) SetLinuxIntelRdt(rdt *rspec.LinuxIntelRdt) {
682716 g .Config .Linux .IntelRdt = rdt
683717}
684718
719+ // SetLinuxIntelRdtClosID sets g.Config.Linux.IntelRdt.ClosID
720+ func (g * Generator ) SetLinuxIntelRdtClosID (closID string ) {
721+ g .initConfigLinuxIntelRdt ()
722+ g .Config .Linux .IntelRdt .ClosID = closID
723+ }
724+
725+ // SetLinuxIntelRdtEnableMonitoring sets g.Config.Linux.IntelRdt.EnableMonitoring
726+ func (g * Generator ) SetLinuxIntelRdtEnableMonitoring (value bool ) {
727+ g .initConfigLinuxIntelRdt ()
728+ g .Config .Linux .IntelRdt .EnableMonitoring = value
729+ }
730+
731+ // SetLinuxIntelRdtSchemata sets g.Config.Linux.IntelRdt.Schemata
732+ func (g * Generator ) SetLinuxIntelRdtSchemata (schemata []string ) {
733+ g .initConfigLinuxIntelRdt ()
734+ g .Config .Linux .IntelRdt .Schemata = slices .Clone (schemata )
735+ }
736+
685737// ClearLinuxResourcesBlockIO clears Block I/O settings.
686738func (g * Generator ) ClearLinuxResourcesBlockIO () {
687739 g .initConfigLinuxResources ()
@@ -773,3 +825,10 @@ func (g *Generator) initConfigLinuxNetDevices() {
773825 g .Config .Linux .NetDevices = map [string ]rspec.LinuxNetDevice {}
774826 }
775827}
828+
829+ func (g * Generator ) initConfigLinuxIntelRdt () {
830+ g .initConfigLinux ()
831+ if g .Config .Linux .IntelRdt == nil {
832+ g .Config .Linux .IntelRdt = & rspec.LinuxIntelRdt {}
833+ }
834+ }
0 commit comments