diff options
| author | Ryan Sundberg <ryan@arctype.co> | 2021-12-29 19:52:16 -0800 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2022-01-05 23:44:18 +0100 |
| commit | bfdeba11f86b18172194b416c6eb59b7cc7ef355 (patch) | |
| tree | 8dc74b57f6ff1d821235542eed18e066a999773d | |
| parent | 2c1807c516185a3d3d7cdca23297ca480dab16d4 (diff) | |
linux-container: Handle CLONE_NEWCGROUP and use it by default.
Adds low-level support for launching Linux containers with cgroup namespaces.
* gnu/build/linux-container.scm (%namespaces): Add 'cgroup.
(namespaces->bit-mask): Handle it.
* guix/build/syscalls.scm (CLONE_NEWCGROUP): New variable.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
| -rw-r--r-- | gnu/build/linux-container.scm | 3 | ||||
| -rw-r--r-- | guix/build/syscalls.scm | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/gnu/build/linux-container.scm b/gnu/build/linux-container.scm index 4a8bed5a9a2..bdeca2cdb9f 100644 --- a/gnu/build/linux-container.scm +++ b/gnu/build/linux-container.scm | |||
| @@ -52,7 +52,7 @@ exists." | |||
| 52 | (file-exists? "/proc/self/setgroups")) | 52 | (file-exists? "/proc/self/setgroups")) |
| 53 | 53 | ||
| 54 | (define %namespaces | 54 | (define %namespaces |
| 55 | '(mnt pid ipc uts user net)) | 55 | '(cgroup mnt pid ipc uts user net)) |
| 56 | 56 | ||
| 57 | (define (call-with-clean-exit thunk) | 57 | (define (call-with-clean-exit thunk) |
| 58 | "Apply THUNK, but exit with a status code of 1 if it fails." | 58 | "Apply THUNK, but exit with a status code of 1 if it fails." |
| @@ -210,6 +210,7 @@ corresponds to the symbols in NAMESPACES." | |||
| 210 | ;; Use the same flags as fork(3) in addition to the namespace flags. | 210 | ;; Use the same flags as fork(3) in addition to the namespace flags. |
| 211 | (apply logior SIGCHLD | 211 | (apply logior SIGCHLD |
| 212 | (map (match-lambda | 212 | (map (match-lambda |
| 213 | ('cgroup CLONE_NEWCGROUP) | ||
| 213 | ('mnt CLONE_NEWNS) | 214 | ('mnt CLONE_NEWNS) |
| 214 | ('uts CLONE_NEWUTS) | 215 | ('uts CLONE_NEWUTS) |
| 215 | ('ipc CLONE_NEWIPC) | 216 | ('ipc CLONE_NEWIPC) |
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 45f95c509d7..a7401fd73ff 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm | |||
| @@ -132,6 +132,7 @@ | |||
| 132 | 132 | ||
| 133 | CLONE_CHILD_CLEARTID | 133 | CLONE_CHILD_CLEARTID |
| 134 | CLONE_CHILD_SETTID | 134 | CLONE_CHILD_SETTID |
| 135 | CLONE_NEWCGROUP | ||
| 135 | CLONE_NEWNS | 136 | CLONE_NEWNS |
| 136 | CLONE_NEWUTS | 137 | CLONE_NEWUTS |
| 137 | CLONE_NEWIPC | 138 | CLONE_NEWIPC |
| @@ -1025,6 +1026,7 @@ caller lacks root privileges." | |||
| 1025 | ;; Linux clone flags, from linux/sched.h | 1026 | ;; Linux clone flags, from linux/sched.h |
| 1026 | (define CLONE_CHILD_CLEARTID #x00200000) | 1027 | (define CLONE_CHILD_CLEARTID #x00200000) |
| 1027 | (define CLONE_CHILD_SETTID #x01000000) | 1028 | (define CLONE_CHILD_SETTID #x01000000) |
| 1029 | (define CLONE_NEWCGROUP #x02000000) | ||
| 1028 | (define CLONE_NEWNS #x00020000) | 1030 | (define CLONE_NEWNS #x00020000) |
| 1029 | (define CLONE_NEWUTS #x04000000) | 1031 | (define CLONE_NEWUTS #x04000000) |
| 1030 | (define CLONE_NEWIPC #x08000000) | 1032 | (define CLONE_NEWIPC #x08000000) |
