From 9a2bbedac7a9c30f5dc5ef3bdd6b68fe196496c0 Mon Sep 17 00:00:00 2001 From: Jakob Naucke Date: Fri, 23 Jul 2021 17:41:22 +0200 Subject: [PATCH] qemu: Remove -realtime in favor of -overcommit as `-realtime` has been removed in QEMU 6. `-overcommit` has been supported since at least QEMU 3.1. Fixes: #189 Signed-off-by: Jakob Naucke --- qemu/qemu.go | 25 +++---------------------- qemu/qemu_test.go | 36 ++++++++---------------------------- 2 files changed, 11 insertions(+), 50 deletions(-) diff --git a/qemu/qemu.go b/qemu/qemu.go index f1c67e4fe3..aebc97c038 100644 --- a/qemu/qemu.go +++ b/qemu/qemu.go @@ -2411,15 +2411,11 @@ type Knobs struct { MemShared bool // Mlock will control locking of memory - // Only active when Realtime is set to true Mlock bool // Stopped will not start guest CPU at startup Stopped bool - // Realtime will enable realtime QEMU - Realtime bool - // Exit instead of rebooting // Prevents QEMU from rebooting in the event of a Triple Fault. NoReboot bool @@ -2809,24 +2805,9 @@ func (config *Config) appendKnobs() { config.appendMemoryKnobs() - if config.Knobs.Realtime { - config.qemuParams = append(config.qemuParams, "-realtime") - // This path is redundant as the default behaviour is locked memory - // Realtime today does not control any other feature even though - // other features may be added in the future - // https://lists.gnu.org/archive/html/qemu-devel/2012-12/msg03330.html - if config.Knobs.Mlock { - config.qemuParams = append(config.qemuParams, "mlock=on") - } else { - config.qemuParams = append(config.qemuParams, "mlock=off") - } - } else { - // In order to turn mlock off we need the -realtime option as well - if !config.Knobs.Mlock { - //Enable realtime anyway just to get the right swapping behaviour - config.qemuParams = append(config.qemuParams, "-realtime") - config.qemuParams = append(config.qemuParams, "mlock=off") - } + if config.Knobs.Mlock { + config.qemuParams = append(config.qemuParams, "-overcommit") + config.qemuParams = append(config.qemuParams, "mem-lock=on") } if config.Knobs.Stopped { diff --git a/qemu/qemu_test.go b/qemu/qemu_test.go index 844ed085f4..07e55108cd 100644 --- a/qemu/qemu_test.go +++ b/qemu/qemu_test.go @@ -524,7 +524,7 @@ func TestAppendEmptyDevice(t *testing.T) { } func TestAppendKnobsAllTrue(t *testing.T) { - var knobsString = "-no-user-config -nodefaults -nographic --no-reboot -daemonize -realtime mlock=on -S" + var knobsString = "-no-user-config -nodefaults -nographic --no-reboot -daemonize -overcommit mem-lock=on -S" knobs := Knobs{ NoUserConfig: true, NoDefaults: true, @@ -534,7 +534,6 @@ func TestAppendKnobsAllTrue(t *testing.T) { MemPrealloc: true, FileBackedMem: true, MemShared: true, - Realtime: true, Mlock: true, Stopped: true, } @@ -543,7 +542,7 @@ func TestAppendKnobsAllTrue(t *testing.T) { } func TestAppendKnobsAllFalse(t *testing.T) { - var knobsString = "-realtime mlock=off" + var knobsString = "" knobs := Knobs{ NoUserConfig: false, NoDefaults: false, @@ -552,7 +551,6 @@ func TestAppendKnobsAllFalse(t *testing.T) { MemPrealloc: false, FileBackedMem: false, MemShared: false, - Realtime: false, Mlock: false, Stopped: false, } @@ -581,7 +579,6 @@ func TestAppendMemoryHugePages(t *testing.T) { objMemString := "-object memory-backend-file,id=dimm1,size=1G,mem-path=/dev/hugepages,share=on,prealloc=on" numaMemString := "-numa node,memdev=dimm1" memBackendString := "-machine memory-backend=dimm1" - mlockFalseString := "-realtime mlock=off" knobsString := objMemString + " " if isDimmSupported(nil) { @@ -590,7 +587,7 @@ func TestAppendMemoryHugePages(t *testing.T) { knobsString += memBackendString } - testConfigAppend(conf, knobs, memString+" "+knobsString+" "+mlockFalseString, t) + testConfigAppend(conf, knobs, memString+" "+knobsString, t) } func TestAppendMemoryMemPrealloc(t *testing.T) { @@ -612,7 +609,6 @@ func TestAppendMemoryMemPrealloc(t *testing.T) { objMemString := "-object memory-backend-ram,id=dimm1,size=1G,share=on,prealloc=on" numaMemString := "-numa node,memdev=dimm1" memBackendString := "-machine memory-backend=dimm1" - mlockFalseString := "-realtime mlock=off" knobsString := objMemString + " " if isDimmSupported(nil) { @@ -621,7 +617,7 @@ func TestAppendMemoryMemPrealloc(t *testing.T) { knobsString += memBackendString } - testConfigAppend(conf, knobs, memString+" "+knobsString+" "+mlockFalseString, t) + testConfigAppend(conf, knobs, memString+" "+knobsString, t) } func TestAppendMemoryMemShared(t *testing.T) { @@ -643,7 +639,6 @@ func TestAppendMemoryMemShared(t *testing.T) { objMemString := "-object memory-backend-file,id=dimm1,size=1G,mem-path=foobar,share=on" numaMemString := "-numa node,memdev=dimm1" memBackendString := "-machine memory-backend=dimm1" - mlockFalseString := "-realtime mlock=off" knobsString := objMemString + " " if isDimmSupported(nil) { @@ -652,7 +647,7 @@ func TestAppendMemoryMemShared(t *testing.T) { knobsString += memBackendString } - testConfigAppend(conf, knobs, memString+" "+knobsString+" "+mlockFalseString, t) + testConfigAppend(conf, knobs, memString+" "+knobsString, t) } func TestAppendMemoryFileBackedMem(t *testing.T) { @@ -674,7 +669,6 @@ func TestAppendMemoryFileBackedMem(t *testing.T) { objMemString := "-object memory-backend-file,id=dimm1,size=1G,mem-path=foobar" numaMemString := "-numa node,memdev=dimm1" memBackendString := "-machine memory-backend=dimm1" - mlockFalseString := "-realtime mlock=off" knobsString := objMemString + " " if isDimmSupported(nil) { @@ -683,7 +677,7 @@ func TestAppendMemoryFileBackedMem(t *testing.T) { knobsString += memBackendString } - testConfigAppend(conf, knobs, memString+" "+knobsString+" "+mlockFalseString, t) + testConfigAppend(conf, knobs, memString+" "+knobsString, t) } func TestAppendMemoryFileBackedMemPrealloc(t *testing.T) { @@ -706,7 +700,6 @@ func TestAppendMemoryFileBackedMemPrealloc(t *testing.T) { objMemString := "-object memory-backend-file,id=dimm1,size=1G,mem-path=foobar,share=on,prealloc=on" numaMemString := "-numa node,memdev=dimm1" memBackendString := "-machine memory-backend=dimm1" - mlockFalseString := "-realtime mlock=off" knobsString := objMemString + " " if isDimmSupported(nil) { @@ -715,7 +708,7 @@ func TestAppendMemoryFileBackedMemPrealloc(t *testing.T) { knobsString += memBackendString } - testConfigAppend(conf, knobs, memString+" "+knobsString+" "+mlockFalseString, t) + testConfigAppend(conf, knobs, memString+" "+knobsString, t) } func TestNoRebootKnob(t *testing.T) { @@ -725,9 +718,8 @@ func TestNoRebootKnob(t *testing.T) { NoReboot: true, } knobsString := "--no-reboot" - mlockFalseString := "-realtime mlock=off" - testConfigAppend(conf, knobs, knobsString+" "+mlockFalseString, t) + testConfigAppend(conf, knobs, knobsString, t) } var kernelString = "-kernel /opt/vmlinux.container -initrd /opt/initrd.container -append root=/dev/pmem0p1 rootflags=dax,data=ordered,errors=remount-ro rw rootfstype=ext4 tsc=reliable" @@ -1163,18 +1155,6 @@ func TestBadMemoryKnobs(t *testing.T) { } } -func TestBadKnobs(t *testing.T) { - c := &Config{ - Knobs: Knobs{ - Mlock: true, - }, - } - c.appendKnobs() - if len(c.qemuParams) != 0 { - t.Errorf("Expected empty qemuParams, found %s", c.qemuParams) - } -} - func TestBadBios(t *testing.T) { c := &Config{} c.appendBios()