Skip to content

Commit

Permalink
config-vm: Recycle the 'process' schema
Browse files Browse the repository at this point in the history
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 <wking@tremily.us>
  • Loading branch information
wking committed Mar 9, 2018
1 parent 74b670e commit edd501a
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 133 deletions.
9 changes: 3 additions & 6 deletions config-vm.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ The virtual-machine container specification provides additional configuration fo

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

**`hypervisor`** (object, OPTIONAL) specifies details of the hypervisor that manages the container virtual machine.
* **`path`** (string, REQUIRED) path to the hypervisor binary that manages the container virtual machine.
This value MUST be an absolute path in the [runtime mount namespace](glossary.md#runtime-namespace).
* **`parameters`** (array of strings, OPTIONAL) specifies an array of parameters to pass to the hypervisor.
**`hypervisor`** (object, OPTIONAL) configures the hypervisor process.
It has the same schema as [`process`](config.md#process), but `terminal` and `consoleSize` MUST NOT be configured.

### Example

```json
"hypervisor": {
"path": "/path/to/vmm",
"parameters": ["opts1=foo", "opts2=bar"]
"args": ["/path/to/vmm", "opts1=foo", "opts2=bar"]
}
```

Expand Down
107 changes: 1 addition & 106 deletions schema/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,112 +48,7 @@
}
},
"process": {
"type": "object",
"required": [
"cwd",
"args"
],
"properties": {
"args": {
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"consoleSize": {
"type": "object",
"required": [
"height",
"width"
],
"properties": {
"height": {
"$ref": "defs.json#/definitions/uint64"
},
"width": {
"$ref": "defs.json#/definitions/uint64"
}
}
},
"cwd": {
"type": "string"
},
"env": {
"$ref": "defs.json#/definitions/Env"
},
"terminal": {
"type": "boolean"
},
"user": {
"type": "object",
"properties": {
"uid": {
"$ref": "defs.json#/definitions/UID"
},
"gid": {
"$ref": "defs.json#/definitions/GID"
},
"additionalGids": {
"$ref": "defs.json#/definitions/ArrayOfGIDs"
},
"username": {
"type": "string"
}
}
},
"capabilities": {
"type": "object",
"properties": {
"bounding": {
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"permitted": {
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"effective": {
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"inheritable": {
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"ambient": {
"$ref": "defs.json#/definitions/ArrayOfStrings"
}
}
},
"apparmorProfile": {
"type": "string"
},
"oomScoreAdj": {
"type": "integer"
},
"selinuxLabel": {
"type": "string"
},
"noNewPrivileges": {
"type": "boolean"
},
"rlimits": {
"type": "array",
"items": {
"type": "object",
"required": [
"type",
"soft",
"hard"
],
"properties": {
"hard": {
"$ref": "defs.json#/definitions/uint64"
},
"soft": {
"$ref": "defs.json#/definitions/uint64"
},
"type": {
"type": "string",
"pattern": "^RLIMIT_[A-Z]+$"
}
}
}
}
}
"$ref": "defs.json#/definitions/Process"
},
"linux": {
"$ref": "config-linux.json#/linux"
Expand Down
13 changes: 1 addition & 12 deletions schema/config-vm.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@
"properties": {
"hypervisor": {
"description": "hypervisor config used by VM-based containers",
"type": "object",
"required": [
"path"
],
"properties": {
"path": {
"$ref": "defs.json#/definitions/FilePath"
},
"parameters": {
"$ref": "defs.json#/definitions/ArrayOfStrings"
}
}
"$ref": "defs.json#/definitions/Process"
},
"kernel": {
"description": "kernel config used by VM-based containers",
Expand Down
108 changes: 108 additions & 0 deletions schema/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,114 @@
"Env": {
"$ref": "#/definitions/ArrayOfStrings"
},
"Process": {
"type": "object",
"required": [
"cwd",
"args"
],
"properties": {
"args": {
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"consoleSize": {
"type": "object",
"required": [
"height",
"width"
],
"properties": {
"height": {
"$ref": "defs.json#/definitions/uint64"
},
"width": {
"$ref": "defs.json#/definitions/uint64"
}
}
},
"cwd": {
"type": "string"
},
"env": {
"$ref": "defs.json#/definitions/Env"
},
"terminal": {
"type": "boolean"
},
"user": {
"type": "object",
"properties": {
"uid": {
"$ref": "defs.json#/definitions/UID"
},
"gid": {
"$ref": "defs.json#/definitions/GID"
},
"additionalGids": {
"$ref": "defs.json#/definitions/ArrayOfGIDs"
},
"username": {
"type": "string"
}
}
},
"capabilities": {
"type": "object",
"properties": {
"bounding": {
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"permitted": {
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"effective": {
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"inheritable": {
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"ambient": {
"$ref": "defs.json#/definitions/ArrayOfStrings"
}
}
},
"apparmorProfile": {
"type": "string"
},
"oomScoreAdj": {
"type": "integer"
},
"selinuxLabel": {
"type": "string"
},
"noNewPrivileges": {
"type": "boolean"
},
"rlimits": {
"type": "array",
"items": {
"type": "object",
"required": [
"type",
"soft",
"hard"
],
"properties": {
"hard": {
"$ref": "defs.json#/definitions/uint64"
},
"soft": {
"$ref": "defs.json#/definitions/uint64"
},
"type": {
"type": "string",
"pattern": "^RLIMIT_[A-Z]+$"
}
}
}
}
}
},
"Hook": {
"type": "object",
"properties": {
Expand Down
10 changes: 1 addition & 9 deletions specs-go/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,21 +504,13 @@ type WindowsHyperV struct {
// VM contains information for virtual-machine-based containers.
type VM struct {
// Hypervisor specifies hypervisor-related configuration for virtual-machine-based containers.
Hypervisor VMHypervisor `json:"hypervisor,omitempty"`
Hypervisor *Process `json:"hypervisor,omitempty"`
// Kernel specifies kernel-related configuration for virtual-machine-based containers.
Kernel VMKernel `json:"kernel"`
// Image specifies guest image related configuration for virtual-machine-based containers.
Image VMImage `json:"image,omitempty"`
}

// VMHypervisor contains information about the hypervisor to use for a virtual machine.
type VMHypervisor struct {
// Path is the host path to the hypervisor used to manage the virtual machine.
Path string `json:"path"`
// Parameters specifies parameters to pass to the hypervisor.
Parameters string `json:"parameters,omitempty"`
}

// VMKernel contains information about the kernel to use for a virtual machine.
type VMKernel struct {
// Path is the host path to the kernel used to boot the virtual machine.
Expand Down

0 comments on commit edd501a

Please sign in to comment.