mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-05 11:36:56 +00:00
Merge pull request #316 from bpradipt/2.0-ppc64le
qemu: Remove Qemu version check in ppc64le unit test
This commit is contained in:
commit
18c882b0fa
@ -24,8 +24,6 @@ const defaultQemuMachineType = QemuPseries
|
||||
|
||||
const defaultQemuMachineOptions = "accel=kvm,usb=off"
|
||||
|
||||
const defaultMemMaxPPC64le = 32256 // Restrict MemMax to 32Gb on PPC64le
|
||||
|
||||
const qmpMigrationWaitTimeout = 5 * time.Second
|
||||
|
||||
var qemuPaths = map[string]string{
|
||||
@ -114,14 +112,8 @@ func (q *qemuPPC64le) cpuModel() string {
|
||||
|
||||
func (q *qemuPPC64le) memoryTopology(memoryMb, hostMemoryMb uint64, slots uint8) govmmQemu.Memory {
|
||||
|
||||
if (qemuMajorVersion > 2) || (qemuMajorVersion == 2 && qemuMinorVersion >= 10) {
|
||||
q.Logger().Debug("Aligning maxmem to multiples of 256MB. Assumption: Kernel Version >= 4.11")
|
||||
hostMemoryMb -= (hostMemoryMb % 256)
|
||||
} else {
|
||||
q.Logger().Debug("Restricting maxmem to 32GB as Qemu Version < 2.10, Assumption: Kernel Version >= 4.11")
|
||||
hostMemoryMb = defaultMemMaxPPC64le
|
||||
}
|
||||
|
||||
q.Logger().Debug("Aligning maxmem to multiples of 256MB. Assumption: Kernel Version >= 4.11")
|
||||
hostMemoryMb -= (hostMemoryMb % 256)
|
||||
return genericMemoryTopology(memoryMb, hostMemoryMb, slots, q.memoryOffset)
|
||||
}
|
||||
|
||||
|
@ -7,17 +7,12 @@ package virtcontainers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
govmmQemu "github.com/intel/govmm/qemu"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var qemuVersionArgs = "--version"
|
||||
|
||||
func newTestQemu(machineType string) qemuArch {
|
||||
config := HypervisorConfig{
|
||||
HypervisorMachineType: machineType,
|
||||
@ -39,31 +34,6 @@ func TestQemuPPC64leCPUModel(t *testing.T) {
|
||||
assert.Equal(expectedOut, model)
|
||||
}
|
||||
|
||||
func getQemuVersion() (qemuMajorVersion int, qemuMinorVersion int) {
|
||||
|
||||
cmd := exec.Command(defaultQemuPath, qemuVersionArgs)
|
||||
additionalEnv := "LANG=C"
|
||||
cmd.Env = append(cmd.Env, additionalEnv)
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Could not execute command %s %s", defaultQemuPath, qemuVersionArgs)
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
|
||||
re := regexp.MustCompile("[0-9]+")
|
||||
qVer := re.FindAllString(string(out), -1)
|
||||
|
||||
qMajor, err := strconv.Atoi(qVer[0])
|
||||
qMinor, err1 := strconv.Atoi(qVer[1])
|
||||
|
||||
if err != nil || err1 != nil {
|
||||
err = fmt.Errorf("Could not convert string to int")
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
|
||||
return qMajor, qMinor
|
||||
}
|
||||
|
||||
func TestQemuPPC64leMemoryTopology(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
ppc64le := newTestQemu(QemuPseries)
|
||||
@ -73,13 +43,8 @@ func TestQemuPPC64leMemoryTopology(t *testing.T) {
|
||||
mem := uint64(120)
|
||||
slots := uint8(10)
|
||||
|
||||
qemuMajorVersion, qemuMinorVersion = getQemuVersion()
|
||||
m := ppc64le.memoryTopology(mem, hostMem, slots)
|
||||
|
||||
if qemuMajorVersion <= 2 && qemuMinorVersion < 10 {
|
||||
hostMem = uint64(defaultMemMaxPPC64le)
|
||||
}
|
||||
|
||||
expectedMemory := govmmQemu.Memory{
|
||||
Size: fmt.Sprintf("%dM", mem),
|
||||
Slots: slots,
|
||||
|
Loading…
Reference in New Issue
Block a user