mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-02 13:44:33 +00:00
qemu: Add support for memory pre-allocation
Add support for pre-allocating all of the RAM. This increases the memory footprint of QEMU and should be used only when needed. Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
This commit is contained in:
parent
1fbe6c5d1d
commit
4ecb9de5b3
17
qemu.go
17
qemu.go
@ -741,6 +741,9 @@ type Knobs struct {
|
||||
|
||||
// Daemonize will turn the qemu process into a daemon
|
||||
Daemonize bool
|
||||
|
||||
// MemPrealloc will allocate all the RAM upfront
|
||||
MemPrealloc bool
|
||||
}
|
||||
|
||||
// Config is the qemu configuration structure.
|
||||
@ -988,6 +991,20 @@ func (config *Config) appendKnobs() {
|
||||
if config.Knobs.Daemonize == true {
|
||||
config.qemuParams = append(config.qemuParams, "-daemonize")
|
||||
}
|
||||
|
||||
if config.Knobs.MemPrealloc == true {
|
||||
if config.Memory.Size != "" {
|
||||
dimmName := "dimm1"
|
||||
objMemParam := "memory-backend-ram,id=" + dimmName + ",size=" + config.Memory.Size + ",prealloc=on"
|
||||
deviceMemParam := "pc-dimm,id=" + dimmName + ",memdev=" + dimmName
|
||||
|
||||
config.qemuParams = append(config.qemuParams, "-object")
|
||||
config.qemuParams = append(config.qemuParams, objMemParam)
|
||||
|
||||
config.qemuParams = append(config.qemuParams, "-device")
|
||||
config.qemuParams = append(config.qemuParams, deviceMemParam)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LaunchQemu can be used to launch a new qemu instance.
|
||||
|
@ -231,6 +231,7 @@ func TestAppendKnobsAllTrue(t *testing.T) {
|
||||
NoDefaults: true,
|
||||
NoGraphic: true,
|
||||
Daemonize: true,
|
||||
MemPrealloc: true,
|
||||
}
|
||||
|
||||
testAppend(knobs, knobsString, t)
|
||||
@ -241,6 +242,7 @@ func TestAppendKnobsAllFalse(t *testing.T) {
|
||||
NoUserConfig: false,
|
||||
NoDefaults: false,
|
||||
NoGraphic: false,
|
||||
MemPrealloc: false,
|
||||
}
|
||||
|
||||
testAppend(knobs, "", t)
|
||||
|
Loading…
Reference in New Issue
Block a user