mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 00:37:24 +00:00
arch/arm64: Fix ARM64 build
Fix ARM64 build which silently broken (as we still don't have an ARM CI). Fixes #349. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
parent
2400978f6a
commit
6e161a248e
@ -45,11 +45,15 @@ type vmContainerCapableDetails struct {
|
||||
|
||||
const (
|
||||
moduleParamDir = "parameters"
|
||||
cpuFlagsTag = "flags"
|
||||
successMessageCapable = "System is capable of running " + project
|
||||
successMessageCreate = "System can currently create " + project
|
||||
failMessage = "System is not capable of running " + project
|
||||
kernelPropertyCorrect = "Kernel property value correct"
|
||||
|
||||
// these refer to fields in the procCPUINFO file
|
||||
genericCPUFlagsTag = "flags"
|
||||
genericCPUVendorField = "vendor_id"
|
||||
genericCPUModelField = "model name"
|
||||
)
|
||||
|
||||
// variables rather than consts to allow tests to modify them
|
||||
|
@ -9,6 +9,12 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
cpuFlagsTag = genericCPUFlagsTag
|
||||
archCPUVendorField = genericCPUVendorField
|
||||
archCPUModelField = genericCPUModelField
|
||||
)
|
||||
|
||||
// archRequiredCPUFlags maps a CPU flag value to search for and a
|
||||
// human-readable description of that value.
|
||||
var archRequiredCPUFlags = map[string]string{
|
||||
|
@ -5,6 +5,37 @@
|
||||
|
||||
package main
|
||||
|
||||
import "github.com/sirupsen/logrus"
|
||||
|
||||
const (
|
||||
cpuFlagsTag = "Features"
|
||||
archCPUVendorField = "CPU implementer"
|
||||
archCPUModelField = "CPU variant"
|
||||
)
|
||||
|
||||
// archRequiredCPUFlags maps a CPU flag value to search for and a
|
||||
// human-readable description of that value.
|
||||
var archRequiredCPUFlags = map[string]string{}
|
||||
|
||||
// archRequiredCPUAttribs maps a CPU (non-CPU flag) attribute value to search for
|
||||
// and a human-readable description of that value.
|
||||
var archRequiredCPUAttribs = map[string]string{}
|
||||
|
||||
// archRequiredKernelModules maps a required module name to a human-readable
|
||||
// description of the modules functionality and an optional list of
|
||||
// required module parameters.
|
||||
var archRequiredKernelModules = map[string]kernelModule{
|
||||
"kvm": {
|
||||
desc: "Kernel-based Virtual Machine",
|
||||
},
|
||||
"vhost": {
|
||||
desc: "Host kernel accelerator for virtio",
|
||||
},
|
||||
"vhost_net": {
|
||||
desc: "Host kernel accelerator for virtio network",
|
||||
},
|
||||
}
|
||||
|
||||
// kvmIsUsable determines if it will be possible to create a full virtual machine
|
||||
// by creating a minimal VM and then deleting it.
|
||||
func kvmIsUsable() error {
|
||||
@ -20,3 +51,7 @@ func archHostCanCreateVMContainer() error {
|
||||
func hostIsVMContainerCapable(details vmContainerCapableDetails) error {
|
||||
return genericHostIsVMContainerCapable(details)
|
||||
}
|
||||
|
||||
func archKernelParamHandler(onVMM bool, fields logrus.Fields, msg string) bool {
|
||||
return genericArchKernelParamHandler(onVMM, fields, msg)
|
||||
}
|
||||
|
@ -7,9 +7,16 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
cpuFlagsTag = genericCPUFlagsTag
|
||||
archCPUVendorField = genericCPUVendorField
|
||||
archCPUModelField = genericCPUModelField
|
||||
)
|
||||
|
||||
// archRequiredCPUFlags maps a CPU flag value to search for and a
|
||||
// human-readable description of that value.
|
||||
var archRequiredCPUFlags = map[string]string{}
|
||||
@ -37,11 +44,6 @@ func archHostCanCreateVMContainer() error {
|
||||
// hostIsVMContainerCapable checks to see if the host is theoretically capable
|
||||
// of creating a VM container.
|
||||
func hostIsVMContainerCapable(details vmContainerCapableDetails) error {
|
||||
_, err := getCPUInfo(details.cpuInfoFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
count, err := checkKernelModules(details.requiredKernelModules, archKernelParamHandler)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -229,10 +229,23 @@ func TestCheckGetCPUFlags(t *testing.T) {
|
||||
{"foo", ""},
|
||||
{"foo bar", ""},
|
||||
{":", ""},
|
||||
{"flags", ""},
|
||||
{"flags:", ""},
|
||||
{"flags: a b c", "a b c"},
|
||||
{"flags: a b c foo bar d", "a b c foo bar d"},
|
||||
|
||||
{
|
||||
cpuFlagsTag,
|
||||
"",
|
||||
},
|
||||
{
|
||||
cpuFlagsTag + ":",
|
||||
"",
|
||||
},
|
||||
{
|
||||
fmt.Sprintf("%s: a b c", cpuFlagsTag),
|
||||
"a b c",
|
||||
},
|
||||
{
|
||||
fmt.Sprintf("%s: a b c foo bar d", cpuFlagsTag),
|
||||
"a b c foo bar d",
|
||||
},
|
||||
}
|
||||
|
||||
for _, d := range data {
|
||||
|
@ -205,9 +205,13 @@ VERSION_ID="%s"
|
||||
`, expectedDistro.Name, expectedDistro.Version)
|
||||
|
||||
procCPUInfoContents := fmt.Sprintf(`
|
||||
vendor_id : %s
|
||||
model name : %s
|
||||
`, expectedCPU.Vendor, expectedCPU.Model)
|
||||
%s : %s
|
||||
%s : %s
|
||||
`,
|
||||
archCPUVendorField,
|
||||
expectedCPU.Vendor,
|
||||
archCPUModelField,
|
||||
expectedCPU.Model)
|
||||
|
||||
data := []filesToCreate{
|
||||
{procVersion, procVersionContents},
|
||||
|
33
cli/utils.go
33
cli/utils.go
@ -108,24 +108,35 @@ func getCPUDetails() (vendor, model string, err error) {
|
||||
lines := strings.Split(cpuinfo, "\n")
|
||||
|
||||
for _, line := range lines {
|
||||
if strings.HasPrefix(line, "vendor_id") {
|
||||
fields := strings.Split(line, ":")
|
||||
if len(fields) > 1 {
|
||||
vendor = strings.TrimSpace(fields[1])
|
||||
if archCPUVendorField != "" {
|
||||
if strings.HasPrefix(line, archCPUVendorField) {
|
||||
fields := strings.Split(line, ":")
|
||||
if len(fields) > 1 {
|
||||
vendor = strings.TrimSpace(fields[1])
|
||||
}
|
||||
}
|
||||
} else if strings.HasPrefix(line, "model name") {
|
||||
fields := strings.Split(line, ":")
|
||||
if len(fields) > 1 {
|
||||
model = strings.TrimSpace(fields[1])
|
||||
}
|
||||
|
||||
if archCPUModelField != "" {
|
||||
if strings.HasPrefix(line, archCPUModelField) {
|
||||
fields := strings.Split(line, ":")
|
||||
if len(fields) > 1 {
|
||||
model = strings.TrimSpace(fields[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if vendor != "" && model != "" {
|
||||
return vendor, model, nil
|
||||
if vendor == "" {
|
||||
return "", "", fmt.Errorf("cannot find vendor field in file %v", procCPUInfo)
|
||||
}
|
||||
|
||||
return "", "", fmt.Errorf("failed to find expected fields in file %v", procCPUInfo)
|
||||
// model name is optional
|
||||
if archCPUModelField != "" && model == "" {
|
||||
return "", "", fmt.Errorf("cannot find model field in file %v", procCPUInfo)
|
||||
}
|
||||
|
||||
return vendor, model, nil
|
||||
}
|
||||
|
||||
// resolvePath returns the fully resolved and expanded value of the
|
||||
|
@ -225,10 +225,10 @@ func TestGetCPUDetails(t *testing.T) {
|
||||
}
|
||||
|
||||
const validVendorName = "a vendor"
|
||||
validVendor := fmt.Sprintf(`vendor_id : %s`, validVendorName)
|
||||
validVendor := fmt.Sprintf(`%s : %s`, archCPUVendorField, validVendorName)
|
||||
|
||||
const validModelName = "some CPU model"
|
||||
validModel := fmt.Sprintf(`model name : %s`, validModelName)
|
||||
validModel := fmt.Sprintf(`%s : %s`, archCPUModelField, validModelName)
|
||||
|
||||
validContents := fmt.Sprintf(`
|
||||
a : b
|
||||
@ -240,7 +240,7 @@ foo : bar
|
||||
data := []testData{
|
||||
{"", "", "", true},
|
||||
{"invalid", "", "", true},
|
||||
{"vendor_id", "", "", true},
|
||||
{archCPUVendorField, "", "", true},
|
||||
{validVendor, "", "", true},
|
||||
{validModel, "", "", true},
|
||||
{validContents, validVendorName, validModelName, false},
|
||||
|
@ -22,6 +22,9 @@ const defaultQemuMachineType = QemuVirt
|
||||
|
||||
const defaultQemuMachineOptions = "gic-version=host,usb=off,accel=kvm"
|
||||
|
||||
// Not used
|
||||
const defaultPCBridgeBus = ""
|
||||
|
||||
var qemuPaths = map[string]string{
|
||||
QemuVirt: defaultQemuPath,
|
||||
}
|
||||
@ -47,7 +50,7 @@ func MaxQemuVCPUs() uint32 {
|
||||
return uint32(runtime.NumCPU())
|
||||
}
|
||||
|
||||
func newQemuArch(config HypervisrConfig) qemuArch {
|
||||
func newQemuArch(config HypervisorConfig) qemuArch {
|
||||
machineType := config.HypervisorMachineType
|
||||
if machineType == "" {
|
||||
machineType = defaultQemuMachineType
|
||||
|
Loading…
Reference in New Issue
Block a user