Return NOT_SUPPORT for set function in VM guest
Fix the unit tests which are fail in VM guest environment. Change-Id: Id7c58887692bbdecba54f5d2d8463b292e19b4ad
This commit is contained in:
committed by
Galantsev, Dmitrii
parent
147af192b5
commit
a0ec98c30d
@@ -329,6 +329,25 @@ rsmi_status_t ErrnoToRsmiStatus(int err) {
|
||||
}
|
||||
}
|
||||
|
||||
bool is_vm_guest() {
|
||||
// the cpuinfo will set hypervisor flag in VM guest
|
||||
const std::string hypervisor = "hypervisor";
|
||||
std::string line;
|
||||
|
||||
// default to false if cannot find the file
|
||||
std::ifstream infile("/proc/cpuinfo");
|
||||
if (infile.fail()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (std::getline(infile, line)) {
|
||||
if (line.find(hypervisor) != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string leftTrim(const std::string &s) {
|
||||
if (!s.empty()) {
|
||||
return std::regex_replace(s, std::regex("^\\s+"), "");
|
||||
|
||||
Reference in New Issue
Block a user