Skip to content

mgr: MIG GPU passthrough via DRA/CDI (deviceMgr + MIG cap-node mknod) - #84

Open
m-amin-sanati wants to merge 3 commits into
nestybox:masterfrom
m-amin-sanati:83-mig-gpu-dra-cdi
Open

mgr: MIG GPU passthrough via DRA/CDI (deviceMgr + MIG cap-node mknod)#84
m-amin-sanati wants to merge 3 commits into
nestybox:masterfrom
m-amin-sanati:83-mig-gpu-dra-cdi

Conversation

@m-amin-sanati

Copy link
Copy Markdown

Adds the sysbox-mgr side of the MIG/DRA/CDI GPU passthrough feature.

Changes:

  • New device manager (deviceMgr): a radix-tree of devicers (root/net/amd/intel/nvidia), per-container device-node creation under the sysbox lib dir, and DeviceMounts for bind-mounting devices into the container. The nvidia devicer reconciles container device paths against host roots {"/", "/run/nvidia/driver"}, covering both direct /dev nodes and MIG caps under /dev/nvidia-caps.
  • isMigCapNode() detects char nodes under /dev/nvidia-caps/nvidia-cap*.
  • mknodMigCapNode() idempotently creates a missing MIG cap node on the host from its (major, minor) pair, invoked from Discover() when capability reads fail for a MIG cap node (sysbox-mgr runs as root, so host mknod is allowed). This fixes the case where per-slice MIG cap nodes never materialize on the host when the NVIDIA driver is containerized (GPU-Operator).
  • Registers the SetupDevices gRPC callback, removes devices on container teardown, and appends device bind-mounts during mount-request handling. Adds go-immutable-radix dependency.
  • Adds unit tests for discovery reconciliation and the full SetupDevices/DeviceMounts/RemoveDevices round-trip.

Closes #83

This is part of a 3-repo feature:

Adds the device manager (deviceMgr) package ported from the upstream
rodny-gpu branch: devicer radix-tree with root/net/amd/intel/nvidia
devicers, per-container device node creation under sysboxLibDir/devices,
and DeviceMounts for bind-mounting into the container.
The nvidia devicer reconciles container device paths against host roots
{"/", "/run/nvidia/driver"}, which covers both the direct /dev nodes
and MIG caps under /dev/nvidia-caps for GPU-Operator DRA/CDI setups.
Wires it into mgr.go: constructs the DeviceMgr, registers the
SetupDevices gRPC callback, removes devices on container teardown, and
appends device bind-mounts during reqMounts. Adds go-immutable-radix dep.

Signed-off-by: Amin San'ati <amin.sanati32@gmail.com>
Adds tests for the ported deviceMgr:
- root devicer passthrough (unsupported devices must not be altered)
- nvidia devicer DRA/CDI reconciliation across host driver roots
  (/dev and /run/nvidia/driver), covering MIG caps under /dev/nvidia-caps
- full SetupDevices/DeviceMounts/RemoveDevices round-trip (skipped when
  unprivileged since device-node creation needs CAP_MKNOD)

Signed-off-by: Amin San'ati <amin.sanati32@gmail.com>
When the nvidia driver is containerized (GPU-Operator), per-slice MIG
capability nodes under /dev/nvidia-caps never materialize on the host;
they only exist inside the driver container at /run/nvidia/driver/dev.
sysbox runs containers in a user namespace and bind-mounts device nodes
from a host path, so Discover() returning nil makes sysbox-runc fail with
ENOENT and the workspace CrashLoopBackOff.
Add isMigCapNode() to detect char nodes under /dev/nvidia-caps/nvidia-cap*
and mknodMigCapNode() to create the missing node on the host from its
(major, minor) pair (idempotent, skips if present). Discover() invokes the
fallback when both /proc capability reads fail and the request is a MIG
cap node, so the existing bind path succeeds. sysbox-mgr runs as root on
the host, so there is no user-namespace mknod restriction.

Signed-off-by: Amin San'ati <amin.sanati32@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MIG GPU passthrough via DRA/CDI (deviceMgr + MIG cap-node mknod)

1 participant