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

Commit

Permalink
Merge pull request #1986 from marcov/kvm-required
Browse files Browse the repository at this point in the history
kata-check: require kvm modules for amd64
  • Loading branch information
jodh-intel authored Aug 29, 2019
2 parents af57485 + 5bfca6e commit a1e0a4c
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 6 deletions.
19 changes: 13 additions & 6 deletions cli/kata-check_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,21 @@ func setCPUtype(hypervisorType vc.HypervisorType) error {
}
archRequiredKernelModules = map[string]kernelModule{
kernelModkvm: {
desc: msgKernelVM,
desc: msgKernelVM,
required: true,
},
kernelModkvmintel: {
desc: "Intel KVM",
parameters: kvmIntelParams,
required: true,
},
kernelModvhost: {
desc: msgKernelVirtio,
desc: msgKernelVirtio,
required: true,
},
kernelModvhostnet: {
desc: msgKernelVirtioNet,
desc: msgKernelVirtioNet,
required: true,
},
kernelModvhostvsock: {
desc: msgKernelVirtioVhostVsock,
Expand All @@ -143,13 +147,16 @@ func setCPUtype(hypervisorType vc.HypervisorType) error {
}
archRequiredKernelModules = map[string]kernelModule{
kernelModvhm: {
desc: "Intel ACRN",
desc: "Intel ACRN",
required: false,
},
kernelModvhost: {
desc: msgKernelVirtio,
desc: msgKernelVirtio,
required: false,
},
kernelModvhostnet: {
desc: msgKernelVirtioNet,
desc: msgKernelVirtioNet,
required: false,
},
}
default:
Expand Down
51 changes: 51 additions & 0 deletions cli/kata-check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,3 +854,54 @@ func TestCheckKernelParamHandler(t *testing.T) {
// single error (due to "param1"'s value being different)
checkKernelParamHandler(assert, testDataToCreate, testDataToExpect, nil, false, uint32(1))
}

func TestArchRequiredKernelModules(t *testing.T) {
assert := assert.New(t)

tmpdir, err := ioutil.TempDir("", "")
assert.NoError(err)
defer os.RemoveAll(tmpdir)

_, config, err := makeRuntimeConfig(tmpdir)
assert.NoError(err)

err = setCPUtype(config.HypervisorType)
assert.NoError(err)

if len(archRequiredKernelModules) == 0 {
// No modules to check
return
}

dir, err := ioutil.TempDir("", "")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)

savedModProbeCmd := modProbeCmd
savedSysModuleDir := sysModuleDir

// XXX: override
sysModuleDir = filepath.Join(dir, "sys/module")
modProbeCmd = "false"

defer func() {
sysModuleDir = savedSysModuleDir
modProbeCmd = savedModProbeCmd
}()

// Running check with no modules
count, err := checkKernelModules(archRequiredKernelModules, nil)
assert.NoError(err)

// Test that count returned matches the # of modules with required set.
expectedCount := 0
for _, module := range archRequiredKernelModules {
if module.required {
expectedCount++
}
}

assert.EqualValues(count, expectedCount)
}

0 comments on commit a1e0a4c

Please sign in to comment.