diff options
-rw-r--r-- | libpod/networking_linux.go | 8 | ||||
-rw-r--r-- | pkg/machine/qemu/machine.go | 20 |
2 files changed, 24 insertions, 4 deletions
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go index 5ade0849d..9aa6cab15 100644 --- a/libpod/networking_linux.go +++ b/libpod/networking_linux.go @@ -185,7 +185,13 @@ func (r *RootlessCNI) Do(toRun func() error) error { // if there is no symlink exit break } - resolvePath = filepath.Join(filepath.Dir(resolvePath), link) + if filepath.IsAbs(link) { + // link is as an absolute path + resolvePath = link + } else { + // link is as a relative, join it with the previous path + resolvePath = filepath.Join(filepath.Dir(resolvePath), link) + } if strings.HasPrefix(resolvePath, "/run/") { break } diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go index 871436618..38a16c3ef 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 |