mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 03:42:09 +00:00
qmp: wait for POWERDOWN event in ExecuteSystemPowerdown()
ExecuteSystemPowerdown issues `system_powerdown` and waits for `SHUTDOWN`. The event emitted is `POWERDOWN` per spec. Without this we get an error even though the VM has shutdown gracefully. Per QEMU spec: ``` POWERDOWN (Event) Emitted when the virtual machine is powered down through the power control system, such as via ACPI. Since 0.12 Example <- { "event": "POWERDOWN", "timestamp": { "seconds": 1267040730, "microseconds": 682951 } } SHUTDOWN (Event) Emitted when the virtual machine has shut down, indicating that qemu is about to exit. Arguments guest: boolean If true, the shutdown was triggered by a guest request (such as a guest-initiated ACPI shutdown request or other hardware-specific action) rather than a host request (such as sending qemu a SIGINT). (since 2.10) reason: ShutdownCause The ShutdownCause which resulted in the SHUTDOWN. (since 4.0) Note If the command-line option “-no-shutdown” has been specified, qemu will not exit, and a STOP event will eventually follow the SHUTDOWN event Since 0.12 Example <- { "event": "SHUTDOWN", "data": { "guest": true }, "timestamp": { "seconds": 1267040730, "microseconds": 682951 } } ``` Signed-off-by: Manohar Castelino <mcastelino@apple.com>
This commit is contained in:
parent
2f8e417bb2
commit
1ed52714c0
@ -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)
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user