mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-10 20:32:54 +00:00
Merge pull request #398 from nitkon/master
cli: kata-check if SMT is off on POWER8 systems
This commit is contained in:
commit
5a6b541caf
@ -7,6 +7,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -17,6 +19,11 @@ const (
|
|||||||
archCPUModelField = genericCPUModelField
|
archCPUModelField = genericCPUModelField
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ppc64CpuCmd = "ppc64_cpu"
|
||||||
|
smtStatusOption = "--smt"
|
||||||
|
)
|
||||||
|
|
||||||
// archRequiredCPUFlags maps a CPU flag value to search for and a
|
// archRequiredCPUFlags maps a CPU flag value to search for and a
|
||||||
// human-readable description of that value.
|
// human-readable description of that value.
|
||||||
var archRequiredCPUFlags = map[string]string{}
|
var archRequiredCPUFlags = map[string]string{}
|
||||||
@ -50,6 +57,17 @@ func hostIsVMContainerCapable(details vmContainerCapableDetails) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text, err := getFileContents(details.cpuInfoFile)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.Contains(text, "POWER8") {
|
||||||
|
if !isSMTOff() {
|
||||||
|
return fmt.Errorf("SMT is not Off. %s", failMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
count, err := checkKernelModules(details.requiredKernelModules, archKernelParamHandler)
|
count, err := checkKernelModules(details.requiredKernelModules, archKernelParamHandler)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -75,3 +93,22 @@ func archKernelParamHandler(onVMM bool, fields logrus.Fields, msg string) bool {
|
|||||||
func getCPUDetails() (vendor, model string, err error) {
|
func getCPUDetails() (vendor, model string, err error) {
|
||||||
return genericGetCPUDetails()
|
return genericGetCPUDetails()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isSMTOff() bool {
|
||||||
|
|
||||||
|
// Check if the SMT is available and off
|
||||||
|
|
||||||
|
cmd := exec.Command(ppc64CpuCmd, smtStatusOption)
|
||||||
|
additionalEnv := "LANG=C"
|
||||||
|
cmd.Env = append(cmd.Env, additionalEnv)
|
||||||
|
out, err := cmd.Output()
|
||||||
|
|
||||||
|
if err == nil && strings.TrimRight(string(out), "\n") == "SMT is off" {
|
||||||
|
return true
|
||||||
|
} else if err != nil {
|
||||||
|
kataLog.Warn("ppc64_cpu isn't installed, can't detect SMT")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user