File tree 1 file changed +39
-1
lines changed
1 file changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,13 @@ unsigned long gethwcap() {
25
25
*/
26
26
import "C"
27
27
28
+ import (
29
+ "os"
30
+ "strings"
31
+
32
+ "k8s.io/klog/v2"
33
+ )
34
+
28
35
/*
29
36
all special features for s390x should be defined here; canonical list:
30
37
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/s390/include/asm/elf.h
@@ -96,4 +103,35 @@ func getCpuidFlags() []string {
96
103
return r
97
104
}
98
105
99
- func getCpuidAttributes () map [string ]string { return nil }
106
+ func getCpuidAttributes () map [string ]string {
107
+ ret := make (map [string ]string )
108
+
109
+ hypervisor , err := getHypervisor ()
110
+ if err != nil {
111
+ klog .ErrorS (err , "failed to detect hypervisor" )
112
+ return ret
113
+ }
114
+ ret ["hypervisor" ] = hypervisor
115
+
116
+ return ret
117
+ }
118
+
119
+ func getHypervisor () (string , error ) {
120
+ data , err := os .ReadFile ("/proc/sysinfo" )
121
+ if err != nil {
122
+ return "" , err
123
+ }
124
+
125
+ hypervisor := "PR/SM"
126
+ for _ , line := range strings .Split (string (data ), "\n " ) {
127
+ if strings .Contains (line , "Control Program:" ) {
128
+ parts := strings .SplitN (line , ":" , 2 )
129
+ if len (parts ) == 2 {
130
+ hypervisor = strings .TrimSpace (parts [1 ])
131
+ }
132
+ break
133
+ }
134
+ }
135
+
136
+ return hypervisor , nil
137
+ }
You can’t perform that action at this time.
0 commit comments