Skip to contentSkip to conversation

cdi: add container-device-interface commandline utility

PATCH Superseded Koen Kooi 1 participant 1 message Apr 16

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Koen Kooi

author
#0 lore raw

PATCH 1/1 cdi: add container-device-interface commandline utility

From the upstream description:

The cdi command-line tool is a utility for inspecting and interacting with the CDI (Container Device Interface) cache. It allows developers and system administrators to:

- List CDI Spec files: View all available CDI specification files in the configured directories
- List vendors: Display registered device vendors in the CDI cache
- List device classes: Show available device classes from CDI Specs
- List devices: Enumerate all CDI devices available in the system
- Validate specs: Verify CDI specification files against the JSON schema
- Inject devices: Inject CDI device configurations into OCI runtime specifications
- Monitor cache: Watch for changes in the CDI cache and Spec directories
- Resolve devices: Resolve fully-qualified device names to their configurations

The CLI tool is particularly useful for debugging CDI configurations, validating spec files, and testing device assignments before deploying them in production environments.

---
 recipes-containers/cdi/cdi_git.bb             | 41 +++++++++++++++
 ...le-add-GOBUILDFLAGS-to-go-build-call.patch | 31 ++++++++++++
 recipes-containers/cdi/go-mod-cache.inc       | 50 +++++++++++++++++++
 recipes-containers/cdi/go-mod-git.inc         | 42 ++++++++++++++++
 .../cdi/go-mod-hybrid-cache.inc               | 10 ++++
 recipes-containers/cdi/go-mod-hybrid-git.inc  |  7 +++
 .../cdi/go-mod-hybrid-gomod.inc               | 45 +++++++++++++++++
 7 files changed, 226 insertions(+)
 create mode 100644 recipes-containers/cdi/cdi_git.bb
 create mode 100644 recipes-containers/cdi/files/0001-makefile-add-GOBUILDFLAGS-to-go-build-call.patch
 create mode 100644 recipes-containers/cdi/go-mod-cache.inc
 create mode 100644 recipes-containers/cdi/go-mod-git.inc
 create mode 100644 recipes-containers/cdi/go-mod-hybrid-cache.inc
 create mode 100644 recipes-containers/cdi/go-mod-hybrid-git.inc
 create mode 100644 recipes-containers/cdi/go-mod-hybrid-gomod.inc
