Skip to content

Commit adf05fb

Browse files
committed
Add IntelRdt schemata and enableMonitoring fields
Signed-off-by: Markus Lehtonen <[email protected]>
1 parent 1b24d96 commit adf05fb

File tree

4 files changed

+44
-19
lines changed

4 files changed

+44
-19
lines changed

pkg/cdi/container-edits_test.go

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -532,17 +532,21 @@ func TestApplyContainerEdits(t *testing.T) {
532532
spec: &oci.Spec{},
533533
edits: &cdi.ContainerEdits{
534534
IntelRdt: &cdi.IntelRdt{
535-
ClosID: "clos-1",
536-
L3CacheSchema: "L3:0=ff;1=ff",
537-
MemBwSchema: "MB:0=50;1=50",
535+
ClosID: "clos-1",
536+
L3CacheSchema: "L3:0=ff;1=ff",
537+
MemBwSchema: "MB:0=50;1=50",
538+
Schemata: []string{"L2:0=ffff"},
539+
EnableMonitoring: true,
538540
},
539541
},
540542
result: &oci.Spec{
541543
Linux: &oci.Linux{
542544
IntelRdt: &oci.LinuxIntelRdt{
543-
ClosID: "clos-1",
544-
L3CacheSchema: "L3:0=ff;1=ff",
545-
MemBwSchema: "MB:0=50;1=50",
545+
ClosID: "clos-1",
546+
L3CacheSchema: "L3:0=ff;1=ff",
547+
MemBwSchema: "MB:0=50;1=50",
548+
Schemata: []string{"L2:0=ffff"},
549+
EnableMonitoring: true,
546550
},
547551
},
548552
},
@@ -552,23 +556,27 @@ func TestApplyContainerEdits(t *testing.T) {
552556
spec: &oci.Spec{
553557
Linux: &oci.Linux{
554558
IntelRdt: &oci.LinuxIntelRdt{
555-
ClosID: "clos-1",
556-
L3CacheSchema: "L3:0=ff",
557-
MemBwSchema: "MB:0=100",
559+
ClosID: "clos-1",
560+
L3CacheSchema: "L3:0=ff",
561+
MemBwSchema: "MB:0=100",
562+
Schemata: []string{"L2:0=ffff"},
563+
EnableMonitoring: true,
558564
},
559565
},
560566
},
561567
edits: &cdi.ContainerEdits{
562568
IntelRdt: &cdi.IntelRdt{
563-
ClosID: "clos-2",
564-
L3CacheSchema: "L3:0=f",
569+
ClosID: "clos-2",
570+
L3CacheSchema: "L3:0=f",
571+
EnableMonitoring: false,
565572
},
566573
},
567574
result: &oci.Spec{
568575
Linux: &oci.Linux{
569576
IntelRdt: &oci.LinuxIntelRdt{
570-
ClosID: "clos-2",
571-
L3CacheSchema: "L3:0=f",
577+
ClosID: "clos-2",
578+
L3CacheSchema: "L3:0=f",
579+
EnableMonitoring: false,
572580
},
573581
},
574582
},
@@ -778,6 +786,7 @@ func TestAppend(t *testing.T) {
778786
IntelRdt: &cdi.IntelRdt{
779787
ClosID: "clos-1",
780788
L3CacheSchema: "L3:0=ff",
789+
Schemata: []string{"L2: 0xFFFF"},
781790
},
782791
},
783792
},

pkg/cdi/oci.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ func (d *DeviceNode) toOCI() spec.LinuxDevice {
5656
// toOCI returns the opencontainers runtime Spec LinuxIntelRdt for this IntelRdt config.
5757
func (i *IntelRdt) toOCI() *spec.LinuxIntelRdt {
5858
return &spec.LinuxIntelRdt{
59-
ClosID: i.ClosID,
60-
L3CacheSchema: i.L3CacheSchema,
61-
MemBwSchema: i.MemBwSchema,
59+
ClosID: i.ClosID,
60+
L3CacheSchema: i.L3CacheSchema,
61+
MemBwSchema: i.MemBwSchema,
62+
Schemata: i.Schemata,
63+
EnableMonitoring: i.EnableMonitoring,
6264
}
6365
}

specs-go/config.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ type Hook struct {
6464

6565
// IntelRdt describes the Linux IntelRdt parameters to set in the OCI spec.
6666
type IntelRdt struct {
67-
ClosID string `json:"closID,omitempty" yaml:"closID,omitempty"`
68-
L3CacheSchema string `json:"l3CacheSchema,omitempty" yaml:"l3CacheSchema,omitempty"`
69-
MemBwSchema string `json:"memBwSchema,omitempty" yaml:"memBwSchema,omitempty"`
67+
ClosID string `json:"closID,omitempty" yaml:"closID,omitempty"`
68+
L3CacheSchema string `json:"l3CacheSchema,omitempty" yaml:"l3CacheSchema,omitempty"`
69+
MemBwSchema string `json:"memBwSchema,omitempty" yaml:"memBwSchema,omitempty"`
70+
Schemata []string `json:"schemata,omitempty" yaml:"schemata,omitempty"`
71+
EnableMonitoring bool `json:"enableMonitoring,omitempty" yaml:"enableMonitoring,omitempty"`
7072
}

specs-go/version.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const (
4040
v070 version = "v0.7.0"
4141
v080 version = "v0.8.0"
4242
v100 version = "v1.0.0"
43+
v110 version = "v1.1.0"
4344

4445
// vEarliest is the earliest supported version of the CDI specification
4546
vEarliest version = v030
@@ -58,6 +59,7 @@ var validSpecVersions = requiredVersionMap{
5859
v070: requiresV070,
5960
v080: requiresV080,
6061
v100: requiresV100,
62+
v110: requiresV110,
6163
}
6264

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

145+
// requiresV110 returns true if the spec uses v1.1.0 features.
146+
func requiresV110(spec *Spec) bool {
147+
if i := spec.ContainerEdits.IntelRdt; i != nil {
148+
if i.Schemata != nil || i.EnableMonitoring {
149+
return true
150+
}
151+
}
152+
return false
153+
}
154+
143155
// requiresV100 returns true if the spec uses v1.0.0 features.
144156
// Since the v1.0.0 spec bump was due to moving the minimum version checks to
145157
// the spec package, there are no explicit spec changes.

0 commit comments

Comments
 (0)