mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-05 16:27:05 +00:00
Upated RDT Discovery() to use exit status
- Updated RDT helper functions.
This commit is contained in:
parent
b44b0549bd
commit
eef0a6c185
4 changed files with 23 additions and 35 deletions
|
@ -10,18 +10,16 @@ int main(int argc, char *argv[]) {
|
|||
lcpuid(0x7, 0x0, &res);
|
||||
if (!(res.ebx & (1 << 15))) {
|
||||
det = 0;
|
||||
printf("NOT DETECTED");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
else {
|
||||
lcpuid(0x10, 0x0, &res);
|
||||
if (!(res.ebx & (1 << 2))) {
|
||||
det = 0;
|
||||
printf("NOT DETECTED");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (det)
|
||||
printf("DETECTED");
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -13,18 +13,16 @@ int main(int argc, char *argv[]) {
|
|||
lcpuid(0x7, 0x0, &res);
|
||||
if (!(res.ebx & (1 << 15))) {
|
||||
det = 0;
|
||||
printf("NOT DETECTED");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
else {
|
||||
lcpuid(0x10, 0x0, &res);
|
||||
if (!(res.ebx & (1 << 1))) {
|
||||
det = 0;
|
||||
printf("NOT DETECTED");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (det)
|
||||
printf("DETECTED");
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -10,18 +10,16 @@ int main(int argc, char *argv[]) {
|
|||
lcpuid(0x7, 0x0, &res);
|
||||
if (!(res.ebx & (1 << 12))) {
|
||||
det = 0;
|
||||
printf("NOT DETECTED");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
else {
|
||||
lcpuid(0xf, 0x0, &res);
|
||||
if (!(res.edx & (1 << 1))) {
|
||||
det=0;
|
||||
printf("NOT DETECTED");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (det)
|
||||
printf("DETECTED");
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
34
sources.go
34
sources.go
|
@ -19,9 +19,6 @@ type FeatureSource interface {
|
|||
}
|
||||
|
||||
const (
|
||||
// DETECTED is compared with stdout for RDT detection helper programs.
|
||||
DETECTED = "DETECTED"
|
||||
|
||||
// RDTBin is the path to RDT detection helpers.
|
||||
RDTBin = "/go/src/github.com/kubernetes-incubator/node-feature-discovery/rdt-discovery"
|
||||
)
|
||||
|
@ -50,30 +47,27 @@ func (s rdtSource) Name() string { return "rdt" }
|
|||
func (s rdtSource) Discover() ([]string, error) {
|
||||
features := []string{}
|
||||
|
||||
out, err := exec.Command("bash", "-c", path.Join(RDTBin, "mon-discovery")).Output()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't detect support for RDT monitoring: %s", err.Error())
|
||||
}
|
||||
if string(out[:]) == DETECTED {
|
||||
cmd := exec.Command("bash", "-c", path.Join(RDTBin, "mon-discovery"))
|
||||
if err := cmd.Run(); err != nil {
|
||||
stderrLogger.Printf("support for RDT monitoring was not detected: %s", err.Error())
|
||||
} else {
|
||||
// RDT monitoring detected.
|
||||
features = append(features, "RDTMON")
|
||||
}
|
||||
|
||||
out, err = exec.Command("bash", "-c", path.Join(RDTBin, "l3-alloc-discovery")).Output()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't detect support for RDT L3 allocation: %s", err.Error())
|
||||
}
|
||||
if string(out[:]) == DETECTED {
|
||||
// RDT L3 cache allocation detected.
|
||||
cmd = exec.Command("bash", "-c", path.Join(RDTBin, "l3-alloc-discovery"))
|
||||
if err := cmd.Run(); err != nil {
|
||||
stderrLogger.Printf("support for RDT L3 allocation was not detected: %s", err.Error())
|
||||
} else {
|
||||
// RDT monitoring detected.
|
||||
features = append(features, "RDTL3CA")
|
||||
}
|
||||
|
||||
out, err = exec.Command("bash", "-c", path.Join(RDTBin, "l2-alloc-discovery")).Output()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't detect support for RDT L2 allocation: %s", err.Error())
|
||||
}
|
||||
if string(out[:]) == DETECTED {
|
||||
// RDT L2 cache allocation detected.
|
||||
cmd = exec.Command("bash", "-c", path.Join(RDTBin, "l2-alloc-discovery"))
|
||||
if err := cmd.Run(); err != nil {
|
||||
stderrLogger.Printf("support for RDT L2 allocation was not detected: %s", err.Error())
|
||||
} else {
|
||||
// RDT monitoring detected.
|
||||
features = append(features, "RDTL2CA")
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue