Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.1:Update
lsvpd
lsvpd.bug-941938_add_powerkvm_guest_detection1....
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File lsvpd.bug-941938_add_powerkvm_guest_detection1.patch of Package lsvpd
From 4113ddd54a2ff224ff064cad99fbbd972f933ff6 Mon Sep 17 00:00:00 2001 From: Janani <jananive@linux.vnet.ibm.com> Date: Thu, 4 Dec 2014 14:00:06 +0530 Subject: [PATCH] lsmcode: Read entire /proc/cpuinfo to fetch platform The platform field in /proc/cpuinfo for both PowerKVM Guest and PowerVM LPAR is pSeries. In order to fetch the right platform, we need to read the entire file. If pSeries (emulated by qemu) is present in the file, we can be sure the platform is PowerKVM Guest. Signed-off-by: Janani Venkataraman <jananive@linux.vnet.ibm.com> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> --- src/internal/sys_interface/platformcollector.cpp | 38 ++++++++++++++++++------ 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/internal/sys_interface/platformcollector.cpp b/src/internal/sys_interface/platformcollector.cpp index 410056159359..a45e98c4ccfc 100644 --- a/src/internal/sys_interface/platformcollector.cpp +++ b/src/internal/sys_interface/platformcollector.cpp @@ -58,16 +58,36 @@ error: void PlatformCollector::get_platform() { - string platform = getCpuInfoTag("platform"); - - if ( platform == "PowerNV" ) - platform_type = PF_POWERKVM_HOST; - else if ( platform == "pSeries (emulated by qemu)" ) - platform_type = PF_POWERKVM_PSERIES_GUEST; - else if ( platform == "pSeries" ) - platform_type = PF_POWERVM_LPAR; - else + string buf; + ifstream ifs(PLATFORM_FILE); + Logger log; + + if (!ifs.is_open()) { + log.log("Unable to open file /proc/cpuinfo", LOG_WARNING); platform_type = PF_ERROR; + return; + } + + buf[0] = '\0'; + + while (getline(ifs, buf)) { + if (strstr(buf.c_str(), "PowerNV")) { + platform_type = PF_POWERKVM_HOST; + break; + } else if (strstr(buf.c_str(), "pSeries (emulated by qemu)")) { + platform_type = PF_POWERKVM_PSERIES_GUEST; + break; + } else if (strstr(buf.c_str(), "pSeries")) { + platform_type = PF_POWERVM_LPAR; + /* catch model for PowerNV guest */ + continue; + } + } + + if (platform_type == PF_NULL) + platform_type = PF_ERROR; + + ifs.close(); } string PlatformCollector::get_platform_name() -- 2.1.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor