gpu: Handle VFIO devices with DevicePlugin and CDI

We can provide devices during cold-plug with CDI annotation on a Pod
level and add per container device information wit the device plugin.
Since the sandbox has already attached the VFIO device remove them
from consideration and just apply the inner runtime CDI annotation.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
This commit is contained in:
Zvonko Kaiser 2025-04-14 20:49:27 +00:00
parent 486244b292
commit 3946435291

View File

@ -842,6 +842,20 @@ func (c *Container) createDevices(contConfig *ContainerConfig) error {
coldPlugDevices := []config.DeviceInfo{}
for i, vfio := range deviceInfos {
// If device is already attached during sandbox creation, e.g.
// with an CDI annotation, skip it in the container creation and
// only create the proper CDI annotation for the kata-agent
for _, dev := range config.PCIeDevicesPerPort["root-port"] {
if dev.HostPath == vfio.ContainerPath {
c.Logger().Warnf("device %s already attached to the sandbox, skipping", vfio.ContainerPath)
}
}
for _, dev := range config.PCIeDevicesPerPort["switch-port"] {
if dev.HostPath == vfio.ContainerPath {
c.Logger().Warnf("device %s already attached to the sandbox, skipping", vfio.ContainerPath)
}
}
// Only considering VFIO updates for Port and ColdPlug or
// HotPlug updates
isVFIODevice := deviceManager.IsVFIODevice(vfio.ContainerPath)