Skip to content

runc: CDI GPU passthrough setup (SetupDevices flow + hook scrub + LibLink recreation) - #121

Open
m-amin-sanati wants to merge 3 commits into
nestybox:masterfrom
m-amin-sanati:120-cdi-gpu-setup
Open

runc: CDI GPU passthrough setup (SetupDevices flow + hook scrub + LibLink recreation)#121
m-amin-sanati wants to merge 3 commits into
nestybox:masterfrom
m-amin-sanati:120-cdi-gpu-setup

Conversation

@m-amin-sanati

Copy link
Copy Markdown

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

Changes:

  • New SetupDevices flow:
    • Mgr.SetupDevices() client in libsysbox/sysbox/mgr.go asks sysbox-mgr to prepare the container's devices via the SetupDevices RPC.
    • cfgDevices() in libsysbox/syscont/spec.go, invoked from ConvertSpec before cfgMounts, reconciles device paths against the host (resolving /dev/nvidia*, MIG caps, /dev/net/tun) and passes the correct --user uid/gid to an nvidia-container-runtime-hook when present.
  • Fixes cfgDevices() never being called from ConvertSpec (it was previously dead code), which caused creating device nodes caused: no such file or directory for CDI-injected devices.
  • Scrubs the injected nvidia-cdi-hook from the OCI spec after device setup (it cannot run inside sysbox's user-mapped namespace).
  • Before scrubbing, captures its --link src::dst pairs into Sysbox.LibLinks so createDevices recreates the soname symlinks (e.g. libnvidia-ml.so.1 -> libnvidia-ml.so.X) inside the container rootfs during setup.

Closes #120

This is part of a 3-repo feature:

Adds the sysbox-runc side of the deviceSetup gRPC flow ported from
rodny-gpu, adapted to the v0.7.1 baseline (time-ns/openat2/userns
preserved):
- libsysbox/sysbox/mgr.go: Mgr.SetupDevices() client that asks sysbox-mgr
  to prepare/resolve the container's devices via the SetupDevices RPC.
- libsysbox/syscont/spec.go: cfgDevices() called in ConvertSpec before
  cfgMounts, which invokes sysMgrSetupDevices() to reconcile device paths
  with the host (resolving /dev/nvidia*, MIG caps, default /dev/net/tun)
  and to pass the right --user uid/gid to an nvidia-container-runtime-hook
  when present.

Signed-off-by: Amin San'ati <amin.sanati32@gmail.com>
The cfgDevices function (SetupDevices flow for DRA/CDI GPU passthrough)
was added but never invoked from ConvertSpec, leaving the device
path-resolution/dead-code and the nvidia-container-runtime-hook --user
re-write unreachable. Call it before cfgMounts, matching rodny-gpu.
Fixes container init 'creating device nodes caused: no such file or
directory' for CDI-injected devices on the MIG/DRA workspace.

Signed-off-by: Amin San'ati <amin.sanati32@gmail.com>
…cdi-hook

The nvidia-cdi-hook (create-symlinks) cannot run inside sysbox's user-mapped
container namespace lesh; scrub it in cfgDevices. Before scrubbing, capture
its --link src::dst pairs into Sysbox.LibLinks so that createDevices can
recreate the soname symlinks (libnvidia-ml.so.1 -> libnvidia-ml.so.X) inside
the container rootfs during setup.

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.

CDI GPU passthrough setup in sysbox-runc (SetupDevices flow + hook scrub + LibLink)

1 participant