summaryrefslogtreecommitdiff
path: root/pkg/machine
diff options
context:
space:
mode:
authoropenshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com>2022-06-16 12:12:09 +0000
committerGitHub <noreply@github.com>2022-06-16 12:12:09 +0000
commit82936d89887d8a649c6e439cef85304882c44c46 (patch)
treed6363af198a03b4701a6adf1edbb1ff5cd7498f4 /pkg/machine
parenta90dac9454698fd024bcac49b371701355ffaf24 (diff)
parente69691c27747a5089658009418a3e427a93b3910 (diff)
downloadpodman-82936d89887d8a649c6e439cef85304882c44c46.tar.gz
podman-82936d89887d8a649c6e439cef85304882c44c46.tar.bz2
podman-82936d89887d8a649c6e439cef85304882c44c46.zip
Merge pull request #14610 from shanesmith/fix-machine-start-interrupt
Fix interrupting machine start leaves the machine unstartable
Diffstat (limited to 'pkg/machine')
-rw-r--r--pkg/machine/qemu/machine.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go
index f27e40043..288b2eeb0 100644
--- a/pkg/machine/qemu/machine.go
+++ b/pkg/machine/qemu/machine.go
@@ -16,9 +16,11 @@ import (
"net/url"
"os"
"os/exec"
+ "os/signal"
"path/filepath"
"strconv"
"strings"
+ "syscall"
"time"
"github.com/containers/common/pkg/config"
@@ -484,12 +486,26 @@ func (v *MachineVM) Start(name string, _ machine.StartOptions) error {
if err := v.writeConfig(); err != nil {
return fmt.Errorf("writing JSON file: %w", err)
}
- defer func() {
+ doneStarting := func() {
v.Starting = false
if err := v.writeConfig(); err != nil {
logrus.Errorf("Writing JSON file: %v", err)
}
+ }
+ defer doneStarting()
+
+ c := make(chan os.Signal, 1)
+ signal.Notify(c, os.Interrupt, syscall.SIGTERM)
+ go func() {
+ _, ok := <-c
+ if !ok {
+ return
+ }
+ doneStarting()
+ os.Exit(1)
}()
+ defer close(c)
+
if v.isIncompatible() {
logrus.Errorf("machine %q is incompatible with this release of podman and needs to be recreated, starting for recovery only", v.Name)
}