@@ -40,6 +40,8 @@ var generateFlags = []cli.Flag{
4040 cli.StringSliceFlag {Name : "linux-device-add" , Usage : "add a device which must be made available in the container" },
4141 cli.StringSliceFlag {Name : "linux-device-remove" , Usage : "remove a device which must be made available in the container" },
4242 cli.BoolFlag {Name : "linux-device-remove-all" , Usage : "remove all devices which must be made available in the container" },
43+ cli.StringSliceFlag {Name : "linux-device-cgroup-add" , Usage : "add a device access rule" },
44+ cli.StringSliceFlag {Name : "linux-device-cgroup-remove" , Usage : "remove a device access rule" },
4345 cli.BoolFlag {Name : "linux-disable-oom-kill" , Usage : "disable OOM Killer" },
4446 cli.StringSliceFlag {Name : "linux-gidmappings" , Usage : "add GIDMappings e.g HostID:ContainerID:Size" },
4547 cli.StringSliceFlag {Name : "linux-hugepage-limits-add" , Usage : "add hugepage resource limits" },
@@ -63,8 +65,6 @@ var generateFlags = []cli.Flag{
6365 cli.StringSliceFlag {Name : "linux-readonly-paths" , Usage : "specifies paths readonly inside container" },
6466 cli.Int64Flag {Name : "linux-realtime-period" , Usage : "CPU period to be used for realtime scheduling (in usecs)" },
6567 cli.Int64Flag {Name : "linux-realtime-runtime" , Usage : "the time realtime scheduling may use (in usecs)" },
66- cli.StringSliceFlag {Name : "linux-resources-device-add" , Usage : "add a device access rule" },
67- cli.StringSliceFlag {Name : "linux-resources-device-remove" , Usage : "remove a device access rule" },
6868 cli.StringFlag {Name : "linux-rootfs-propagation" , Usage : "mount propagation for rootfs" },
6969 cli.StringFlag {Name : "linux-seccomp-allow" , Usage : "specifies syscalls to respond with allow" },
7070 cli.StringFlag {Name : "linux-seccomp-arch" , Usage : "specifies additional architectures permitted to be used for system calls" },
@@ -243,8 +243,8 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
243243 }
244244 }
245245
246- if context .IsSet ("linux-resources- device-add" ) {
247- devices := context .StringSlice ("linux-resources- device-add" )
246+ if context .IsSet ("linux-device-cgroup -add" ) {
247+ devices := context .StringSlice ("linux-device-cgroup -add" )
248248 for _ , device := range devices {
249249 dev , err := parseLinuxResourcesDeviceAccess (device , g )
250250 if err != nil {
@@ -254,8 +254,8 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
254254 }
255255 }
256256
257- if context .IsSet ("linux-resources- device-remove" ) {
258- devices := context .StringSlice ("linux-resources- device-remove" )
257+ if context .IsSet ("linux-device-cgroup -remove" ) {
258+ devices := context .StringSlice ("linux-device-cgroup -remove" )
259259 for _ , device := range devices {
260260 dev , err := parseLinuxResourcesDeviceAccess (device , g )
261261 if err != nil {
@@ -835,7 +835,6 @@ func parseRlimit(rlimit string) (string, uint64, uint64, error) {
835835 return parts [0 ], uint64 (hard ), uint64 (soft ), nil
836836}
837837
838- << << << < 9e0 e42dbf918070406a2a4a2e1476e7350ba9129
839838func parseNamespace (ns string ) (string , string , error ) {
840839 parts := strings .SplitN (ns , ":" , 2 )
841840 if len (parts ) == 0 || parts [0 ] == "" {
@@ -943,7 +942,7 @@ var cgroupDeviceAccess = map[string]bool{
943942}
944943
945944// parseLinuxResourcesDeviceAccess parses the raw string passed with the --device-access-add flag
946- func parseLinuxResourcesDeviceAccess (device string , g * generate.Generator ) (rspec.DeviceCgroup , error ) {
945+ func parseLinuxResourcesDeviceAccess (device string , g * generate.Generator ) (rspec.LinuxDeviceCgroup , error ) {
947946 var allow bool
948947 var devType , access string
949948 var major , minor * int64
@@ -956,7 +955,7 @@ func parseLinuxResourcesDeviceAccess(device string, g *generate.Generator) (rspe
956955 case "deny" :
957956 allow = false
958957 default :
959- return rspec.DeviceCgroup {},
958+ return rspec.LinuxDeviceCgroup {},
960959 fmt .Errorf ("Only 'allow' and 'deny' are allowed in the first field of device-access-add: %s" , device )
961960 }
962961
@@ -967,38 +966,38 @@ func parseLinuxResourcesDeviceAccess(device string, g *generate.Generator) (rspe
967966 }
968967 parts := strings .SplitN (s , "=" , 2 )
969968 if len (parts ) != 2 {
970- return rspec.DeviceCgroup {}, fmt .Errorf ("Incomplete device-access-add arguments: %s" , s )
969+ return rspec.LinuxDeviceCgroup {}, fmt .Errorf ("Incomplete device-access-add arguments: %s" , s )
971970 }
972971 name , value := parts [0 ], parts [1 ]
973972
974973 switch name {
975974 case "type" :
976975 if ! cgroupDeviceType [value ] {
977- return rspec.DeviceCgroup {}, fmt .Errorf ("Invalid device type in device-access-add: %s" , value )
976+ return rspec.LinuxDeviceCgroup {}, fmt .Errorf ("Invalid device type in device-access-add: %s" , value )
978977 }
979- devType = & value
978+ devType = value
980979 case "major" :
981980 i , err := strconv .ParseInt (value , 10 , 64 )
982981 if err != nil {
983- return rspec.DeviceCgroup {}, err
982+ return rspec.LinuxDeviceCgroup {}, err
984983 }
985984 major = & i
986985 case "minor" :
987986 i , err := strconv .ParseInt (value , 10 , 64 )
988987 if err != nil {
989- return rspec.DeviceCgroup {}, err
988+ return rspec.LinuxDeviceCgroup {}, err
990989 }
991990 minor = & i
992991 case "access" :
993992 for _ , c := range strings .Split (value , "" ) {
994993 if ! cgroupDeviceAccess [c ] {
995- return rspec.DeviceCgroup {}, fmt .Errorf ("Invalid device access in device-access-add: %s" , c )
994+ return rspec.LinuxDeviceCgroup {}, fmt .Errorf ("Invalid device access in device-access-add: %s" , c )
996995 }
997996 }
998- access = & value
997+ access = value
999998 }
1000999 }
1001- return rspec.DeviceCgroup {
1000+ return rspec.LinuxDeviceCgroup {
10021001 Allow : allow ,
10031002 Type : devType ,
10041003 Major : major ,
0 commit comments