Merge pull request #202 from mcastelino/topic/fix-shutdown

Add clean shutdown support
This commit is contained in:
Eric Ernst 2021-09-16 14:20:51 -07:00 committed by GitHub
commit c4da1a902a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -2421,8 +2421,12 @@ type Knobs struct {
Realtime bool Realtime bool
// Exit instead of rebooting // Exit instead of rebooting
// Prevents QEMU from rebooting in the event of a Triple Fault.
NoReboot bool NoReboot bool
// Dont exit QEMU on guest shutdown, but instead only stop the emulation.
NoShutdown bool
// IOMMUPlatform will enable IOMMU for supported devices // IOMMUPlatform will enable IOMMU for supported devices
IOMMUPlatform bool IOMMUPlatform bool
} }
@ -2795,6 +2799,10 @@ func (config *Config) appendKnobs() {
config.qemuParams = append(config.qemuParams, "--no-reboot") config.qemuParams = append(config.qemuParams, "--no-reboot")
} }
if config.Knobs.NoShutdown {
config.qemuParams = append(config.qemuParams, "--no-shutdown")
}
if config.Knobs.Daemonize { if config.Knobs.Daemonize {
config.qemuParams = append(config.qemuParams, "-daemonize") config.qemuParams = append(config.qemuParams, "-daemonize")
} }

View File

@ -761,7 +761,7 @@ func (q *QMP) ExecuteCont(ctx context.Context) error {
// This function will block until the SHUTDOWN event is received. // This function will block until the SHUTDOWN event is received.
func (q *QMP) ExecuteSystemPowerdown(ctx context.Context) error { func (q *QMP) ExecuteSystemPowerdown(ctx context.Context) error {
filter := &qmpEventFilter{ filter := &qmpEventFilter{
eventName: "SHUTDOWN", eventName: "POWERDOWN",
} }
return q.executeCommand(ctx, "system_powerdown", nil, filter) return q.executeCommand(ctx, "system_powerdown", nil, filter)
} }

View File

@ -802,7 +802,7 @@ func TestQMPSystemPowerdown(t *testing.T) {
disconnectedCh := make(chan struct{}) disconnectedCh := make(chan struct{})
buf := newQMPTestCommandBuffer(t) buf := newQMPTestCommandBuffer(t)
buf.AddCommand("system_powerdown", nil, "return", nil) buf.AddCommand("system_powerdown", nil, "return", nil)
buf.AddEvent("SHUTDOWN", time.Millisecond*100, buf.AddEvent("POWERDOWN", time.Millisecond*100,
nil, nil,
map[string]interface{}{ map[string]interface{}{
"seconds": seconds, "seconds": seconds,