diff --git a/pkg/cdi/container-edits_test.go b/pkg/cdi/container-edits_test.go index c1fcfab..cb3c0de 100644 --- a/pkg/cdi/container-edits_test.go +++ b/pkg/cdi/container-edits_test.go @@ -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, }, }, }, @@ -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, }, }, }, @@ -778,6 +786,7 @@ func TestAppend(t *testing.T) { IntelRdt: &cdi.IntelRdt{ ClosID: "clos-1", L3CacheSchema: "L3:0=ff", + Schemata: []string{"L2: 0xFFFF"}, }, }, }, diff --git a/pkg/cdi/oci.go b/pkg/cdi/oci.go index e7d18cd..d8fa14a 100644 --- a/pkg/cdi/oci.go +++ b/pkg/cdi/oci.go @@ -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, } } diff --git a/specs-go/config.go b/specs-go/config.go index 6f403e6..577331f 100644 --- a/specs-go/config.go +++ b/specs-go/config.go @@ -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"` } diff --git a/specs-go/version.go b/specs-go/version.go index 002e035..b2e90c4 100644 --- a/specs-go/version.go +++ b/specs-go/version.go @@ -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 @@ -58,6 +59,7 @@ var validSpecVersions = requiredVersionMap{ v070: requiresV070, v080: requiresV080, v100: requiresV100, + v110: requiresV110, } // ValidateVersion checks whether the specified spec version is valid. @@ -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.