Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
cli: kata-check if SMT is off on POWER8 systems
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nitkon committed Jun 25, 2018
1 parent 62d819c commit f890ffd
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions cli/kata-check_ppc64le.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package main

import (
"fmt"
"os/exec"
"strings"

"github.com/sirupsen/logrus"
)
Expand All @@ -17,6 +19,11 @@ const (
archCPUModelField = genericCPUModelField
)

var (
ppc64CpuCmd = "ppc64_cpu"
smtStatusOption = "--smt"
)

// archRequiredCPUFlags maps a CPU flag value to search for and a
// human-readable description of that value.
var archRequiredCPUFlags = map[string]string{}
Expand Down Expand Up @@ -50,6 +57,17 @@ func hostIsVMContainerCapable(details vmContainerCapableDetails) error {
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)
if err != nil {
return err
Expand All @@ -75,3 +93,22 @@ func archKernelParamHandler(onVMM bool, fields logrus.Fields, msg string) bool {
func getCPUDetails() (vendor, model string, err error) {
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
}

0 comments on commit f890ffd

Please sign in to comment.