diff --git a/qemu/qemu.go b/qemu/qemu.go index e57a4b26a9..f1c67e4fe3 100644 --- a/qemu/qemu.go +++ b/qemu/qemu.go @@ -2421,8 +2421,12 @@ type Knobs struct { Realtime bool // Exit instead of rebooting + // Prevents QEMU from rebooting in the event of a Triple Fault. NoReboot bool + // Don’t exit QEMU on guest shutdown, but instead only stop the emulation. + NoShutdown bool + // IOMMUPlatform will enable IOMMU for supported devices IOMMUPlatform bool } @@ -2795,6 +2799,10 @@ func (config *Config) appendKnobs() { config.qemuParams = append(config.qemuParams, "--no-reboot") } + if config.Knobs.NoShutdown { + config.qemuParams = append(config.qemuParams, "--no-shutdown") + } + if config.Knobs.Daemonize { config.qemuParams = append(config.qemuParams, "-daemonize") } diff --git a/qemu/qmp.go b/qemu/qmp.go index f8a33334c2..a7afc6dcd1 100644 --- a/qemu/qmp.go +++ b/qemu/qmp.go @@ -761,7 +761,7 @@ func (q *QMP) ExecuteCont(ctx context.Context) error { // This function will block until the SHUTDOWN event is received. func (q *QMP) ExecuteSystemPowerdown(ctx context.Context) error { filter := &qmpEventFilter{ - eventName: "SHUTDOWN", + eventName: "POWERDOWN", } return q.executeCommand(ctx, "system_powerdown", nil, filter) } diff --git a/qemu/qmp_test.go b/qemu/qmp_test.go index 38153f914e..d541b284ab 100644 --- a/qemu/qmp_test.go +++ b/qemu/qmp_test.go @@ -802,7 +802,7 @@ func TestQMPSystemPowerdown(t *testing.T) { disconnectedCh := make(chan struct{}) buf := newQMPTestCommandBuffer(t) buf.AddCommand("system_powerdown", nil, "return", nil) - buf.AddEvent("SHUTDOWN", time.Millisecond*100, + buf.AddEvent("POWERDOWN", time.Millisecond*100, nil, map[string]interface{}{ "seconds": seconds,