@@ -21,6 +21,7 @@ import (
2121 "github.com/opencontainers/runc/libcontainer/cgroups"
2222 "github.com/opencontainers/runc/libcontainer/configs"
2323 "github.com/opencontainers/runc/libcontainer/criurpc"
24+ "github.com/opencontainers/runc/libcontainer/intelrdt"
2425 "github.com/opencontainers/runc/libcontainer/system"
2526 "github.com/opencontainers/runc/libcontainer/utils"
2627
@@ -38,6 +39,7 @@ type linuxContainer struct {
3839 root string
3940 config * configs.Config
4041 cgroupManager cgroups.Manager
42+ intelRdtManager intelrdt.Manager
4143 initArgs []string
4244 initProcess parentProcess
4345 initProcessStartTime uint64
@@ -67,6 +69,9 @@ type State struct {
6769
6870 // Container's standard descriptors (std{in,out,err}), needed for checkpoint and restore
6971 ExternalDescriptors []string `json:"external_descriptors,omitempty"`
72+
73+ // Intel RDT "resource control" filesystem path
74+ IntelRdtPath string `json:"intel_rdt_path"`
7075}
7176
7277// Container is a libcontainer container object.
@@ -163,6 +168,11 @@ func (c *linuxContainer) Stats() (*Stats, error) {
163168 if stats .CgroupStats , err = c .cgroupManager .GetStats (); err != nil {
164169 return stats , newSystemErrorWithCause (err , "getting container stats from cgroups" )
165170 }
171+ if c .intelRdtManager != nil {
172+ if stats .IntelRdtStats , err = c .intelRdtManager .GetStats (); err != nil {
173+ return stats , newSystemErrorWithCause (err , "getting container's Intel RDT stats" )
174+ }
175+ }
166176 for _ , iface := range c .config .Networks {
167177 switch iface .Type {
168178 case "veth" :
@@ -193,6 +203,15 @@ func (c *linuxContainer) Set(config configs.Config) error {
193203 }
194204 return err
195205 }
206+ if c .intelRdtManager != nil {
207+ if err := c .intelRdtManager .Set (& config ); err != nil {
208+ // Set configs back
209+ if err2 := c .intelRdtManager .Set (c .config ); err2 != nil {
210+ logrus .Warnf ("Setting back intelrdt configs failed due to error: %v, your state.json and actual configs might be inconsistent." , err2 )
211+ }
212+ return err
213+ }
214+ }
196215 // After config setting succeed, update config and states
197216 c .config = & config
198217 _ , err = c .updateState (nil )
@@ -434,15 +453,16 @@ func (c *linuxContainer) newInitProcess(p *Process, cmd *exec.Cmd, parentPipe, c
434453 return nil , err
435454 }
436455 return & initProcess {
437- cmd : cmd ,
438- childPipe : childPipe ,
439- parentPipe : parentPipe ,
440- manager : c .cgroupManager ,
441- config : c .newInitConfig (p ),
442- container : c ,
443- process : p ,
444- bootstrapData : data ,
445- sharePidns : sharePidns ,
456+ cmd : cmd ,
457+ childPipe : childPipe ,
458+ parentPipe : parentPipe ,
459+ manager : c .cgroupManager ,
460+ intelRdtManager : c .intelRdtManager ,
461+ config : c .newInitConfig (p ),
462+ container : c ,
463+ process : p ,
464+ bootstrapData : data ,
465+ sharePidns : sharePidns ,
446466 }, nil
447467}
448468
@@ -461,6 +481,7 @@ func (c *linuxContainer) newSetnsProcess(p *Process, cmd *exec.Cmd, parentPipe,
461481 return & setnsProcess {
462482 cmd : cmd ,
463483 cgroupPaths : c .cgroupManager .GetPaths (),
484+ intelRdtPath : state .IntelRdtPath ,
464485 childPipe : childPipe ,
465486 parentPipe : parentPipe ,
466487 config : c .newInitConfig (p ),
@@ -1519,6 +1540,10 @@ func (c *linuxContainer) currentState() (*State, error) {
15191540 startTime , _ = c .initProcess .startTime ()
15201541 externalDescriptors = c .initProcess .externalDescriptors ()
15211542 }
1543+ intelRdtPath , err := intelrdt .GetIntelRdtPath (c .ID ())
1544+ if err != nil {
1545+ intelRdtPath = ""
1546+ }
15221547 state := & State {
15231548 BaseState : BaseState {
15241549 ID : c .ID (),
@@ -1529,6 +1554,7 @@ func (c *linuxContainer) currentState() (*State, error) {
15291554 },
15301555 Rootless : c .config .Rootless ,
15311556 CgroupPaths : c .cgroupManager .GetPaths (),
1557+ IntelRdtPath : intelRdtPath ,
15321558 NamespacePaths : make (map [configs.NamespaceType ]string ),
15331559 ExternalDescriptors : externalDescriptors ,
15341560 }
0 commit comments