Skip to content

Commit e01b694

Browse files
committed
config: Add Windows Devices to Schema
Signed-off-by: Craig Wilhite <[email protected]> This adds Windows Device support to the OCI runtime-spec: code, JSON schema and markdown documentation. This is a first step in our approach to lighting up access to host devices for Windows Server containers. Devices in Windows implement any number of interface class GUIDs. By configuring a container with a device interface class GUID, we will plug all devices on the host that implement the interface class GUID into the device namespace of the container. While this approach does not allow for the speciication of a single, particular device, our schema definition is defined to be flexible; we interpret the 'id' of the device passed in based upon the 'id_type'.
1 parent 7c4c8f6 commit e01b694

File tree

5 files changed

+67
-0
lines changed

5 files changed

+67
-0
lines changed

config-windows.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,34 @@ The Windows container specification uses APIs provided by the Windows Host Compu
1919
}
2020
```
2121

22+
## <a name="configWindowsDevices" />Devices
23+
24+
**`devices`** (array of objects, OPTIONAL) lists devices that MUST be available in the container.
25+
26+
Each entry has the following structure:
27+
28+
* **`id`** *(string, REQUIRED)* - specifies the device which the runtime MUST make available in the container.
29+
* **`id_type`** *(string, REQUIRED)* - tells the runtime how to interpret `id`. Today, Windows only supports a value of `class`, which identifies `id` as a [device interface class GUID][interfaceGUID].
30+
31+
[interfaceGUID]: https://docs.microsoft.com/en-us/windows-hardware/drivers/install/overview-of-device-interface-classes
32+
33+
### Example
34+
35+
```json
36+
"windows": {
37+
"devices": [
38+
{
39+
"id": "24E552D7-6523-47F7-A647-D3465BF1F5CA",
40+
"id_type": "class"
41+
},
42+
{
43+
"id": "5175d334-c371-4806-b3ba-71fd53c9258d",
44+
"id_type": "class"
45+
}
46+
]
47+
}
48+
```
49+
2250
## <a name="configWindowsResources" />Resources
2351

2452
You can configure a container's resource limits via the OPTIONAL `resources` field of the Windows configuration.

schema/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The layout of the files is as follows:
1313
* [state-schema.json](state-schema.json) - the primary entrypoint for the [state JSON](../runtime.md#state) schema
1414
* [defs.json](defs.json) - definitions for general types
1515
* [defs-linux.json](defs-linux.json) - definitions for Linux-specific types
16+
* [defs-windows.json](defs-windows.json) - definitions for Windows-specific types
1617
* [validate.go](validate.go) - validation utility source code
1718

1819

schema/config-windows.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
},
1111
"minItems": 1
1212
},
13+
"devices": {
14+
"type": "array",
15+
"items": {
16+
"$ref": "defs-windows.json#/definitions/Device"
17+
}
18+
},
1319
"resources": {
1420
"type": "object",
1521
"properties": {

schema/defs-windows.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"definitions": {
3+
"Device": {
4+
"type": "object",
5+
"properties": {
6+
"id": {
7+
"type": "string"
8+
},
9+
"id_type": {
10+
"type": "string",
11+
"enum": [
12+
"class"
13+
]
14+
}
15+
},
16+
"required": [
17+
"id",
18+
"id_type"
19+
]
20+
}
21+
}
22+
}

specs-go/config.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ type SolarisAnet struct {
433433
type Windows struct {
434434
// LayerFolders contains a list of absolute paths to directories containing image layers.
435435
LayerFolders []string `json:"layerFolders"`
436+
// Devices are a list of interface class GUIDs for which device objects need to be mapped into the container.
437+
Devices []WindowsDevice `json:"devices,omitempty"`
436438
// Resources contains information for handling resource constraints for the container.
437439
Resources *WindowsResources `json:"resources,omitempty"`
438440
// CredentialSpec contains a JSON object describing a group Managed Service Account (gMSA) specification.
@@ -447,6 +449,14 @@ type Windows struct {
447449
Network *WindowsNetwork `json:"network,omitempty"`
448450
}
449451

452+
// WindowsDevice represents information about a host device to be mapped into the container.
453+
type WindowsDevice struct {
454+
// Device identifier: interface class GUID, etc.
455+
Id string `json:"id"`
456+
// Device identifier type: "class", etc.
457+
IdType string `json:"id_type"`
458+
}
459+
450460
// WindowsResources has container runtime resource constraints for containers running on Windows.
451461
type WindowsResources struct {
452462
// Memory restriction configuration.

0 commit comments

Comments
 (0)