Skip to content

Commit 265b9a7

Browse files
committed
Add linux.resources.devices
For specifying device cgroups independent of device creation. I also split the cgroups section into sections for each class (the earlier docs were very terse). I'll flesh these sections out in future commits if the devices addition sounds acceptable. Signed-off-by: W. Trevor King <wking@tremily.us>
1 parent 470c90d commit 265b9a7

File tree

2 files changed

+74
-3
lines changed

2 files changed

+74
-3
lines changed

config-linux.md

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,60 @@ $ cp --archive /dev/tty rootfs/dev/tty
6666

6767
## Linux control groups
6868

69-
Also known as cgroups, they are used to restrict resource usage for a container and handle
70-
device access. cgroups provide controls to restrict cpu, memory, IO, and network for
71-
the container. For more information, see the [kernel cgroups documentation](https://www.kernel.org/doc/Documentation/cgroups/cgroups.txt)
69+
Also known as cgroups, they are used to restrict resource usage for a container and handle device access.
70+
For more information, see the [kernel cgroups documentation][cgroups].
71+
You can configure a container's cgroups via the "resources" field of the Linux configuration.
72+
73+
### Disable out-of-memory killer
74+
75+
FIXME
76+
77+
### Memory
78+
79+
FIXME
80+
81+
### CPU
82+
83+
FIXME
84+
85+
### Block I/O
86+
87+
FIXME
88+
89+
### Devices
90+
91+
Container-side devices are [mounted from the bundle filesystems][mount-devices].
92+
Bundle authors can set major and minor nodes, owner IDs, filesystem permissions, etc. by altering those filesystems.
93+
However, you cannot pass cgroup information via the bundle filesystem, so bundle authors that need special device cgroups should use the "devices" field of the resource configuration.
94+
The fields are discussed [in the kernel documentation][cgroups-devices].
95+
The entries are applied to the container in the order that they are listed in the configuration.
96+
97+
```json
98+
"devices": [
99+
{
100+
"allow": false,
101+
"type": "a",
102+
"major": "*",
103+
"minor": "*",
104+
"access": "rwm",
105+
},
106+
{
107+
"allow": true,
108+
"type": "c",
109+
"major": "1",
110+
"minor": "3",
111+
"access": "mr",
112+
}
113+
]
114+
```
115+
116+
### Huge page limits
117+
118+
FIXME
119+
120+
### Network
121+
122+
FIXME
72123

73124
## Linux capabilities
74125

@@ -144,3 +195,6 @@ rootfsPropagation sets the rootfs's mount propagation. Its value is either slave
144195

145196
[mounts]: config.md#mount-configuration
146197
[mknod]: http://linux.die.net/man/1/mknod
198+
[cgroups]: https://www.kernel.org/doc/Documentation/cgroups/cgroups.txt
199+
[device-cgroups]: https://www.kernel.org/doc/Documentation/cgroups/devices.txt
200+
[mount-devices]: #access-to-devices

spec_linux.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,21 @@ type BlockIO struct {
100100
ThrottleWriteIOpsDevice string `json:"blkioThrottleWriteIopsDevice"`
101101
}
102102

103+
// Device rule for Linux cgroup management
104+
type Device struct {
105+
// Whether the device is allowed (true) or denied (false)
106+
Allow bool `json:"allow"`
107+
// a (all), c (char), or b (block). 'all' means it applies to all
108+
// types and all major and minor numbers
109+
Type string `json:type`
110+
// Major number. Either an integer or '*' for all.
111+
Major string `json:major`
112+
// Minor number. Either an integer or '*' for all.
113+
Minor string `json:minor`
114+
// a composition of r (read), w (write), and m (mknod).
115+
Access string `json:access`
116+
}
117+
103118
// Memory for Linux cgroup 'memory' resource management
104119
type Memory struct {
105120
// Memory limit (in bytes)
@@ -150,6 +165,8 @@ type Resources struct {
150165
CPU CPU `json:"cpu"`
151166
// BlockIO restriction configuration
152167
BlockIO BlockIO `json:"blockIO"`
168+
// Device configuration
169+
Devices []Device `json:"devices"`
153170
// Hugetlb limit (in bytes)
154171
HugepageLimits []HugepageLimit `json:"hugepageLimits"`
155172
// Network restriction configuration

0 commit comments

Comments
 (0)