1
0
mirror of https://github.com/kata-containers/kata-containers.git synced 2025-04-29 04:04:45 +00:00

qemu: Add NoReboot config Knob for qemuParams

The Kata architecture does not support rebooting VMs (the lifecycle
being start/exec/kill) and if a VM is killed (e.g. using sysrq-trigger),
the VM does not exit fully and other layers do not notice the state change.
Kata needs a way to tell QEMU to run with the '--no-reboot' option
so that the guest VM exits and does not attempt to reboot.

Add a NoReboot boolean Knob so when Knobs.NoReboot is set, the '--no-reboot'
command-line option will be passed to QEMU on startup.

Signed-off-by: Liam Merwick <liam.merwick@oracle.com>
This commit is contained in:
Liam Merwick 2020-07-20 13:56:17 +01:00
parent af9e34b91a
commit 6645baf249
2 changed files with 22 additions and 1 deletions

View File

@ -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")
}

View File

@ -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) {