Replace /proc/version with uname -r to read hm version

Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
This commit is contained in:
Chen Zhongjin 2024-01-23 17:37:03 +08:00
parent 5ec63a7d49
commit 31b297b721
2 changed files with 11 additions and 4 deletions

View File

@ -13,6 +13,7 @@
* limitations under the License.
*/
#include <sys/utsname.h>
#include "subcommand_list.h"
using namespace std;
@ -68,8 +69,11 @@ void SubCommandList::RegisterSubCommandList()
void SubCommandList::SetHM()
{
std::string version = ReadFileToString("/proc/version");
isHM_ = version.find(HMKERNEL) != std::string::npos;
utsname unameBuf;
if ((uname(&unameBuf)) == 0) {
std::string osrelease = unameBuf.release;
isHM_ = osrelease.find(HMKERNEL) != std::string::npos;
}
perfEvents_.SetHM(isHM_);
HLOGD("Set isHM_: %d", isHM_);
}

View File

@ -1764,8 +1764,11 @@ bool SubCommandRecord::RegisterSubCommandRecord(void)
void SubCommandRecord::SetHM()
{
std::string version = ReadFileToString(PROC_VERSION);
isHM_ = version.find(HMKERNEL) != std::string::npos;
utsname unameBuf;
if ((uname(&unameBuf)) == 0) {
std::string osrelease = unameBuf.release;
isHM_ = osrelease.find(HMKERNEL) != std::string::npos;
}
virtualRuntime_.SetHM(isHM_);
perfEvents_.SetHM(isHM_);
HLOGD("Set isHM_: %d", isHM_);