Skip to content

Commit edd501a

Browse files
committed
config-vm: Recycle the 'process' schema
We already have two ways to specify a process to launch (for the container process and for hooks). This commit recycles the container process schema for launcing the hypervisor. I've dropped the terminal configuration because callers are unlikely to need control over their hypervisor's standard streams, but otherwise this is the same structure. The JSON Schema cheats a bit by not forbidding the terminal properties. We could address that if we really wanted to (JSON Schema makes it hard to extend a previously-defined object), but I'm leaving it to downstream tools in this commit. Signed-off-by: W. Trevor King <[email protected]>
1 parent 74b670e commit edd501a

File tree

5 files changed

+114
-133
lines changed

5 files changed

+114
-133
lines changed

config-vm.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@ The virtual-machine container specification provides additional configuration fo
55

66
## <a name="HypervisorObject" /> Hypervisor Object
77

8-
**`hypervisor`** (object, OPTIONAL) specifies details of the hypervisor that manages the container virtual machine.
9-
* **`path`** (string, REQUIRED) path to the hypervisor binary that manages the container virtual machine.
10-
This value MUST be an absolute path in the [runtime mount namespace](glossary.md#runtime-namespace).
11-
* **`parameters`** (array of strings, OPTIONAL) specifies an array of parameters to pass to the hypervisor.
8+
**`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.
1210

1311
### Example
1412

1513
```json
1614
"hypervisor": {
17-
"path": "/path/to/vmm",
18-
"parameters": ["opts1=foo", "opts2=bar"]
15+
"args": ["/path/to/vmm", "opts1=foo", "opts2=bar"]
1916
}
2017
```
2118

schema/config-schema.json

Lines changed: 1 addition & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -48,112 +48,7 @@
4848
}
4949
},
5050
"process": {
51-
"type": "object",
52-
"required": [
53-
"cwd",
54-
"args"
55-
],
56-
"properties": {
57-
"args": {
58-
"$ref": "defs.json#/definitions/ArrayOfStrings"
59-
},
60-
"consoleSize": {
61-
"type": "object",
62-
"required": [
63-
"height",
64-
"width"
65-
],
66-
"properties": {
67-
"height": {
68-
"$ref": "defs.json#/definitions/uint64"
69-
},
70-
"width": {
71-
"$ref": "defs.json#/definitions/uint64"
72-
}
73-
}
74-
},
75-
"cwd": {
76-
"type": "string"
77-
},
78-
"env": {
79-
"$ref": "defs.json#/definitions/Env"
80-
},
81-
"terminal": {
82-
"type": "boolean"
83-
},
84-
"user": {
85-
"type": "object",
86-
"properties": {
87-
"uid": {
88-
"$ref": "defs.json#/definitions/UID"
89-
},
90-
"gid": {
91-
"$ref": "defs.json#/definitions/GID"
92-
},
93-
"additionalGids": {
94-
"$ref": "defs.json#/definitions/ArrayOfGIDs"
95-
},
96-
"username": {
97-
"type": "string"
98-
}
99-
}
100-
},
101-
"capabilities": {
102-
"type": "object",
103-
"properties": {
104-
"bounding": {
105-
"$ref": "defs.json#/definitions/ArrayOfStrings"
106-
},
107-
"permitted": {
108-
"$ref": "defs.json#/definitions/ArrayOfStrings"
109-
},
110-
"effective": {
111-
"$ref": "defs.json#/definitions/ArrayOfStrings"
112-
},
113-
"inheritable": {
114-
"$ref": "defs.json#/definitions/ArrayOfStrings"
115-
},
116-
"ambient": {
117-
"$ref": "defs.json#/definitions/ArrayOfStrings"
118-
}
119-
}
120-
},
121-
"apparmorProfile": {
122-
"type": "string"
123-
},
124-
"oomScoreAdj": {
125-
"type": "integer"
126-
},
127-
"selinuxLabel": {
128-
"type": "string"
129-
},
130-
"noNewPrivileges": {
131-
"type": "boolean"
132-
},
133-
"rlimits": {
134-
"type": "array",
135-
"items": {
136-
"type": "object",
137-
"required": [
138-
"type",
139-
"soft",
140-
"hard"
141-
],
142-
"properties": {
143-
"hard": {
144-
"$ref": "defs.json#/definitions/uint64"
145-
},
146-
"soft": {
147-
"$ref": "defs.json#/definitions/uint64"
148-
},
149-
"type": {
150-
"type": "string",
151-
"pattern": "^RLIMIT_[A-Z]+$"
152-
}
153-
}
154-
}
155-
}
156-
}
51+
"$ref": "defs.json#/definitions/Process"
15752
},
15853
"linux": {
15954
"$ref": "config-linux.json#/linux"

schema/config-vm.json

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,7 @@
88
"properties": {
99
"hypervisor": {
1010
"description": "hypervisor config used by VM-based containers",
11-
"type": "object",
12-
"required": [
13-
"path"
14-
],
15-
"properties": {
16-
"path": {
17-
"$ref": "defs.json#/definitions/FilePath"
18-
},
19-
"parameters": {
20-
"$ref": "defs.json#/definitions/ArrayOfStrings"
21-
}
22-
}
11+
"$ref": "defs.json#/definitions/Process"
2312
},
2413
"kernel": {
2514
"description": "kernel config used by VM-based containers",

schema/defs.json

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,114 @@
7878
"Env": {
7979
"$ref": "#/definitions/ArrayOfStrings"
8080
},
81+
"Process": {
82+
"type": "object",
83+
"required": [
84+
"cwd",
85+
"args"
86+
],
87+
"properties": {
88+
"args": {
89+
"$ref": "defs.json#/definitions/ArrayOfStrings"
90+
},
91+
"consoleSize": {
92+
"type": "object",
93+
"required": [
94+
"height",
95+
"width"
96+
],
97+
"properties": {
98+
"height": {
99+
"$ref": "defs.json#/definitions/uint64"
100+
},
101+
"width": {
102+
"$ref": "defs.json#/definitions/uint64"
103+
}
104+
}
105+
},
106+
"cwd": {
107+
"type": "string"
108+
},
109+
"env": {
110+
"$ref": "defs.json#/definitions/Env"
111+
},
112+
"terminal": {
113+
"type": "boolean"
114+
},
115+
"user": {
116+
"type": "object",
117+
"properties": {
118+
"uid": {
119+
"$ref": "defs.json#/definitions/UID"
120+
},
121+
"gid": {
122+
"$ref": "defs.json#/definitions/GID"
123+
},
124+
"additionalGids": {
125+
"$ref": "defs.json#/definitions/ArrayOfGIDs"
126+
},
127+
"username": {
128+
"type": "string"
129+
}
130+
}
131+
},
132+
"capabilities": {
133+
"type": "object",
134+
"properties": {
135+
"bounding": {
136+
"$ref": "defs.json#/definitions/ArrayOfStrings"
137+
},
138+
"permitted": {
139+
"$ref": "defs.json#/definitions/ArrayOfStrings"
140+
},
141+
"effective": {
142+
"$ref": "defs.json#/definitions/ArrayOfStrings"
143+
},
144+
"inheritable": {
145+
"$ref": "defs.json#/definitions/ArrayOfStrings"
146+
},
147+
"ambient": {
148+
"$ref": "defs.json#/definitions/ArrayOfStrings"
149+
}
150+
}
151+
},
152+
"apparmorProfile": {
153+
"type": "string"
154+
},
155+
"oomScoreAdj": {
156+
"type": "integer"
157+
},
158+
"selinuxLabel": {
159+
"type": "string"
160+
},
161+
"noNewPrivileges": {
162+
"type": "boolean"
163+
},
164+
"rlimits": {
165+
"type": "array",
166+
"items": {
167+
"type": "object",
168+
"required": [
169+
"type",
170+
"soft",
171+
"hard"
172+
],
173+
"properties": {
174+
"hard": {
175+
"$ref": "defs.json#/definitions/uint64"
176+
},
177+
"soft": {
178+
"$ref": "defs.json#/definitions/uint64"
179+
},
180+
"type": {
181+
"type": "string",
182+
"pattern": "^RLIMIT_[A-Z]+$"
183+
}
184+
}
185+
}
186+
}
187+
}
188+
},
81189
"Hook": {
82190
"type": "object",
83191
"properties": {

specs-go/config.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -504,21 +504,13 @@ type WindowsHyperV struct {
504504
// VM contains information for virtual-machine-based containers.
505505
type VM struct {
506506
// Hypervisor specifies hypervisor-related configuration for virtual-machine-based containers.
507-
Hypervisor VMHypervisor `json:"hypervisor,omitempty"`
507+
Hypervisor *Process `json:"hypervisor,omitempty"`
508508
// Kernel specifies kernel-related configuration for virtual-machine-based containers.
509509
Kernel VMKernel `json:"kernel"`
510510
// Image specifies guest image related configuration for virtual-machine-based containers.
511511
Image VMImage `json:"image,omitempty"`
512512
}
513513

514-
// VMHypervisor contains information about the hypervisor to use for a virtual machine.
515-
type VMHypervisor struct {
516-
// Path is the host path to the hypervisor used to manage the virtual machine.
517-
Path string `json:"path"`
518-
// Parameters specifies parameters to pass to the hypervisor.
519-
Parameters string `json:"parameters,omitempty"`
520-
}
521-
522514
// VMKernel contains information about the kernel to use for a virtual machine.
523515
type VMKernel struct {
524516
// Path is the host path to the kernel used to boot the virtual machine.

0 commit comments

Comments
 (0)