@@ -40,6 +40,8 @@ var generateFlags = []cli.Flag{
40
40
cli.StringSliceFlag {Name : "linux-device-add" , Usage : "add a device which must be made available in the container" },
41
41
cli.StringSliceFlag {Name : "linux-device-remove" , Usage : "remove a device which must be made available in the container" },
42
42
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" },
43
45
cli.BoolFlag {Name : "linux-disable-oom-kill" , Usage : "disable OOM Killer" },
44
46
cli.StringSliceFlag {Name : "linux-gidmappings" , Usage : "add GIDMappings e.g HostID:ContainerID:Size" },
45
47
cli.StringSliceFlag {Name : "linux-hugepage-limits-add" , Usage : "add hugepage resource limits" },
@@ -63,8 +65,6 @@ var generateFlags = []cli.Flag{
63
65
cli.StringSliceFlag {Name : "linux-readonly-paths" , Usage : "specifies paths readonly inside container" },
64
66
cli.Int64Flag {Name : "linux-realtime-period" , Usage : "CPU period to be used for realtime scheduling (in usecs)" },
65
67
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" },
68
68
cli.StringFlag {Name : "linux-rootfs-propagation" , Usage : "mount propagation for rootfs" },
69
69
cli.StringFlag {Name : "linux-seccomp-allow" , Usage : "specifies syscalls to respond with allow" },
70
70
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 {
243
243
}
244
244
}
245
245
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" )
248
248
for _ , device := range devices {
249
249
dev , err := parseLinuxResourcesDeviceAccess (device , g )
250
250
if err != nil {
@@ -254,8 +254,8 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
254
254
}
255
255
}
256
256
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" )
259
259
for _ , device := range devices {
260
260
dev , err := parseLinuxResourcesDeviceAccess (device , g )
261
261
if err != nil {
@@ -835,7 +835,6 @@ func parseRlimit(rlimit string) (string, uint64, uint64, error) {
835
835
return parts [0 ], uint64 (hard ), uint64 (soft ), nil
836
836
}
837
837
838
- << << << < 9e0 e42dbf918070406a2a4a2e1476e7350ba9129
839
838
func parseNamespace (ns string ) (string , string , error ) {
840
839
parts := strings .SplitN (ns , ":" , 2 )
841
840
if len (parts ) == 0 || parts [0 ] == "" {
@@ -943,7 +942,7 @@ var cgroupDeviceAccess = map[string]bool{
943
942
}
944
943
945
944
// 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 ) {
947
946
var allow bool
948
947
var devType , access string
949
948
var major , minor * int64
@@ -956,7 +955,7 @@ func parseLinuxResourcesDeviceAccess(device string, g *generate.Generator) (rspe
956
955
case "deny" :
957
956
allow = false
958
957
default :
959
- return rspec.DeviceCgroup {},
958
+ return rspec.LinuxDeviceCgroup {},
960
959
fmt .Errorf ("Only 'allow' and 'deny' are allowed in the first field of device-access-add: %s" , device )
961
960
}
962
961
@@ -967,38 +966,38 @@ func parseLinuxResourcesDeviceAccess(device string, g *generate.Generator) (rspe
967
966
}
968
967
parts := strings .SplitN (s , "=" , 2 )
969
968
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 )
971
970
}
972
971
name , value := parts [0 ], parts [1 ]
973
972
974
973
switch name {
975
974
case "type" :
976
975
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 )
978
977
}
979
- devType = & value
978
+ devType = value
980
979
case "major" :
981
980
i , err := strconv .ParseInt (value , 10 , 64 )
982
981
if err != nil {
983
- return rspec.DeviceCgroup {}, err
982
+ return rspec.LinuxDeviceCgroup {}, err
984
983
}
985
984
major = & i
986
985
case "minor" :
987
986
i , err := strconv .ParseInt (value , 10 , 64 )
988
987
if err != nil {
989
- return rspec.DeviceCgroup {}, err
988
+ return rspec.LinuxDeviceCgroup {}, err
990
989
}
991
990
minor = & i
992
991
case "access" :
993
992
for _ , c := range strings .Split (value , "" ) {
994
993
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 )
996
995
}
997
996
}
998
- access = & value
997
+ access = value
999
998
}
1000
999
}
1001
- return rspec.DeviceCgroup {
1000
+ return rspec.LinuxDeviceCgroup {
1002
1001
Allow : allow ,
1003
1002
Type : devType ,
1004
1003
Major : major ,
0 commit comments