@@ -25,6 +25,7 @@ import (
25
25
dpapi "github.com/intel/intel-device-plugins-for-kubernetes/pkg/deviceplugin"
26
26
"k8s.io/klog/v2"
27
27
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
28
+ cdispec "tags.cncf.io/container-device-interface/specs-go"
28
29
)
29
30
30
31
const (
@@ -67,6 +68,24 @@ func (dp *devicePlugin) Scan(notifier dpapi.Notifier) error {
67
68
return nil
68
69
}
69
70
71
+ func createEFIMountsCDIDevice (name string ) * cdispec.Spec {
72
+
73
+ return & cdispec.Spec {
74
+ Version : dpapi .CDIVersion ,
75
+ Kind : dpapi .CDIVendor + "/sgx" ,
76
+ Devices : []cdispec.Device {
77
+ {
78
+ Name : name ,
79
+ ContainerEdits : cdispec.ContainerEdits {
80
+ Mounts : []* cdispec.Mount {
81
+ {HostPath : "efivarfs" , ContainerPath : "/sys/firmware/efi/efivars" , Type : "efivarfs" , Options : []string {"rw" , "nosuid" , "nodev" , "noexec" , "relatime" }},
82
+ },
83
+ },
84
+ },
85
+ },
86
+ }
87
+ }
88
+
70
89
func (dp * devicePlugin ) scan () (dpapi.DeviceTree , error ) {
71
90
devTree := dpapi .NewDeviceTree ()
72
91
@@ -96,6 +115,19 @@ func (dp *devicePlugin) scan() (dpapi.DeviceTree, error) {
96
115
devTree .AddDevice (deviceTypeProvision , devID , dpapi .NewDeviceInfoWithTopologyHints (pluginapi .Healthy , nodes , nil , nil , nil , nil , nil ))
97
116
}
98
117
118
+ tdQeNodes := []pluginapi.DeviceSpec {
119
+ {HostPath : sgxEnclavePath , ContainerPath : sgxEnclavePath , Permissions : "rw" },
120
+ {HostPath : sgxProvisionPath , ContainerPath : sgxProvisionPath , Permissions : "rw" },
121
+ }
122
+
123
+ devTree .AddDevice ("tdqe" , "tdqe-1" , dpapi .NewDeviceInfoWithTopologyHints (pluginapi .Healthy , tdQeNodes , nil , nil , nil , nil , nil ))
124
+
125
+ regNodes := []pluginapi.DeviceSpec {
126
+ {HostPath : sgxEnclavePath , ContainerPath : sgxEnclavePath , Permissions : "rw" },
127
+ }
128
+
129
+ devTree .AddDevice ("registration" , "registration-1" , dpapi .NewDeviceInfoWithTopologyHints (pluginapi .Healthy , regNodes , nil , nil , nil , nil , createEFIMountsCDIDevice ("registration" )))
130
+
99
131
return devTree , nil
100
132
}
101
133
0 commit comments