@@ -16,6 +16,8 @@ import (
1616 "github.com/opencontainers/runtime-tools/generate"
1717 "github.com/opencontainers/runtime-tools/generate/seccomp"
1818 "github.com/urfave/cli"
19+
20+ mpolCheck "github.com/opencontainers/runtime-tools/validate/memorypolicy"
1921)
2022
2123var generateFlags = []cli.Flag {
@@ -64,6 +66,9 @@ var generateFlags = []cli.Flag{
6466 cli.StringFlag {Name : "linux-mems" , Usage : "list of memory nodes in the cpuset (default is to use any available memory node)" },
6567 cli.Uint64Flag {Name : "linux-mem-swap" , Usage : "total memory limit (memory + swap) (in bytes)" },
6668 cli.Uint64Flag {Name : "linux-mem-swappiness" , Usage : "how aggressive the kernel will swap memory pages (Range from 0 to 100)" },
69+ cli.StringFlag {Name : "linux-memorypolicy-mode" , Usage : "memory policy defines from which nodes memory is allocated by default, e.g MPOL_INTERLEAVE" },
70+ cli.StringFlag {Name : "linux-memorypolicy-nodes" , Usage : "memory nodes related to the linux-memorypolicy-mode, e.g 0-3,7" },
71+ cli.StringSliceFlag {Name : "linux-memorypolicy-flags" , Usage : "optional memory policy mode flags, e.g MPOL_F_STATIC_NODES" },
6772 cli.StringFlag {Name : "linux-mount-label" , Usage : "selinux mount context label" },
6873 cli.StringSliceFlag {Name : "linux-namespace-add" , Usage : "adds a namespace to the set of namespaces to create or join of the form 'ns[:path]'" },
6974 cli.StringSliceFlag {Name : "linux-namespace-remove" , Usage : "removes a namespace from the set of namespaces to create or join of the form 'ns'" },
@@ -782,6 +787,28 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
782787 g .SetLinuxResourcesMemorySwappiness (context .Uint64 ("linux-mem-swappiness" ))
783788 }
784789
790+ if context .IsSet ("linux-memorypolicy-mode" ) {
791+ mpolMode := context .String ("linux-memorypolicy-mode" )
792+ if err := mpolCheck .MpolModeValid (mpolMode ); err != nil {
793+ return err
794+ }
795+ g .SetLinuxMemoryPolicyMode (mpolMode )
796+ }
797+
798+ if context .IsSet ("linux-memorypolicy-nodes" ) {
799+ g .SetLinuxMemoryPolicyNodes (context .String ("linux-memorypolicy-nodes" ))
800+ }
801+
802+ if context .IsSet ("linux-memorypolicy-flags" ) {
803+ mpolFlags := context .StringSlice ("linux-memorypolicy-flags" )
804+ for _ , flag := range mpolFlags {
805+ if err := mpolCheck .MpolFlagValid (flag ); err != nil {
806+ return err
807+ }
808+ }
809+ g .SetLinuxMemoryPolicyFlags (mpolFlags )
810+ }
811+
785812 if context .IsSet ("linux-network-classid" ) {
786813 g .SetLinuxResourcesNetworkClassID (uint32 (context .Int ("linux-network-classid" )))
787814 }
0 commit comments