Skip to content

Commit ebccf3f

Browse files
committed
WIP: Copy/paste new Markdown and Go for hypervisor
Michael asked for this [1], because it allows you to extend one schema without extending the other (the terminal properties are an example of this). I think the overlap is much greater than the differences, so I'd rather use the previous commit's "is is the same, except for ..." approach. But as far as configurations are concerned, the two approaches are identical, so I don't really care. I've left the JSON Schema change off this commit for now, I'll go back through and adjust that once we have a maintainer confirming the copy/paste approach. [1]: http://ircbot.wl.linuxfoundation.org/meetings/opencontainers/2018/opencontainers.2018-03-07-22.00.log.html#l-53 Signed-off-by: W. Trevor King <wking@tremily.us>
1 parent 1aad2e3 commit ebccf3f

2 files changed

Lines changed: 111 additions & 2 deletions

File tree

config-vm.md

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,80 @@ The virtual-machine container specification provides additional configuration fo
66
## <a name="HypervisorObject" /> Hypervisor Object
77

88
**`hypervisor`** (object, OPTIONAL) configures the hypervisor process.
9-
It has the same schema as [`process`](config.md#process), but `terminal` and `consoleSize` MUST NOT be configured.
9+
The schema is a subset of the [`process`](config.md#process) schema with the terminal properties `terminal` and `consoleSize` removed.
10+
11+
* **`cwd`** (string, REQUIRED) is the working directory that will be set for the executable.
12+
This value MUST be an absolute path.
13+
* **`env`** (array of strings, OPTIONAL) with the same semantics as [IEEE Std 1003.1-2008's `environ`][ieee-1003.1-2008-xbd-c8.1_2].
14+
* **`args`** (array of strings, REQUIRED) with similar semantics to [IEEE Std 1003.1-2008 `execvp`'s *argv*][ieee-1003.1-2008-functions-exec_2].
15+
This specification extends the IEEE standard in that at least one entry is REQUIRED, and that entry is used with the same semantics as `execvp`'s *file*.
16+
17+
### <a name="HypervisorPOSIXProcess" />POSIX process
18+
19+
For systems that support POSIX rlimits (for example Linux and Solaris), the `hypervisor` object supports the following process-specific properties:
20+
21+
* **`rlimits`** (array of objects, OPTIONAL) allows setting resource limits for the process.
22+
Each entry has the following structure:
23+
24+
* **`type`** (string, REQUIRED) the platform resource being limited.
25+
* Linux: valid values are defined in the [`getrlimit(2)`][getrlimit.2_2] man page, such as `RLIMIT_MSGQUEUE`.
26+
* Solaris: valid values are defined in the [`getrlimit(3)`][getrlimit.3_2] man page, such as `RLIMIT_CORE`.
27+
28+
The runtime MUST [generate an error](runtime.md#errors) for any values which cannot be mapped to a relevant kernel interface.
29+
For each entry in `rlimits`, a [`getrlimit(3)`][getrlimit.3_2] on `type` MUST succeed.
30+
For the following properties, `rlim` refers to the status returned by the `getrlimit(3)` call.
31+
32+
* **`soft`** (uint64, REQUIRED) the value of the limit enforced for the corresponding resource.
33+
`rlim.rlim_cur` MUST match the configured value.
34+
* **`hard`** (uint64, REQUIRED) the ceiling for the soft limit that could be set by an unprivileged process.
35+
`rlim.rlim_max` MUST match the configured value.
36+
Only a privileged process (e.g. one with the `CAP_SYS_RESOURCE` capability) can raise a hard limit.
37+
38+
If `rlimits` contains duplicated entries with same `type`, the runtime MUST [generate an error](runtime.md#errors).
39+
40+
### <a name="HypervisorLinuxProcess" />Linux Process
41+
42+
For Linux-based systems, the `hypervisor` object supports the following process-specific properties.
43+
44+
* **`apparmorProfile`** (string, OPTIONAL) specifies the name of the AppArmor profile for the process.
45+
For more information about AppArmor, see [AppArmor documentation][apparmor_2].
46+
* **`capabilities`** (object, OPTIONAL) is an object containing arrays that specifies the sets of capabilities for the process.
47+
Valid values are defined in the [capabilities(7)][capabilities.7_2] man page, such as `CAP_CHOWN`.
48+
Any value which cannot be mapped to a relevant kernel interface MUST cause an error.
49+
`capabilities` contains the following properties:
50+
51+
* **`effective`** (array of strings, OPTIONAL) the `effective` field is an array of effective capabilities that are kept for the process.
52+
* **`bounding`** (array of strings, OPTIONAL) the `bounding` field is an array of bounding capabilities that are kept for the process.
53+
* **`inheritable`** (array of strings, OPTIONAL) the `inheritable` field is an array of inheritable capabilities that are kept for the process.
54+
* **`permitted`** (array of strings, OPTIONAL) the `permitted` field is an array of permitted capabilities that are kept for the process.
55+
* **`ambient`** (array of strings, OPTIONAL) the `ambient` field is an array of ambient capabilities that are kept for the process.
56+
* **`noNewPrivileges`** (bool, OPTIONAL) setting `noNewPrivileges` to true prevents the process from gaining additional privileges.
57+
As an example, the [`no_new_privs`][no-new-privs_2] article in the kernel documentation has information on how this is achieved using a `prctl` system call on Linux.
58+
* **`oomScoreAdj`** *(int, OPTIONAL)* adjusts the oom-killer score in `[pid]/oom_score_adj` for the process's `[pid]` in a [proc pseudo-filesystem][proc_3].
59+
If `oomScoreAdj` is set, the runtime MUST set `oom_score_adj` to the given value.
60+
If `oomScoreAdj` is not set, the runtime MUST NOT change the value of `oom_score_adj`.
61+
* **`selinuxLabel`** (string, OPTIONAL) specifies the SELinux label for the process.
62+
For more information about SELinux, see [SELinux documentation][selinux_2].
63+
64+
### <a name="HypervisorUser" />User
65+
66+
The user for the process is a platform-specific structure that allows specific control over which user the process runs as.
67+
68+
#### <a name="HypervisorPOSIXUser" />POSIX-platform User
69+
70+
For POSIX platforms the `user` structure has the following fields:
71+
72+
* **`uid`** (int, REQUIRED) specifies the user ID in the [container namespace](glossary.md#container-namespace).
73+
* **`gid`** (int, REQUIRED) specifies the group ID in the [container namespace](glossary.md#container-namespace).
74+
* **`additionalGids`** (array of ints, OPTIONAL) specifies additional group IDs in the [container namespace](glossary.md#container-namespace) to be added to the process.
75+
76+
_Note: symbolic name for uid and gid, such as uname and gname respectively, are left to upper levels to derive (i.e. `/etc/passwd` parsing, NSS, etc)_
77+
78+
#### <a name="HypervisorWindowsUser" />Windows User
79+
80+
For Windows based systems the user structure has the following fields:
81+
82+
* **`username`** (string, OPTIONAL) specifies the user name for the process.
1083

1184
### Example
1285

@@ -58,3 +131,14 @@ This image contains the root filesystem that the virtual machine **`kernel`** wi
58131
"format": "raw"
59132
}
60133
```
134+
135+
[apparmor_2]: https://wiki.ubuntu.com/AppArmor
136+
[ieee-1003.1-2008-xbd-c8.1_2]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_01
137+
[ieee-1003.1-2008-functions-exec_2]: http://pubs.opengroup.org/onlinepubs/9699919799/fu
138+
[no-new-privs_2]: https://www.kernel.org/doc/Documentation/prctl/no_new_privs.txt
139+
[proc_3]: https://www.kernel.org/doc/Documentation/filesystems/proc.txt
140+
[selinux_2]:http://selinuxproject.org/page/Main_Page
141+
142+
[capabilities.7_2]: http://man7.org/linux/man-pages/man7/capabilities.7.html
143+
[getrlimit.2_2]: http://man7.org/linux/man-pages/man2/getrlimit.2.html
144+
[getrlimit.3_2]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/getrlimit.html

specs-go/config.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,31 @@ type Process struct {
5858
SelinuxLabel string `json:"selinuxLabel,omitempty" platform:"linux"`
5959
}
6060

61+
// HypervisorProcess is like Process, except for launching the hypervisor instead of for launching a container process.
62+
type Process struct {
63+
// User specifies user information for the process.
64+
User User `json:"user"`
65+
// Args specifies the binary and arguments for the application to execute.
66+
Args []string `json:"args"`
67+
// Env populates the process environment for the process.
68+
Env []string `json:"env,omitempty"`
69+
// Cwd is the current working directory for the process and must be
70+
// relative to the container's root.
71+
Cwd string `json:"cwd"`
72+
// Capabilities are Linux capabilities that are kept for the process.
73+
Capabilities *LinuxCapabilities `json:"capabilities,omitempty" platform:"linux"`
74+
// Rlimits specifies rlimit options to apply to the process.
75+
Rlimits []POSIXRlimit `json:"rlimits,omitempty" platform:"linux,solaris"`
76+
// NoNewPrivileges controls whether additional privileges could be gained by processes in the container.
77+
NoNewPrivileges bool `json:"noNewPrivileges,omitempty" platform:"linux"`
78+
// ApparmorProfile specifies the apparmor profile for the container.
79+
ApparmorProfile string `json:"apparmorProfile,omitempty" platform:"linux"`
80+
// Specify an oom_score_adj for the container.
81+
OOMScoreAdj *int `json:"oomScoreAdj,omitempty" platform:"linux"`
82+
// SelinuxLabel specifies the selinux context that the container process is run as.
83+
SelinuxLabel string `json:"selinuxLabel,omitempty" platform:"linux"`
84+
}
85+
6186
// LinuxCapabilities specifies the whitelist of capabilities that are kept for a process.
6287
// http://man7.org/linux/man-pages/man7/capabilities.7.html
6388
type LinuxCapabilities struct {
@@ -504,7 +529,7 @@ type WindowsHyperV struct {
504529
// VM contains information for virtual-machine-based containers.
505530
type VM struct {
506531
// Hypervisor specifies hypervisor-related configuration for virtual-machine-based containers.
507-
Hypervisor *Process `json:"hypervisor,omitempty"`
532+
Hypervisor *HypervisorProcess `json:"hypervisor,omitempty"`
508533
// Kernel specifies kernel-related configuration for virtual-machine-based containers.
509534
Kernel VMKernel `json:"kernel"`
510535
// Image specifies guest image related configuration for virtual-machine-based containers.

0 commit comments

Comments
 (0)