Merge pull request #316 from bpradipt/2.0-ppc64le

qemu: Remove Qemu version check in ppc64le unit test
This commit is contained in:
Julio Montes 2020-06-22 11:02:11 -05:00 committed by GitHub
commit 18c882b0fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 45 deletions

View File

@ -24,8 +24,6 @@ const defaultQemuMachineType = QemuPseries
const defaultQemuMachineOptions = "accel=kvm,usb=off" const defaultQemuMachineOptions = "accel=kvm,usb=off"
const defaultMemMaxPPC64le = 32256 // Restrict MemMax to 32Gb on PPC64le
const qmpMigrationWaitTimeout = 5 * time.Second const qmpMigrationWaitTimeout = 5 * time.Second
var qemuPaths = map[string]string{ 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 { 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") q.Logger().Debug("Aligning maxmem to multiples of 256MB. Assumption: Kernel Version >= 4.11")
hostMemoryMb -= (hostMemoryMb % 256) hostMemoryMb -= (hostMemoryMb % 256)
} else {
q.Logger().Debug("Restricting maxmem to 32GB as Qemu Version < 2.10, Assumption: Kernel Version >= 4.11")
hostMemoryMb = defaultMemMaxPPC64le
}
return genericMemoryTopology(memoryMb, hostMemoryMb, slots, q.memoryOffset) return genericMemoryTopology(memoryMb, hostMemoryMb, slots, q.memoryOffset)
} }

View File

@ -7,17 +7,12 @@ package virtcontainers
import ( import (
"fmt" "fmt"
"os/exec"
"regexp"
"strconv"
"testing" "testing"
govmmQemu "github.com/intel/govmm/qemu" govmmQemu "github.com/intel/govmm/qemu"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
var qemuVersionArgs = "--version"
func newTestQemu(machineType string) qemuArch { func newTestQemu(machineType string) qemuArch {
config := HypervisorConfig{ config := HypervisorConfig{
HypervisorMachineType: machineType, HypervisorMachineType: machineType,
@ -39,31 +34,6 @@ func TestQemuPPC64leCPUModel(t *testing.T) {
assert.Equal(expectedOut, model) 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) { func TestQemuPPC64leMemoryTopology(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
ppc64le := newTestQemu(QemuPseries) ppc64le := newTestQemu(QemuPseries)
@ -73,13 +43,8 @@ func TestQemuPPC64leMemoryTopology(t *testing.T) {
mem := uint64(120) mem := uint64(120)
slots := uint8(10) slots := uint8(10)
qemuMajorVersion, qemuMinorVersion = getQemuVersion()
m := ppc64le.memoryTopology(mem, hostMem, slots) m := ppc64le.memoryTopology(mem, hostMem, slots)
if qemuMajorVersion <= 2 && qemuMinorVersion < 10 {
hostMem = uint64(defaultMemMaxPPC64le)
}
expectedMemory := govmmQemu.Memory{ expectedMemory := govmmQemu.Memory{
Size: fmt.Sprintf("%dM", mem), Size: fmt.Sprintf("%dM", mem),
Slots: slots, Slots: slots,