Commit fa917b2
committed
[RFC] Implement systemd-specific per-cgroup support, add it to "devices" cgroup
This PR is trying to accomplish two things:
1. Define a new interface that will allow subsystems/controllers to
implement systemd-based configuration, by using systemd directives
rather than writing directly to the cgroup subtree.
2. Add a systemd-based implementation to the "devices" subsystem, to
illustrate how it is meant to be used.
The initial point I'd like to make here is towards discussing (1) as an
idea and whether the Go abstractions/interfaces are appropriate here or
whether we should move things around.
Consider part (2) to be really a draft and not really finished (even
though it actually works to a large extent, the D-Bus messages are
correct and that has been tested to do what's expected.)
I tested this with Podman using:
$ podman --runtime ~/go/src/github.com/opencontainers/runc/runc run -t fedora:29 echo hello
And also bringing up a container and checking the contents of
"device.list" in the cgroup subtree:
$ podman --runtime ~/go/src/github.com/opencontainers/runc/runc run -t fedora:29 sleep 1h
$ cat
/sys/fs/cgroup/devices/machine.slice/libpod-12fc7bd62fd6*/devices.list
c 10:200 rwm
c 5:2 rwm
c 136:* rwm
c 5:1 rwm
c 1:9 rwm
c 1:5 rwm
c 5:0 rwm
c 1:7 rwm
c 1:8 rwm
c 1:3 rwm
b *:* m
c *:* m
This matches the output of devices.list when using the official "runc"
binary, only difference being the lines are inverted in order (again, we
can fix that on a second step.)
Querying systemd for this unit also works as expected:
$ systemctl show libpod-12fc7bd62fd66ff62fa1b045c2d717c7b2076c072c20de14f5c1ad86b78865eb.scope -p DevicePolicy -p DeviceAllow
DevicePolicy=strict
DeviceAllow=/dev/net/tun rwm
DeviceAllow=/dev/ptmx rwm
DeviceAllow=char-136 rwm
DeviceAllow=/dev/console rwm
DeviceAllow=/dev/urandom rwm
DeviceAllow=/dev/zero rwm
DeviceAllow=/dev/tty rwm
DeviceAllow=/dev/full rwm
DeviceAllow=/dev/random rwm
DeviceAllow=/dev/null rwm
DeviceAllow=block-* m
DeviceAllow=char-* m1 parent 751f18d commit fa917b2
File tree
3 files changed
+75
-0
lines changed- libcontainer
- cgroups
- fs
- systemd
- configs
3 files changed
+75
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
9 | 14 | | |
10 | 15 | | |
11 | 16 | | |
| |||
71 | 76 | | |
72 | 77 | | |
73 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
74 | 115 | | |
75 | 116 | | |
76 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
40 | 45 | | |
41 | 46 | | |
42 | 47 | | |
| |||
282 | 287 | | |
283 | 288 | | |
284 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
285 | 302 | | |
286 | 303 | | |
287 | 304 | | |
| |||
503 | 520 | | |
504 | 521 | | |
505 | 522 | | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
506 | 527 | | |
507 | 528 | | |
508 | 529 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
47 | 60 | | |
48 | 61 | | |
49 | 62 | | |
| |||
0 commit comments