Repository navigation
feat(platform): auto-wire KubeVirt permittedHostDevices + HostDevices feature gate when gpu-operator is enabled #2765
Description
Summary
After enabling cozystack.gpu-operator with the default (passthrough) variant, the registered GPU resource (e.g. nvidia.com/GH100_H200_SXM_141GB) shows up in kubectl get node -o yaml | grep allocatable — but a KubeVirt VM that references it as a hostDevices.deviceName is rejected by the admission webhook.
Two pieces have to be wired into the KubeVirt CR manually for VFIO passthrough to actually be usable, and neither is automated by Cozystack today:
spec.configuration.developerConfiguration.featureGatesmust includeHostDevices. The default Cozystack KubeVirt CR shipsGPUbut notHostDevices— and they are separate gates in current KubeVirt; theGPUgate alone does not unlockspec.template.spec.domain.devices.hostDevices.spec.configuration.permittedHostDevices.pciHostDevicesmust list the GPU's PCI vendor:device and the resourceName published bynvidia-sandbox-device-plugin. Without this entry the admission webhook errors with "PCI host device not permitted".
Observed
Patch needed before any VM with the GPU can be created:
spec:
configuration:
developerConfiguration:
featureGates:
- HotplugVolumes
- ExpandDisks
- CPUManager
- VMExport
- HostDevices # <-- added
permittedHostDevices:
pciHostDevices:
- pciVendorSelector: "10DE:2335"
resourceName: nvidia.com/GH100_H200_SXM_141GB
externalResourceProvider: trueexternalResourceProvider: true is required because the resource is published by nvidia-sandbox-device-plugin DaemonSet (deployed by gpu-operator), not by KubeVirt itself.
gpu-operator's ServiceAccount has no RBAC to patch the KubeVirt CR, so this cannot be done by the operator. Cozystack's cozystack-engine overwrites Secret cozystack-values entirely, so trying to inject this through the existing user-overrides path is also a dead end.
Proposal
When cozystack.gpu-operator is enabled, the platform should auto-populate the KubeVirt CR with:
HostDevicesadded todeveloperConfiguration.featureGatespermittedHostDevices.pciHostDevicesentries built from the PCI device IDs the sandbox-device-plugin publishes (vendor:device discovered from the host'slspci -nn, resourceName matching the device-plugin's registered name)
Implementation options:
- A small controller in
cozystack-enginethat watches Node Allocatable fornvidia.com/*resources and reconciles the corresponding KubeVirt CR entries. - Or: extend the
system/kubevirt-operatorchart with a values block that takes a list of(vendor:device, resourceName)pairs and templates them into the KubeVirt CR, then wire that from the Platform Package when gpu-operator is enabled. - Or: a one-shot Job included in the gpu-operator package that patches the KubeVirt CR on install and on upgrade.
The first option is the cleanest but the heaviest. The third is the smallest delta and matches the way other Cozystack post-install adjustments are done.
Related
- The need for a
containervariant ofcozystack.gpu-operatoris a separate issue; this issue is specifically about the passthrough path. For the container variant the KubeVirt wiring would not be needed. - Without this wiring the passthrough variant ends up "halfway working": the gpu-operator stack is green, the GPU resource is visible in
kubectl describe node, but no VM can actually use it. That is the most confusing failure mode for a new user — every component reports healthy and the VM simply refuses to schedule with an opaque message.
Activity
feat(platform): auto-wire KubeVirt permittedHostDevices and HostDevic…