recipes-containers/cdi/cdi_git.bb new file +41 -0
new file mode 100644
index 00000000..5c5d4fee
@@ -0,0 +1,41 @@
+DESCRIPTION = "The cdi command-line tool is a utility for inspecting and interacting with the CDI (Container Device Interface) cache."
+SUMMARY = "The cdi command-line tool."
+HOMEPAGE = "https://github.com/cncf-tags/container-device-interface"
+
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=86d3f3a95c324c9479bd8986968f4327"
+
+PV = "1.1.0+git"
+SRCREV_cdi = "db8fd53e4587ebcb5cd240a0054e75e6f6d55799"
+SRCREV_FORMAT = "cdi"
+SRC_URI = "git://github.com/cncf-tags/container-device-interface.git;protocol=https;name=cdi;branch=main;destsuffix=${GO_SRCURI_DESTSUFFIX} \
+           file://0001-makefile-add-GOBUILDFLAGS-to-go-build-call.patch \
+          "
+SRCREV_FORMAT = "cdi"
+
+GO_IMPORT = "tags.cncf.io/container-device-interface/"
+
+inherit go goarch
+
+# GO_MOD_FETCH_MODE: "vcs" (all git://) or "hybrid" (gomod:// + git://)
+GO_MOD_FETCH_MODE ?= "hybrid"
+
+# VCS mode: all modules via git://
+include ${@ "go-mod-git.inc" if d.getVar("GO_MOD_FETCH_MODE") == "vcs" else ""}
+include ${@ "go-mod-cache.inc" if d.getVar("GO_MOD_FETCH_MODE") == "vcs" else ""}
+
+# Hybrid mode: gomod:// for most, git:// for selected
+include ${@ "go-mod-hybrid-gomod.inc" if d.getVar("GO_MOD_FETCH_MODE") == "hybrid" else ""}
+include ${@ "go-mod-hybrid-git.inc" if d.getVar("GO_MOD_FETCH_MODE") == "hybrid" else ""}
+include ${@ "go-mod-hybrid-cache.inc" if d.getVar("GO_MOD_FETCH_MODE") == "hybrid" else ""}
+
+do_compile() {
+	cd ${S}/src/${GO_IMPORT}
+	pwd
+	oe_runmake
+}
+
+do_install() {
+        install -d "${D}${bindir}"
+        install -m 755 ${S}/src/${GO_IMPORT}/bin/* "${D}${bindir}"
+}
recipes-containers/cdi/files/0001-makefile-add-GOBUILDFLAGS-to-go-build-call.patch new file +31 -0
new file mode 100644
index 00000000..b5222ade
@@ -0,0 +1,31 @@
+From 53853d00a0d24fae8ebb975dea1b342c0b25a2c0 Mon Sep 17 00:00:00 2001
+From: Koen Kooi <[email protected]>
+Date: Tue, 14 Apr 2026 13:45:45 +0200
+Subject: [PATCH] makefile: add GOBUILDFLAGS to go build call
+
+We may need to specify things like -trimpath, so add $(GOBUILDFLAGS)
+to allow them to be passed from the recipe to the Makefile.
+
+Upstream-Status: Inappropriate [embedded specific]
+
+Signed-off-by: Koen Kooi <[email protected]>
+---
+ Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index 71afa0e..cd4f0ed 100644
+--- a/src/tags.cncf.io/container-device-interface/Makefile
++++ b/src/tags.cncf.io/container-device-interface/Makefile
+@@ -63,7 +63,7 @@ golangci-lint ci-lint:
+ 
+ $(BINARIES): bin/%:
+ 	$(Q)echo "Building $@..."
+-	$(Q)(cd cmd/$(*) && $(GO_BUILD) -o $(abspath $@) .)
++	$(Q)(cd cmd/$(*) && $(GO_BUILD) $(GOBUILDFLAGS) -o $(abspath $@) .)
+ 
+ #
+ # go module tidy and verify targets
+-- 
+2.47.3
+
recipes-containers/cdi/go-mod-cache.inc new file +50 -0

50 lines not on this page · raw message

recipes-containers/cdi/go-mod-git.inc new file +42 -0

42 lines not on this page · raw message

recipes-containers/cdi/go-mod-hybrid-cache.inc new file +10 -0
new file mode 100644
index 00000000..7cbd74eb
@@ -0,0 +1,10 @@
+# Generated by oe-go-mod-fetcher-hybrid.py
+# Metadata for git-fetched modules (VCS path)
+# Used by go-mod-vcs.bbclass to build module cache from git checkouts
+
+inherit go-mod-vcs
+
+# Module metadata for cache building (one module per line)
+GO_MODULE_CACHE_DATA = '[\
+{"module":"tags.cncf.io/container-device-interface","version":"v1.1.0","vcs_hash":"2a0706ee0554e66b341fabb5c09e62f00336b0a7e6faac981d973f30b4064622","timestamp":"2025-12-10T08:48:20Z","subdir":"","vcs_ref":"refs/tags/v1.1.0"},\
+{"module":"tags.cncf.io/container-device-interface/specs-go","version":"v1.1.0","vcs_hash":"2a0706ee0554e66b341fabb5c09e62f00336b0a7e6faac981d973f30b4064622","timestamp":"2025-12-10T08:48:20Z","subdir":"specs-go","vcs_ref":"refs/tags/specs-go/v1.1.0"}]'
recipes-containers/cdi/go-mod-hybrid-git.inc new file +7 -0
new file mode 100644
index 00000000..43dc77ee
@@ -0,0 +1,7 @@
+# Generated by oe-go-mod-fetcher-hybrid.py
+# Go modules fetched from git repositories (VCS path)
+#
+# These modules are fetched directly from their git repositories.
+# They provide full VCS provenance and allow easy SRCREV bumping.
+
+SRC_URI += "git://github.com/cncf-tags/container-device-interface;protocol=https;nobranch=1;tag=v1.1.0;shallow=1;rev=98a7d735d9592c1ccca0130e06b0709f4b65ecbf;name=git_c2439148_0;destsuffix=vcs_cache/2a0706ee0554e66b341fabb5c09e62f00336b0a7e6faac981d973f30b4064622"
recipes-containers/cdi/go-mod-hybrid-gomod.inc new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.47.3