mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-07-01 22:50:54 +00:00
Add support for cold-plugging raw VFIO devices in standalone container scenarios (e.g., `ctr --device /dev/vfio/0`) where devices are specified directly in the OCI spec rather than through K8S CDI/device plugins. This implements a fallback path that: - Reads linux.devices from the OCI spec in the container bundle - Identifies character devices under /dev/vfio - Cold-plugs them before VM boot using the configured cold_plug_vfio mode - Handles VFIO-AP devices specially by using NoPort topology - Mirrors the Go runtime's coldOrHotPlugVFIO() behavior The implementation: - Adds prepare_coldplug_raw_vfio_devices() method to VirtSandbox - Exports is_vfio_ap_device() helper for device type detection - Integrates with existing CDI device cold-plug flow - Only activates when cold_plug_vfio is configured (not "no-port") - Skips processing when bundle path is unavailable or OCI spec missing Plus, update resource manager: - Skipping hotplug for cold-plugged mediated AP devices - Handling the AP devices to get exposed to the agent This enables VFIO device passthrough for standalone containers while maintaining compatibility with Kubernetes pod resource API workflows. Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>