summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpod/container_internal.go5
-rw-r--r--libpod/container_internal_linux.go5
-rw-r--r--libpod/networking_linux.go8
-rw-r--r--pkg/machine/qemu/machine.go20
-rw-r--r--test/e2e/run_volume_test.go20
5 files changed, 49 insertions, 9 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 6717ada59..9082b136a 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -1072,6 +1072,11 @@ func (c *Container) init(ctx context.Context, retainRetries bool) error {
return err
}
+ // Make sure the workdir exists while initializing container
+ if err := c.resolveWorkDir(); err != nil {
+ return err
+ }
+
// Save the OCI newSpec to disk
if err := c.saveSpec(newSpec); err != nil {
return err
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 8b73c82de..b624f44ac 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -176,11 +176,6 @@ func (c *Container) prepare() error {
return err
}
- // Make sure the workdir exists
- if err := c.resolveWorkDir(); err != nil {
- return err
- }
-
return nil
}
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
diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go
index d1f6ea80e..59937b6c0 100644
--- a/test/e2e/run_volume_test.go
+++ b/test/e2e/run_volume_test.go
@@ -222,6 +222,26 @@ var _ = Describe("Podman run with volumes", func() {
Expect(matches[0]).To(Not(ContainSubstring("nosuid")))
})
+ // Container should start when workdir is overlayed volume
+ It("podman run with volume mounted as overlay and used as workdir", func() {
+ SkipIfRemote("Overlay volumes only work locally")
+ if os.Getenv("container") != "" {
+ Skip("Overlay mounts not supported when running in a container")
+ }
+ if rootless.IsRootless() {
+ if _, err := exec.LookPath("fuse-overlayfs"); err != nil {
+ Skip("Fuse-Overlayfs required for rootless overlay mount test")
+ }
+ }
+ mountPath := filepath.Join(podmanTest.TempDir, "secrets")
+ os.Mkdir(mountPath, 0755)
+
+ //Container should be able to start with custom overlayed volume
+ session := podmanTest.Podman([]string{"run", "--rm", "-v", mountPath + ":/data:O", "--workdir=/data", ALPINE, "echo", "hello"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ })
+
It("podman run with noexec can't exec", func() {
session := podmanTest.Podman([]string{"run", "--rm", "-v", "/bin:/hostbin:noexec", ALPINE, "/hostbin/ls", "/"})
session.WaitWithDefaultTimeout()