Merge pull request #10850 from baude/issue10824

Create podman temp dir on machine start
This commit is contained in:
OpenShift Merge Robot
2021-07-02 20:10:04 -04:00
committed by GitHub

View File

@ -15,9 +15,8 @@ import (
"strings" "strings"
"time" "time"
"github.com/containers/podman/v3/pkg/rootless"
"github.com/containers/podman/v3/pkg/machine" "github.com/containers/podman/v3/pkg/machine"
"github.com/containers/podman/v3/pkg/rootless"
"github.com/containers/podman/v3/utils" "github.com/containers/podman/v3/utils"
"github.com/containers/storage/pkg/homedir" "github.com/containers/storage/pkg/homedir"
"github.com/digitalocean/go-qemu/qmp" "github.com/digitalocean/go-qemu/qmp"
@ -248,7 +247,23 @@ func (v *MachineVM) Start(name string, _ machine.StartOptions) error {
if err := v.startHostNetworking(); err != nil { if err := v.startHostNetworking(); err != nil {
return errors.Errorf("unable to start host networking: %q", err) return errors.Errorf("unable to start host networking: %q", err)
} }
rtPath, err := getRuntimeDir()
if err != nil {
return err
}
// If the temporary podman dir is not created, create it
podmanTempDir := filepath.Join(rtPath, "podman")
if _, err := os.Stat(podmanTempDir); os.IsNotExist(err) {
if mkdirErr := os.MkdirAll(podmanTempDir, 0755); mkdirErr != nil {
return err
}
}
qemuSocketPath, _, err := v.getSocketandPid() qemuSocketPath, _, err := v.getSocketandPid()
if err != nil {
return err
}
for i := 0; i < 6; i++ { for i := 0; i < 6; i++ {
qemuSocketConn, err = net.Dial("unix", qemuSocketPath) qemuSocketConn, err = net.Dial("unix", qemuSocketPath)
@ -258,9 +273,6 @@ func (v *MachineVM) Start(name string, _ machine.StartOptions) error {
time.Sleep(wait) time.Sleep(wait)
wait++ wait++
} }
if err != nil {
return err
}
fd, err := qemuSocketConn.(*net.UnixConn).File() fd, err := qemuSocketConn.(*net.UnixConn).File()
if err != nil { if err != nil {