Skip to content

Commit efa3c30

Browse files
committed
Add option HostPath to DeviceNode
Signed-off-by: Evan Lezar <[email protected]>
1 parent 3b39456 commit efa3c30

File tree

5 files changed

+8
-2
lines changed

5 files changed

+8
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ $ cat > /etc/cdi/vendor.json <<EOF
3232
"name": "myDevice",
3333
"containerEdits": {
3434
"deviceNodes": [
35-
{"path": "/dev/card1", "type": "c", "major": 25, "minor": 25, "fileMode": 384, "permissions": "rw", "uid": 1000, "gid": 1000},
35+
{"hostPath": "/vendor/dev/card1": "path": "/dev/card1", "type": "c", "major": 25, "minor": 25, "fileMode": 384, "permissions": "rw", "uid": 1000, "gid": 1000},
3636
{"path": "/dev/card-render1", "type": "c", "major": 25, "minor": 25, "fileMode": 384, "permissions": "rwm", "uid": 1000, "gid": 1000}
3737
]
3838
}

SPEC.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ The key words "must", "must not", "required", "shall", "shall not", "should", "s
103103
"deviceNodes": [ (optional)
104104
{
105105
"path": "<path>",
106+
"hostPath": "<hostPath>" (optional),
106107
"type": "<type>" (optional),
107108
"major": <int32> (optional),
108109
"minor": <int32> (optional),
@@ -181,6 +182,7 @@ The `containerEdits` field has the following definition:
181182
* `env` (array of strings in the format of "VARNAME=VARVALUE", OPTIONAL) describes the environment variables that should be set. These values are appended to the container environment array.
182183
* `deviceNodes` (array of objects, OPTIONAL) describes the device nodes that should be mounted:
183184
* `path` (string, REQUIRED) path of the device within the container.
185+
* `hostPath` (string, OPTIONAL) path of the device node on the host. If not specified the value for `path` is used.
184186
* `type` (string, OPTIONAL) Device type: block, char, etc.
185187
* `major` (int64, OPTIONAL) Device major number.
186188
* `minor` (int64, OPTIONAL) Device minor number.

schema/defs.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
"path": {
3030
"$ref": "#/definitions/FilePath"
3131
},
32+
"hostPath": {
33+
"$ref": "#/definitions/FilePath"
34+
},
3235
"permissions": {
3336
"type": "string"
3437
},

schema/testdata/good/spec-example.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"name": "myDevice",
77
"containerEdits": {
88
"deviceNodes": [
9-
{"path": "/dev/card1"},
9+
{"hostPath": "/vendorroot/dev/card1", "path": "/dev/card1"},
1010
{"path": "/dev/card2"}
1111
]
1212
}

specs-go/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type ContainerEdits struct {
3131
// DeviceNode represents a device node that needs to be added to the OCI spec.
3232
type DeviceNode struct {
3333
Path string `json:"path"`
34+
HostPath string `json:"hostPath,omitempty"`
3435
Type string `json:"type,omitempty"`
3536
Major int64 `json:"major,omitempty"`
3637
Minor int64 `json:"minor,omitempty"`

0 commit comments

Comments
 (0)