diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-02-19 10:59:22 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-19 10:59:22 -0500 |
commit | b6db60e58f2f5abb4902c28c91e770495f3d4926 (patch) | |
tree | 13c2a79df6e96b7cdf38310d6a0386db16ba0c17 /cmd | |
parent | c12576501c01f5317f140634bcc6e02d45d88716 (diff) | |
parent | d6b0b54121558027d087b9dcd157cb7df9d0a778 (diff) | |
download | podman-b6db60e58f2f5abb4902c28c91e770495f3d4926.tar.gz podman-b6db60e58f2f5abb4902c28c91e770495f3d4926.tar.bz2 podman-b6db60e58f2f5abb4902c28c91e770495f3d4926.zip |
Merge pull request #9430 from baude/issue9429
Fix segfault in run with memory-swap
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/common/specgen.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go index 975c76fd9..eff8b43aa 100644 --- a/cmd/podman/common/specgen.go +++ b/cmd/podman/common/specgen.go @@ -148,17 +148,16 @@ func getMemoryLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts) (*specs.Linu } if m := c.MemorySwap; len(m) > 0 { var ms int64 - if m == "-1" { - ms = int64(-1) - s.ResourceLimits.Memory.Swap = &ms - } else { + // only set memory swap if it was set + // -1 indicates unlimited + if m != "-1" { ms, err = units.RAMInBytes(m) + memory.Swap = &ms if err != nil { return nil, errors.Wrapf(err, "invalid value for memory") } + hasLimits = true } - memory.Swap = &ms - hasLimits = true } if m := c.KernelMemory; len(m) > 0 { mk, err := units.RAMInBytes(m) |