From 420b84c0185123e9603dbab4303db79f3752cf73 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Wed, 15 Oct 2025 09:43:06 +0300 Subject: [PATCH] Allow root CLOS in IntelRdt.closID Enables: https://github.com/opencontainers/runtime-spec/pull/1289 Signed-off-by: Markus Lehtonen --- pkg/cdi/container-edits.go | 6 ++++-- pkg/cdi/container-edits_test.go | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/cdi/container-edits.go b/pkg/cdi/container-edits.go index 4744eff8..450a84f6 100644 --- a/pkg/cdi/container-edits.go +++ b/pkg/cdi/container-edits.go @@ -337,8 +337,10 @@ func ValidateIntelRdt(i *cdi.IntelRdt) error { // Validate validates the IntelRdt configuration. func (i *IntelRdt) Validate() error { - // ClosID must be a valid Linux filename - if len(i.ClosID) >= 4096 || i.ClosID == "." || i.ClosID == ".." || strings.ContainsAny(i.ClosID, "/\n") { + // ClosID must be a valid Linux filename. Exception: "/" refers to the root CLOS. + switch c := i.ClosID; { + case c == "/": + case len(c) >= 4096, c == ".", c == "..", strings.ContainsAny(c, "/\n"): return errors.New("invalid ClosID") } return nil diff --git a/pkg/cdi/container-edits_test.go b/pkg/cdi/container-edits_test.go index ace0fd2e..c1fcfab0 100644 --- a/pkg/cdi/container-edits_test.go +++ b/pkg/cdi/container-edits_test.go @@ -254,6 +254,14 @@ func TestValidateContainerEdits(t *testing.T) { }, }, }, + { + name: "valid rdt config, root clos", + edits: &cdi.ContainerEdits{ + IntelRdt: &cdi.IntelRdt{ + ClosID: "/", + }, + }, + }, { name: "invalid rdt config, invalid closID (slash)", edits: &cdi.ContainerEdits{