Skip to content

Commit

Permalink
kata-runtime: Return correct kata-env on ppc64le
Browse files Browse the repository at this point in the history
The contents of /proc/cpuinfo were
trimmed and hence the "model" field could
not be parsed despite being a field in
/proc/cpuinfo. Fix this issue.

Fixes: kata-containers#1089

Signed-off-by: Nitesh Konkar niteshkonkar@in.ibm.com
  • Loading branch information
nitkon authored and root committed Jan 5, 2019
1 parent 8161b4c commit ed5e0b6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
7 changes: 2 additions & 5 deletions cli/kata-check.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,11 @@ func getCPUInfo(cpuInfoFile string) (string, error) {
return "", err
}

cpus := strings.SplitAfter(text, "\n\n")

trimmed := strings.TrimSpace(cpus[0])
if trimmed == "" {
if len(strings.TrimSpace(text)) == 0 {
return "", fmt.Errorf("Cannot determine CPU details")
}

return trimmed, nil
return text, nil
}

// findAnchoredString searches haystack for needle and returns true if found
Expand Down
6 changes: 1 addition & 5 deletions cli/kata-check_ppc64le.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ func archKernelParamHandler(onVMM bool, fields logrus.Fields, msg string) bool {
}

func getCPUDetails() (vendor, model string, err error) {
vendor, model, err = genericGetCPUDetails()
if err == nil {
model = "POWER8"
}
return vendor, model, err
return genericGetCPUDetails()
}

func isSMTOff() bool {
Expand Down
8 changes: 4 additions & 4 deletions cli/kata-check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ func TestCheckGetCPUInfo(t *testing.T) {
{" ", "", true},
{"\n", "", true},
{"\n\n", "", true},
{"hello\n", "hello", false},
{"foo\n\n", "foo", false},
{"foo\n\nbar\n\n", "foo", false},
{"foo\n\nbar\nbaz\n\n", "foo", false},
{"hello\n", "hello\n", false},
{"foo\n\n", "foo\n\n", false},
{"foo\n\nbar\n\n", "foo\n\nbar\n\n", false},
{"foo\n\nbar\nbaz\n\n", "foo\n\nbar\nbaz\n\n", false},
}

dir, err := ioutil.TempDir("", "")
Expand Down

0 comments on commit ed5e0b6

Please # to comment.