Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request #131 from merwick/master
Browse files Browse the repository at this point in the history
qemu: Add NoReboot config Knob for qemuParams
  • Loading branch information
Julio Montes committed Jul 28, 2020
2 parents af9e34b + 6645baf commit 6c3315b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 7 additions & 0 deletions qemu/qemu.go
Expand Up @@ -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.
Expand Down Expand Up @@ -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")
}
Expand Down
16 changes: 15 additions & 1 deletion qemu/qemu_test.go
Expand Up @@ -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,
Expand All @@ -524,6 +525,7 @@ func TestAppendKnobsAllFalse(t *testing.T) {
NoUserConfig: false,
NoDefaults: false,
NoGraphic: false,
NoReboot: false,
MemPrealloc: false,
FileBackedMem: false,
MemShared: false,
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 6c3315b

Please sign in to comment.