Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions pkg/cdi/container-edits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,17 +532,21 @@ func TestApplyContainerEdits(t *testing.T) {
spec: &oci.Spec{},
edits: &cdi.ContainerEdits{
IntelRdt: &cdi.IntelRdt{
ClosID: "clos-1",
L3CacheSchema: "L3:0=ff;1=ff",
MemBwSchema: "MB:0=50;1=50",
ClosID: "clos-1",
L3CacheSchema: "L3:0=ff;1=ff",
MemBwSchema: "MB:0=50;1=50",
Schemata: []string{"L2:0=ffff"},
EnableMonitoring: true,
},
},
result: &oci.Spec{
Linux: &oci.Linux{
IntelRdt: &oci.LinuxIntelRdt{
ClosID: "clos-1",
L3CacheSchema: "L3:0=ff;1=ff",
MemBwSchema: "MB:0=50;1=50",
ClosID: "clos-1",
L3CacheSchema: "L3:0=ff;1=ff",
MemBwSchema: "MB:0=50;1=50",
Schemata: []string{"L2:0=ffff"},
EnableMonitoring: true,
},
},
},
Expand All @@ -552,23 +556,27 @@ func TestApplyContainerEdits(t *testing.T) {
spec: &oci.Spec{
Linux: &oci.Linux{
IntelRdt: &oci.LinuxIntelRdt{
ClosID: "clos-1",
L3CacheSchema: "L3:0=ff",
MemBwSchema: "MB:0=100",
ClosID: "clos-1",
L3CacheSchema: "L3:0=ff",
MemBwSchema: "MB:0=100",
Schemata: []string{"L2:0=ffff"},
EnableMonitoring: true,
},
},
},
edits: &cdi.ContainerEdits{
IntelRdt: &cdi.IntelRdt{
ClosID: "clos-2",
L3CacheSchema: "L3:0=f",
ClosID: "clos-2",
L3CacheSchema: "L3:0=f",
EnableMonitoring: false,
},
},
result: &oci.Spec{
Linux: &oci.Linux{
IntelRdt: &oci.LinuxIntelRdt{
ClosID: "clos-2",
L3CacheSchema: "L3:0=f",
ClosID: "clos-2",
L3CacheSchema: "L3:0=f",
EnableMonitoring: false,
},
},
},
Expand Down Expand Up @@ -778,6 +786,7 @@ func TestAppend(t *testing.T) {
IntelRdt: &cdi.IntelRdt{
ClosID: "clos-1",
L3CacheSchema: "L3:0=ff",
Schemata: []string{"L2: 0xFFFF"},
},
},
},
Expand Down
8 changes: 5 additions & 3 deletions pkg/cdi/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ func (d *DeviceNode) toOCI() spec.LinuxDevice {
// toOCI returns the opencontainers runtime Spec LinuxIntelRdt for this IntelRdt config.
func (i *IntelRdt) toOCI() *spec.LinuxIntelRdt {
return &spec.LinuxIntelRdt{
ClosID: i.ClosID,
L3CacheSchema: i.L3CacheSchema,
MemBwSchema: i.MemBwSchema,
ClosID: i.ClosID,
L3CacheSchema: i.L3CacheSchema,
MemBwSchema: i.MemBwSchema,
Schemata: i.Schemata,
EnableMonitoring: i.EnableMonitoring,
}
}
8 changes: 5 additions & 3 deletions specs-go/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ type Hook struct {

// IntelRdt describes the Linux IntelRdt parameters to set in the OCI spec.
type IntelRdt struct {
ClosID string `json:"closID,omitempty" yaml:"closID,omitempty"`
L3CacheSchema string `json:"l3CacheSchema,omitempty" yaml:"l3CacheSchema,omitempty"`
MemBwSchema string `json:"memBwSchema,omitempty" yaml:"memBwSchema,omitempty"`
ClosID string `json:"closID,omitempty" yaml:"closID,omitempty"`
L3CacheSchema string `json:"l3CacheSchema,omitempty" yaml:"l3CacheSchema,omitempty"`
MemBwSchema string `json:"memBwSchema,omitempty" yaml:"memBwSchema,omitempty"`
Schemata []string `json:"schemata,omitempty" yaml:"schemata,omitempty"`
EnableMonitoring bool `json:"enableMonitoring,omitempty" yaml:"enableMonitoring,omitempty"`
}
12 changes: 12 additions & 0 deletions specs-go/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const (
v070 version = "v0.7.0"
v080 version = "v0.8.0"
v100 version = "v1.0.0"
v110 version = "v1.1.0"

// vEarliest is the earliest supported version of the CDI specification
vEarliest version = v030
Expand All @@ -58,6 +59,7 @@ var validSpecVersions = requiredVersionMap{
v070: requiresV070,
v080: requiresV080,
v100: requiresV100,
v110: requiresV110,
}

// ValidateVersion checks whether the specified spec version is valid.
Expand Down Expand Up @@ -140,6 +142,16 @@ func (r requiredVersionMap) requiredVersion(spec *Spec) version {
return minVersion
}

// requiresV110 returns true if the spec uses v1.1.0 features.
func requiresV110(spec *Spec) bool {
if i := spec.ContainerEdits.IntelRdt; i != nil {
if i.Schemata != nil || i.EnableMonitoring {
return true
}
}
return false
}

// requiresV100 returns true if the spec uses v1.0.0 features.
// Since the v1.0.0 spec bump was due to moving the minimum version checks to
// the spec package, there are no explicit spec changes.
Expand Down