Skip to content

Commit e846add

Browse files
committed
libcontainer/configs/validate: check that intelrdt is enabled
If intelRdt is specified in the spec, check that the resctrl fs is actually mounted. Fixes e.g. the case where "intelRdt.closID" is specified but runc silently ignores this if resctrl is not mounted. Signed-off-by: Markus Lehtonen <[email protected]>
1 parent 5d04e7f commit e846add

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

libcontainer/configs/validate/validator.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ func sysctl(config *configs.Config) error {
283283

284284
func intelrdtCheck(config *configs.Config) error {
285285
if config.IntelRdt != nil {
286+
if !intelrdt.IsEnabled() {
287+
return fmt.Errorf("intelRdt is specified in config, but Intel RDT is not enabled")
288+
}
289+
286290
if config.IntelRdt.ClosID == "." || config.IntelRdt.ClosID == ".." || strings.Contains(config.IntelRdt.ClosID, "/") {
287291
return fmt.Errorf("invalid intelRdt.ClosID %q", config.IntelRdt.ClosID)
288292
}

libcontainer/intelrdt/intelrdt.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,12 @@ func WriteIntelRdtTasks(dir string, pid int) error {
416416
return nil
417417
}
418418

419+
// IsEnabled checks if Intel RDT is enabled.
420+
func IsEnabled() bool {
421+
fsroot, err := Root()
422+
return err == nil && fsroot != ""
423+
}
424+
419425
// IsCATEnabled checks if Intel RDT/CAT is enabled.
420426
func IsCATEnabled() bool {
421427
featuresInit()

0 commit comments

Comments
 (0)