From f7fe424e19c6d95da6366be966457640bbcfd2e6 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 21 Apr 2020 05:46:58 -0400 Subject: Throw error on IPv6 ip addresses Podman does not currently support IPv6 addresses. Signed-off-by: Daniel J Walsh --- cmd/podman/common/netflags.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cmd/podman/common') diff --git a/cmd/podman/common/netflags.go b/cmd/podman/common/netflags.go index 1a47733e7..a63605909 100644 --- a/cmd/podman/common/netflags.go +++ b/cmd/podman/common/netflags.go @@ -4,6 +4,7 @@ import ( "net" "github.com/containers/libpod/cmd/podman/parse" + "github.com/containers/libpod/libpod/define" "github.com/containers/libpod/pkg/domain/entities" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -148,6 +149,9 @@ func NetFlagsToNetOptions(cmd *cobra.Command) (*entities.NetOptions, error) { if staticIP == nil { return nil, errors.Errorf("%s is not an ip address", ip) } + if staticIP.To4() == nil { + return nil, errors.Wrapf(define.ErrInvalidArg, "%s is not an IPv4 address", ip) + } opts.StaticIP = &staticIP } -- cgit v1.2.3-54-g00ecf From 9d7b5947b9ff661433c4bedc018f5368830abbe6 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 21 Apr 2020 14:27:21 -0400 Subject: Fix handling of CGroupsParent and CGroupsMode Signed-off-by: Daniel J Walsh --- cmd/podman/common/create.go | 2 +- cmd/podman/common/create_opts.go | 2 +- cmd/podman/common/specgen.go | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'cmd/podman/common') diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go index f256d9677..f4c7059d1 100644 --- a/cmd/podman/common/create.go +++ b/cmd/podman/common/create.go @@ -55,7 +55,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet { "cgroup namespace to use", ) createFlags.StringVar( - &cf.CGroups, + &cf.CGroupsMode, "cgroups", containerConfig.Cgroups(), `control container cgroup configuration ("enabled"|"disabled"|"no-conmon")`, ) diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go index 9d12e4b26..37fe01460 100644 --- a/cmd/podman/common/create_opts.go +++ b/cmd/podman/common/create_opts.go @@ -11,7 +11,7 @@ type ContainerCLIOpts struct { CapAdd []string CapDrop []string CGroupsNS string - CGroups string + CGroupsMode string CGroupParent string CIDFile string ConmonPIDFile string diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go index 12fd16551..e8e889e66 100644 --- a/cmd/podman/common/specgen.go +++ b/cmd/podman/common/specgen.go @@ -124,7 +124,7 @@ func getPidsLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string) pids.Limit = c.PIDsLimit hasLimits = true } - if c.CGroups == "disabled" && c.PIDsLimit > 0 { + if c.CGroupsMode == "disabled" && c.PIDsLimit > 0 { s.ResourceLimits.Pids.Limit = -1 } if !hasLimits { @@ -473,12 +473,11 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string if ld := c.LogDriver; len(ld) > 0 { s.LogConfiguration.Driver = ld } + s.CgroupParent = c.CGroupParent + s.CgroupsMode = c.CGroupsMode // TODO WTF //cgroup := &cc.CgroupConfig{ - // Cgroups: c.String("cgroups"), // Cgroupns: c.String("cgroupns"), - // CgroupParent: c.String("cgroup-parent"), - // CgroupMode: cgroupMode, //} // //userns := &cc.UserConfig{ -- cgit v1.2.3-54-g00ecf From 592e7867a3fc2fa370f7f24125285e81fb0c6d1a Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 21 Apr 2020 08:22:05 -0400 Subject: Add support for devices from command line Signed-off-by: Daniel J Walsh --- cmd/podman/common/create.go | 2 +- cmd/podman/common/create_opts.go | 2 +- cmd/podman/common/specgen.go | 11 +++-------- 3 files changed, 5 insertions(+), 10 deletions(-) (limited to 'cmd/podman/common') diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go index f4c7059d1..bdf762ed7 100644 --- a/cmd/podman/common/create.go +++ b/cmd/podman/common/create.go @@ -125,7 +125,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet { "Override the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-`, where `` is one of: `a-cf`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`", ) createFlags.StringSliceVar( - &cf.Device, + &cf.Devices, "device", containerConfig.Devices(), fmt.Sprintf("Add a host device to the container"), ) diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go index 37fe01460..2f08bb6a6 100644 --- a/cmd/podman/common/create_opts.go +++ b/cmd/podman/common/create_opts.go @@ -25,7 +25,7 @@ type ContainerCLIOpts struct { CPUSetMems string Detach bool DetachKeys string - Device []string + Devices []string DeviceCGroupRule []string DeviceReadBPs []string DeviceReadIOPs []string diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go index e8e889e66..7818c628d 100644 --- a/cmd/podman/common/specgen.go +++ b/cmd/podman/common/specgen.go @@ -561,14 +561,9 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string //s.Mounts = c.Mount s.VolumesFrom = c.VolumesFrom - // TODO any idea why this was done - //devices := rtc.Containers.Devices - // TODO conflict on populate? - // - //if c.Changed("device") { - // devices = append(devices, c.StringSlice("device")...) - //} - + for _, dev := range c.Devices { + s.Devices = append(s.Devices, specs.LinuxDevice{Path: dev}) + } // TODO things i cannot find in spec // we dont think these are in the spec // init - initbinary -- cgit v1.2.3-54-g00ecf From bc56236102990c6719b7d185bc13c7c70240d211 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 21 Apr 2020 14:28:14 -0400 Subject: Handle hostname flag from client Signed-off-by: Daniel J Walsh --- cmd/podman/common/specgen.go | 1 + 1 file changed, 1 insertion(+) (limited to 'cmd/podman/common') diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go index 7818c628d..71010feb3 100644 --- a/cmd/podman/common/specgen.go +++ b/cmd/podman/common/specgen.go @@ -494,6 +494,7 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string // Hostname: c.String("hostname"), //} + s.Hostname = c.Hostname sysctl := map[string]string{} if ctl := c.Sysctl; len(ctl) > 0 { sysctl, err = util.ValidateSysctls(ctl) -- cgit v1.2.3-54-g00ecf