QEMU: Knobs: Huge Page Support: Add support for huge pages

Add support to launch virtual machines where the RAM is
allocated using huge pages. This is useful for running
with a user mode networking stack, and for custom setups
which require high performance and low latency.

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
This commit is contained in:
Manohar Castelino 2017-09-25 16:30:56 -07:00
parent 9bfa792795
commit 3da2ef9dea

24
qemu.go
View File

@ -768,6 +768,16 @@ type Knobs struct {
// Daemonize will turn the qemu process into a daemon
Daemonize bool
// Both HugePages and MemPrealloc require the Memory.Size of the VM
// to be set, as they need to reserve the memory upfront in order
// for the VM to boot without errors.
//
// HugePages always results in memory pre-allocation.
// However the setup is different from normal pre-allocation.
// Hence HugePages has precedence over MemPrealloc
// HugePages will pre-allocate all the RAM from huge pages
HugePages bool
// MemPrealloc will allocate all the RAM upfront
MemPrealloc bool
@ -1025,7 +1035,19 @@ func (config *Config) appendKnobs() {
config.qemuParams = append(config.qemuParams, "-daemonize")
}
if config.Knobs.MemPrealloc == true {
if config.Knobs.HugePages == true {
if config.Memory.Size != "" {
dimmName := "dimm1"
objMemParam := "memory-backend-file,id=" + dimmName + ",size=" + config.Memory.Size + ",mem-path=/dev/hugepages,share=on,prealloc=on"
numaMemParam := "node,memdev=" + dimmName
config.qemuParams = append(config.qemuParams, "-object")
config.qemuParams = append(config.qemuParams, objMemParam)
config.qemuParams = append(config.qemuParams, "-numa")
config.qemuParams = append(config.qemuParams, numaMemParam)
}
} else if config.Knobs.MemPrealloc == true {
if config.Memory.Size != "" {
dimmName := "dimm1"
objMemParam := "memory-backend-ram,id=" + dimmName + ",size=" + config.Memory.Size + ",prealloc=on"