mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 11:44:38 +00:00
QEMU: Enable realtime options
Enable realtime options in QEMU. Also add support to control memory locking. Turning realtime on with memory locking disabled allows memory to be swapped out, potentially increasing density of VMs. Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
This commit is contained in:
parent
4ecb9de5b3
commit
ddee41d553
16
qemu.go
16
qemu.go
@ -744,6 +744,13 @@ type Knobs struct {
|
||||
|
||||
// MemPrealloc will allocate all the RAM upfront
|
||||
MemPrealloc bool
|
||||
|
||||
// Mlock will control locking of memory
|
||||
// Only active when Realtime is set to true
|
||||
Mlock bool
|
||||
|
||||
// Realtime will enable realtime QEMU
|
||||
Realtime bool
|
||||
}
|
||||
|
||||
// Config is the qemu configuration structure.
|
||||
@ -1005,6 +1012,15 @@ func (config *Config) appendKnobs() {
|
||||
config.qemuParams = append(config.qemuParams, deviceMemParam)
|
||||
}
|
||||
}
|
||||
|
||||
if config.Knobs.Realtime == true {
|
||||
config.qemuParams = append(config.qemuParams, "-realtime")
|
||||
if config.Knobs.Mlock == true {
|
||||
config.qemuParams = append(config.qemuParams, "mlock=on")
|
||||
} else {
|
||||
config.qemuParams = append(config.qemuParams, "mlock=off")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LaunchQemu can be used to launch a new qemu instance.
|
||||
|
@ -223,7 +223,7 @@ func TestAppendEmptyDevice(t *testing.T) {
|
||||
testAppend(device, "", t)
|
||||
}
|
||||
|
||||
var knobsString = "-no-user-config -nodefaults -nographic -daemonize"
|
||||
var knobsString = "-no-user-config -nodefaults -nographic -daemonize -realtime mlock=on"
|
||||
|
||||
func TestAppendKnobsAllTrue(t *testing.T) {
|
||||
knobs := Knobs{
|
||||
@ -232,6 +232,8 @@ func TestAppendKnobsAllTrue(t *testing.T) {
|
||||
NoGraphic: true,
|
||||
Daemonize: true,
|
||||
MemPrealloc: true,
|
||||
Realtime: true,
|
||||
Mlock: true,
|
||||
}
|
||||
|
||||
testAppend(knobs, knobsString, t)
|
||||
@ -243,6 +245,8 @@ func TestAppendKnobsAllFalse(t *testing.T) {
|
||||
NoDefaults: false,
|
||||
NoGraphic: false,
|
||||
MemPrealloc: false,
|
||||
Realtime: false,
|
||||
Mlock: false,
|
||||
}
|
||||
|
||||
testAppend(knobs, "", t)
|
||||
|
Loading…
Reference in New Issue
Block a user