summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2021-08-27 10:32:02 -0500
committerMatthew Heon <mheon@redhat.com>2021-08-30 15:15:26 -0400
commitbea10960809a18fb3e6306fdf5a2a8efc3eeac95 (patch)
tree6a1b72fc736bc98686befd34ed20cf9979a047c7 /pkg
parent68a059d89b297482d39530b7800fb03365ad0968 (diff)
downloadpodman-bea10960809a18fb3e6306fdf5a2a8efc3eeac95.tar.gz
podman-bea10960809a18fb3e6306fdf5a2a8efc3eeac95.tar.bz2
podman-bea10960809a18fb3e6306fdf5a2a8efc3eeac95.zip
clean up socket and pid files from podman machine
to avoid segvs, we should clean up as much of the socket and regular files from podman machine as possible on stop. also, on start, we should add logic to remove these files before starting in case the start process is stopped prematurely (due to an error for example). [NO TESTS NEEDED] Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/machine/qemu/machine.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go
index 646c84aba..ac70357c6 100644
--- a/pkg/machine/qemu/machine.go
+++ b/pkg/machine/qemu/machine.go
@@ -244,6 +244,7 @@ func (v *MachineVM) Start(name string, _ machine.StartOptions) error {
qemuSocketConn net.Conn
wait time.Duration = time.Millisecond * 500
)
+
if err := v.startHostNetworking(); err != nil {
return errors.Errorf("unable to start host networking: %q", err)
}
@@ -264,7 +265,11 @@ func (v *MachineVM) Start(name string, _ machine.StartOptions) error {
if err != nil {
return err
}
-
+ // If the qemusocketpath exists and the vm is off/down, we should rm
+ // it before the dial as to avoid a segv
+ if err := os.Remove(qemuSocketPath); err != nil && !errors.Is(err, os.ErrNotExist) {
+ logrus.Warn(err)
+ }
for i := 0; i < 6; i++ {
qemuSocketConn, err = net.Dial("unix", qemuSocketPath)
if err == nil {
@@ -352,7 +357,7 @@ func (v *MachineVM) Stop(name string, _ machine.StopOptions) error {
if _, err = qmpMonitor.Run(input); err != nil {
return err
}
- _, pidFile, err := v.getSocketandPid()
+ qemuSocketFile, pidFile, err := v.getSocketandPid()
if err != nil {
return err
}
@@ -373,7 +378,16 @@ func (v *MachineVM) Stop(name string, _ machine.StopOptions) error {
if p == nil && err != nil {
return err
}
- return p.Kill()
+ // Kill the process
+ if err := p.Kill(); err != nil {
+ return err
+ }
+ // Remove the pidfile
+ if err := os.Remove(pidFile); err != nil && !errors.Is(err, os.ErrNotExist) {
+ logrus.Warn(err)
+ }
+ // Remove socket
+ return os.Remove(qemuSocketFile)
}
// NewQMPMonitor creates the monitor subsection of our vm