forked from containers/podman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/api: honor cdi devices from the hostconfig
pass down the devices specifies in the resources block so that CDI devices in the compose file are honored. Tested manually with the following compose file: services: testgpupodman_count: image: ubuntu:latest command: ["nvidia-smi"] profiles: [gpu] deploy: resources: reservations: devices: - driver: nvidia count: 1 capabilities: [gpu] testgpupodman_deviceid: image: docker.io/ubuntu:latest command: ["nvidia-smi"] deploy: resources: reservations: devices: - driver: cdi device_ids: ['nvidia.com/gpu=all'] capabilities: [gpu] Closes: containers#19338 Signed-off-by: Giuseppe Scrivano <[email protected]>
- Loading branch information
Showing
7 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cdi devices | ||
=========== | ||
|
||
This test copies a CDI device file on a tmpfs mounted on /etc/cdi, then checks that the CDI device in the compose file is present in a container. When running as rootless, the mount is created inside the rootless mount namespasce. | ||
|
||
Validation | ||
------------ | ||
|
||
* The CDI device is present in the container. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"cdiVersion": "0.3.0", | ||
"kind": "vendor.com/device", | ||
"devices": [ | ||
{ | ||
"name": "myKmsg", | ||
"containerEdits": { | ||
"mounts": [ | ||
{"hostPath": "/dev/kmsg", "containerPath": "/dev/kmsg1", "options": ["rw", "rprivate", "rbind"]} | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
services: | ||
test: | ||
image: alpine | ||
command: ["top"] | ||
deploy: | ||
resources: | ||
reservations: | ||
devices: | ||
- driver: cdi | ||
device_ids: ['vendor.com/device=myKmsg'] | ||
capabilities: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
if is_rootless; then | ||
reason=" - can't write to /etc/cdi" | ||
_show_ok skip "$testname # skip$reason" | ||
exit 0 | ||
fi | ||
|
||
mkdir -p /etc/cdi | ||
mount -t tmpfs tmpfs /etc/cdi | ||
cp device.json /etc/cdi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
if ! is_rootless; then | ||
umount /etc/cdi | ||
rmdir /etc/cdi || true # do not return an error if the directory is non-empty | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- bash -*- | ||
|
||
ctr_name="cdi_device-test-1" | ||
|
||
podman exec "$ctr_name" sh -c 'test /dev/ksmg1' |