mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 08:47:56 +00:00
cli: kata-check if SMT is off on POWER8 systems
SMT must be turned off on Power8 for KVM to work. Put this as a check for kata-runtime kata-check. Fixes: #397 Signed-off-by: Nitesh Konkar <niteshkonkar@in.ibm.com>
This commit is contained in:
parent
62d819c907
commit
f890ffdaf7
@ -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