summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-01-10 15:58:18 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-01-11 12:39:06 +0000
commitdd0d35deb098b63f8c5be7ef9d8d63c16760221b (patch)
tree695d44a49d636e45e4121c9aecfb3d8c0e1cca06 /cmd
parente6be800ec633342aef656e0a2ed0bdc4519796d9 (diff)
downloadpodman-dd0d35deb098b63f8c5be7ef9d8d63c16760221b.tar.gz
podman-dd0d35deb098b63f8c5be7ef9d8d63c16760221b.tar.bz2
podman-dd0d35deb098b63f8c5be7ef9d8d63c16760221b.zip
Add support for shm-size.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #206 Approved by: TomSweeneyRedHat
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/common.go3
-rw-r--r--cmd/podman/create.go11
-rw-r--r--cmd/podman/inspect.go2
-rw-r--r--cmd/podman/run.go1
-rw-r--r--cmd/podman/spec.go18
5 files changed, 28 insertions, 7 deletions
diff --git a/cmd/podman/common.go b/cmd/podman/common.go
index e3997539a..e0ef43782 100644
--- a/cmd/podman/common.go
+++ b/cmd/podman/common.go
@@ -377,7 +377,8 @@ var createFlags = []cli.Flag{
},
cli.StringFlag{
Name: "shm-size",
- Usage: "Size of `/dev/shm`. The format is `<number><unit>`. default is 64 MB",
+ Usage: "Size of `/dev/shm`. The format is `<number><unit>`.",
+ Value: "65536k",
},
cli.BoolFlag{
Name: "sig-proxy",
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index bb9a31467..ce06ac51b 100644
--- a/cmd/podman/create.go
+++ b/cmd/podman/create.go
@@ -62,7 +62,7 @@ type createResourceConfig struct {
MemorySwappiness int // memory-swappiness
OomScoreAdj int //oom-score-adj
PidsLimit int64 // pids-limit
- ShmSize string
+ ShmSize int64
Ulimit []string //ulimit
}
@@ -179,6 +179,7 @@ func createCmd(c *cli.Context) error {
options = append(options, libpod.WithLabels(createConfig.Labels))
options = append(options, libpod.WithUser(createConfig.User))
options = append(options, libpod.WithShmDir(createConfig.ShmDir))
+ options = append(options, libpod.WithShmSize(createConfig.Resources.ShmSize))
ctr, err := runtime.NewContainer(runtimeSpec, options...)
if err != nil {
return err
@@ -524,6 +525,12 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime) (*createConfig, er
return nil, err
}
+ // SHM SIze
+ shmSize, err := units.FromHumanSize(c.String("shm-size"))
+ if err != nil {
+ return nil, errors.Wrapf(err, "unable to translate --shm-size")
+ }
+
config := &createConfig{
Runtime: runtime,
CapAdd: c.StringSlice("cap-add"),
@@ -580,7 +587,7 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime) (*createConfig, er
DeviceWriteBps: c.StringSlice("device-write-bps"),
DeviceWriteIOps: c.StringSlice("device-write-iops"),
DisableOomKiller: c.Bool("oom-kill-disable"),
- ShmSize: c.String("shm-size"),
+ ShmSize: shmSize,
Memory: memoryLimit,
MemoryReservation: memoryReservation,
MemorySwap: memorySwap,
diff --git a/cmd/podman/inspect.go b/cmd/podman/inspect.go
index dc5810492..5e9fc53bb 100644
--- a/cmd/podman/inspect.go
+++ b/cmd/podman/inspect.go
@@ -320,7 +320,7 @@ type HostConfig struct {
SecurityOpt []string `json:"SecurityOpt"`
UTSMode string `json:"UTSMode"`
UsernsMode string `json:"UsernsMode"`
- ShmSize string `json:"ShmSize"`
+ ShmSize int64 `json:"ShmSize"`
Runtime string `json:"Runtime"`
ConsoleSize *specs.Box `json:"ConsoleSize"`
Isolation string `json:"Isolation"` //TODO
diff --git a/cmd/podman/run.go b/cmd/podman/run.go
index 45a428f39..07af4a6a2 100644
--- a/cmd/podman/run.go
+++ b/cmd/podman/run.go
@@ -56,6 +56,7 @@ func runCmd(c *cli.Context) error {
options = append(options, libpod.WithLabels(createConfig.Labels))
options = append(options, libpod.WithUser(createConfig.User))
options = append(options, libpod.WithShmDir(createConfig.ShmDir))
+ options = append(options, libpod.WithShmSize(createConfig.Resources.ShmSize))
ctr, err := runtime.NewContainer(runtimeSpec, options...)
if err != nil {
return err
diff --git a/cmd/podman/spec.go b/cmd/podman/spec.go
index 342b80d9e..d630b2f50 100644
--- a/cmd/podman/spec.go
+++ b/cmd/podman/spec.go
@@ -189,7 +189,13 @@ func addDevice(g *generate.Generator, device string) error {
// Parses information needed to create a container into an OCI runtime spec
func createConfigToOCISpec(config *createConfig) (*spec.Spec, error) {
g := generate.New()
- g.AddCgroupsMount("ro")
+ cgroupMnt := spec.Mount{
+ Destination: "/sys/fs/cgroup",
+ Type: "cgroup",
+ Source: "cgroup",
+ Options: []string{"nosuid", "noexec", "nodev", "relatime", "ro"},
+ }
+ g.AddMount(cgroupMnt)
g.SetProcessCwd(config.WorkDir)
g.SetProcessArgs(config.Command)
g.SetProcessTerminal(config.Tty)
@@ -273,6 +279,7 @@ func createConfigToOCISpec(config *createConfig) (*spec.Spec, error) {
}
for _, i := range config.Tmpfs {
+ // Default options if nothing passed
options := []string{"rw", "noexec", "nosuid", "nodev", "size=65536k"}
spliti := strings.SplitN(i, ":", 2)
if len(spliti) > 1 {
@@ -281,8 +288,13 @@ func createConfigToOCISpec(config *createConfig) (*spec.Spec, error) {
}
options = strings.Split(spliti[1], ",")
}
- // Default options if nothing passed
- g.AddTmpfsMount(spliti[0], append(options, "tmpcopyup"))
+ tmpfsMnt := spec.Mount{
+ Destination: spliti[0],
+ Type: "tmpfs",
+ Source: "tmpfs",
+ Options: append(options, "tmpcopyup"),
+ }
+ g.AddMount(tmpfsMnt)
}
for name, val := range config.Env {