Skip to content

Commit

Permalink
lxd: Make VM shutdown/reboot exit cleanly
Browse files Browse the repository at this point in the history
Closes lxc/incus#256

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
Signed-off-by: hamistao <pedro.ribeiro@canonical.com>
License: Apache-2.0
  • Loading branch information
stgraber authored and hamistao committed Sep 6, 2024
1 parent 8c48af1 commit 8665ae0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lxd/instance_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/canonical/lxd/lxd/cluster"
"github.com/canonical/lxd/lxd/db/operationtype"
"github.com/canonical/lxd/lxd/instance"
"github.com/canonical/lxd/lxd/instance/drivers"
"github.com/canonical/lxd/lxd/instance/instancetype"
"github.com/canonical/lxd/lxd/operations"
"github.com/canonical/lxd/lxd/request"
Expand Down Expand Up @@ -289,7 +290,14 @@ func (s *execWs) Do(op *operations.Operation) error {
_ = pty.Close()
}

// Make VM disconnections (shutdown/reboot) match containers.
if cmdErr == drivers.ErrExecDisconnected {
cmdResult = 129
cmdErr = nil
}

metadata := shared.Jmap{"return": cmdResult}

err = op.ExtendMetadata(metadata)
if err != nil {
return err
Expand Down

0 comments on commit 8665ae0

Please sign in to comment.