diff --git a/libcontainer/configs/validate/validator.go b/libcontainer/configs/validate/validator.go index dc6134991..3c938fbfe 100644 --- a/libcontainer/configs/validate/validator.go +++ b/libcontainer/configs/validate/validator.go @@ -306,22 +306,23 @@ func sysctl(config *configs.Config) error { } func intelrdtCheck(config *configs.Config) error { - if config.IntelRdt != nil { - if !intelRdt.isEnabled() { - return fmt.Errorf("intelRdt is specified in config, but Intel RDT is not enabled") - } + if config.IntelRdt == nil { + return nil + } + if !intelRdt.isEnabled() { + return fmt.Errorf("intelRdt is specified in config, but Intel RDT is not enabled") + } - switch clos := config.IntelRdt.ClosID; { - case clos == ".", clos == "..", len(clos) > 1 && strings.Contains(clos, "/"): - return fmt.Errorf("invalid intelRdt.ClosID %q", clos) - } + switch clos := config.IntelRdt.ClosID; { + case clos == ".", clos == "..", len(clos) > 1 && strings.Contains(clos, "/"): + return fmt.Errorf("invalid intelRdt.ClosID %q", clos) + } - if !intelRdt.isCATEnabled() && config.IntelRdt.L3CacheSchema != "" { - return errors.New("intelRdt.l3CacheSchema is specified in config, but Intel RDT/CAT is not enabled") - } - if !intelRdt.isMBAEnabled() && config.IntelRdt.MemBwSchema != "" { - return errors.New("intelRdt.memBwSchema is specified in config, but Intel RDT/MBA is not enabled") - } + if !intelRdt.isCATEnabled() && config.IntelRdt.L3CacheSchema != "" { + return errors.New("intelRdt.l3CacheSchema is specified in config, but Intel RDT/CAT is not enabled") + } + if !intelRdt.isMBAEnabled() && config.IntelRdt.MemBwSchema != "" { + return errors.New("intelRdt.memBwSchema is specified in config, but Intel RDT/MBA is not enabled") } return nil