diff --git a/qemu/qemu.go b/qemu/qemu.go index 4716595cd7..d5a01c87a8 100644 --- a/qemu/qemu.go +++ b/qemu/qemu.go @@ -2122,6 +2122,9 @@ type Knobs struct { // Realtime will enable realtime QEMU Realtime bool + + // Exit instead of rebooting + NoReboot bool } // IOThread allows IO to be performed on a separate thread. @@ -2457,6 +2460,10 @@ func (config *Config) appendKnobs() { config.qemuParams = append(config.qemuParams, "-nographic") } + if config.Knobs.NoReboot { + config.qemuParams = append(config.qemuParams, "--no-reboot") + } + if config.Knobs.Daemonize { config.qemuParams = append(config.qemuParams, "-daemonize") } diff --git a/qemu/qemu_test.go b/qemu/qemu_test.go index 2e7669a151..30dedf9727 100644 --- a/qemu/qemu_test.go +++ b/qemu/qemu_test.go @@ -501,11 +501,12 @@ func TestAppendEmptyDevice(t *testing.T) { } func TestAppendKnobsAllTrue(t *testing.T) { - var knobsString = "-no-user-config -nodefaults -nographic -daemonize -realtime mlock=on -S" + var knobsString = "-no-user-config -nodefaults -nographic --no-reboot -daemonize -realtime mlock=on -S" knobs := Knobs{ NoUserConfig: true, NoDefaults: true, NoGraphic: true, + NoReboot: true, Daemonize: true, MemPrealloc: true, FileBackedMem: true, @@ -524,6 +525,7 @@ func TestAppendKnobsAllFalse(t *testing.T) { NoUserConfig: false, NoDefaults: false, NoGraphic: false, + NoReboot: false, MemPrealloc: false, FileBackedMem: false, MemShared: false, @@ -668,6 +670,18 @@ func TestAppendMemoryFileBackedMemPrealloc(t *testing.T) { testConfigAppend(conf, knobs, memString+" "+knobsString+" "+mlockFalseString, t) } +func TestNoRebootKnob(t *testing.T) { + conf := &Config{} + + knobs := Knobs{ + NoReboot: true, + } + knobsString := "--no-reboot" + mlockFalseString := "-realtime mlock=off" + + testConfigAppend(conf, knobs, knobsString+" "+mlockFalseString, 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" func TestAppendKernel(t *testing.T) {