Merge pull request #417 from nitkon/maxmem

virtcontainers: Set ppc64le maxmem depending on qemu version
This commit is contained in:
Sebastien Boeuf
2018-07-09 12:07:12 -07:00
committed by GitHub
2 changed files with 17 additions and 4 deletions

View File

@@ -68,6 +68,9 @@ const qmpSocket = "qmp.sock"
const defaultConsole = "console.sock"
var qemuMajorVersion int
var qemuMinorVersion int
// agnostic list of kernel parameters
var defaultKernelParameters = []Param{
{"panic", "1"},
@@ -472,6 +475,8 @@ func (q *qemu) waitSandbox(timeout int) error {
}
q.qmpMonitorCh.qmp = qmp
qemuMajorVersion = ver.Major
qemuMinorVersion = ver.Minor
q.Logger().WithFields(logrus.Fields{
"qmp-major-version": ver.Major,

View File

@@ -12,6 +12,7 @@ import (
govmmQemu "github.com/intel/govmm/qemu"
"github.com/kata-containers/runtime/virtcontainers/device/drivers"
"github.com/kata-containers/runtime/virtcontainers/utils"
"github.com/sirupsen/logrus"
)
type qemuPPC64le struct {
@@ -54,6 +55,11 @@ var supportedQemuMachines = []govmmQemu.Machine{
},
}
// Logger returns a logrus logger appropriate for logging qemu messages
func (q *qemuPPC64le) Logger() *logrus.Entry {
return virtLog.WithField("subsystem", "qemu")
}
// MaxQemuVCPUs returns the maximum number of vCPUs supported
func MaxQemuVCPUs() uint32 {
return uint32(128)
@@ -105,12 +111,14 @@ func (q *qemuPPC64le) cpuModel() string {
func (q *qemuPPC64le) memoryTopology(memoryMb, hostMemoryMb uint64) govmmQemu.Memory {
if hostMemoryMb > defaultMemMaxPPC64le {
hostMemoryMb = defaultMemMaxPPC64le
} else {
// align hostMemoryMb to 256MB multiples
if 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
}
return genericMemoryTopology(memoryMb, hostMemoryMb)
}