Skip to content

Commit 420b84c

Browse files
committed
Allow root CLOS in IntelRdt.closID
Enables: opencontainers/runtime-spec#1289 Signed-off-by: Markus Lehtonen <[email protected]>
1 parent e17a161 commit 420b84c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pkg/cdi/container-edits.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,10 @@ func ValidateIntelRdt(i *cdi.IntelRdt) error {
337337

338338
// Validate validates the IntelRdt configuration.
339339
func (i *IntelRdt) Validate() error {
340-
// ClosID must be a valid Linux filename
341-
if len(i.ClosID) >= 4096 || i.ClosID == "." || i.ClosID == ".." || strings.ContainsAny(i.ClosID, "/\n") {
340+
// ClosID must be a valid Linux filename. Exception: "/" refers to the root CLOS.
341+
switch c := i.ClosID; {
342+
case c == "/":
343+
case len(c) >= 4096, c == ".", c == "..", strings.ContainsAny(c, "/\n"):
342344
return errors.New("invalid ClosID")
343345
}
344346
return nil

pkg/cdi/container-edits_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,14 @@ func TestValidateContainerEdits(t *testing.T) {
254254
},
255255
},
256256
},
257+
{
258+
name: "valid rdt config, root clos",
259+
edits: &cdi.ContainerEdits{
260+
IntelRdt: &cdi.IntelRdt{
261+
ClosID: "/",
262+
},
263+
},
264+
},
257265
{
258266
name: "invalid rdt config, invalid closID (slash)",
259267
edits: &cdi.ContainerEdits{

0 commit comments

Comments
 (0)