Skip to content

Default CDI spec paths doesn't include /var/run/cdi #2460

Open
@remos

Description

@remos

The default CDI spec paths that are configured (and used in podman) only includes /etc/cdi, so /var/run/cdi isn't checked unless explicitly configured

// DefaultCdiSpecDirs defines the default cdi spec directories.
DefaultCdiSpecDirs = []string{"/etc/cdi"}

Was this intentional? Most documentation I've been able to find seems to insist podman should be checking /var/run/cdi too;

Including the container-device-interface repo's readme:

...
### Podman configuration

[podman](https://github.com/containers/podman) does not require any specific
configuration to enable CDI support and processes specified `--device` flags
directly. If fully-qualified device selectors (e.g.
`vendor.com/device=myDevice`) are included the CDI specifications at the default
location (`/etc/cdi` and `/var/run/cdi`) are checked for matching devices.

*Note:* Although initial support was added in
[`v3.2.0`](https://github.com/containers/podman/releases/tag/v3.2.0) this was
updated for the tagged `v0.3.0` CDI spec in
[`v4.1.0-rc.1`](https://github.com/containers/podman/releases/tag/v4.1.0-rc1)
with [commit
a234e4e](https://github.com/containers/podman/commit/a234e4e19662e172472877ce69523f4afea5c12e).
...

The default dirs used by the container-device-interface module itself includes both:

...
const (
	// DefaultStaticDir is the default directory for static CDI Specs.
	DefaultStaticDir = "/etc/cdi"
	// DefaultDynamicDir is the default directory for generated CDI Specs
	DefaultDynamicDir = "/var/run/cdi"
)

var (
	// DefaultSpecDirs is the default Spec directory configuration.
	// While altering this variable changes the package defaults,
	// the preferred way of overriding the default directories is
	// to use a WithSpecDirs options. Otherwise the change is only
	// effective if it takes place before creating the cache instance.
	DefaultSpecDirs = []string{DefaultStaticDir, DefaultDynamicDir}
...

I've checked this using podman 5.5.1 on nixos - and removing the line where the cdi cache's spec dirs are set from config (which defaults to what's defined in this module) seems to resolve it, presumably because it's using the cdi module's defaults at that point?

Is there appetite to add /var/run/cdi and/or just pull the default CDI spec directories from the exported DefaultSpecDirs defined in container-device-interface/pkgs/cdi?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions