Hello community, here is the log from the commit of package lsvpd for openSUSE:Factory checked in at 2015-09-08 17:38:46 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/lsvpd (Old) and /work/SRC/openSUSE:Factory/.lsvpd.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "lsvpd" Changes: -------- --- /work/SRC/openSUSE:Factory/lsvpd/lsvpd.changes 2015-04-22 01:19:42.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.lsvpd.new/lsvpd.changes 2015-09-08 17:39:57.000000000 +0200 @@ -1,0 +2,9 @@ +Fri Aug 28 12:33:16 UTC 2015 - [email protected] + +- support lsvpd on PowerKVM guest (bsc#941938) + +- added patches: + * lsvpd.bug-941938_add_powerkvm_guest_detection1.patch + * lsvpd.bug-941938_add_powerkvm_guest_detection2.patch + +------------------------------------------------------------------- New: ---- lsvpd.bug-941938_add_powerkvm_guest_detection1.patch lsvpd.bug-941938_add_powerkvm_guest_detection2.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ lsvpd.spec ++++++ --- /var/tmp/diff_new_pack.WFQHLY/_old 2015-09-08 17:39:58.000000000 +0200 +++ /var/tmp/diff_new_pack.WFQHLY/_new 2015-09-08 17:39:58.000000000 +0200 @@ -25,6 +25,8 @@ Url: http://sourceforge.net/projects/linux-diag/ Source0: http://sourceforge.net/projects/linux-diag/files/lsvpd-new/%{version}/%{name}-%{version}.tar.gz Patch0: lsvpd.no-return-in-nonvoid-function.patch +Patch1: lsvpd.bug-941938_add_powerkvm_guest_detection1.patch +Patch2: lsvpd.bug-941938_add_powerkvm_guest_detection2.patch BuildRequires: gcc-c++ BuildRequires: librtas-devel BuildRequires: libvpd2-devel @@ -49,6 +51,8 @@ %prep %setup -q %patch0 -p1 +%patch1 -p1 +%patch2 -p1 %build export CFLAGS="%{optflags} -UPCI_IDS -DPCI_IDS='\"%{_datadir}/pci.ids\"' -UUSB_IDS -DUSB_IDS='\"%{_datadir}/usb.ids\"'" ++++++ lsvpd.bug-941938_add_powerkvm_guest_detection1.patch ++++++ >From 4113ddd54a2ff224ff064cad99fbbd972f933ff6 Mon Sep 17 00:00:00 2001 From: Janani <[email protected]> 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 <[email protected]> Signed-off-by: Vasant Hegde <[email protected]> --- 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 ++++++ lsvpd.bug-941938_add_powerkvm_guest_detection2.patch ++++++ Index: lsvpd-1.7.5/src/include/devicetreecollector.hpp =================================================================== --- lsvpd-1.7.5.orig/src/include/devicetreecollector.hpp +++ lsvpd-1.7.5/src/include/devicetreecollector.hpp @@ -141,7 +141,7 @@ namespace lsvpd /* Check whether we are on Opal based system */ inline bool isPlatformOPAL() { - return (platForm == PF_POWERKVM_HOST); + return (platForm == PF_OPAL); } /** Index: lsvpd-1.7.5/src/include/platformcollector.hpp =================================================================== --- lsvpd-1.7.5.orig/src/include/platformcollector.hpp +++ lsvpd-1.7.5/src/include/platformcollector.hpp @@ -22,7 +22,7 @@ using namespace std; namespace lsvpd { - enum platform { PF_NULL, PF_POWERVM_LPAR, PF_POWERKVM_HOST , PF_POWERKVM_PSERIES_GUEST, PF_ERROR }; + enum platform { PF_NULL, PF_POWERVM_LPAR, PF_OPAL, PF_PSERIES_KVM_GUEST, PF_ERROR }; class PlatformCollector { public: Index: lsvpd-1.7.5/src/internal/sys_interface/platformcollector.cpp =================================================================== --- lsvpd-1.7.5.orig/src/internal/sys_interface/platformcollector.cpp +++ lsvpd-1.7.5/src/internal/sys_interface/platformcollector.cpp @@ -72,10 +72,10 @@ error: while (getline(ifs, buf)) { if (strstr(buf.c_str(), "PowerNV")) { - platform_type = PF_POWERKVM_HOST; + platform_type = PF_OPAL; break; } else if (strstr(buf.c_str(), "pSeries (emulated by qemu)")) { - platform_type = PF_POWERKVM_PSERIES_GUEST; + platform_type = PF_PSERIES_KVM_GUEST; break; } else if (strstr(buf.c_str(), "pSeries")) { platform_type = PF_POWERVM_LPAR; @@ -94,12 +94,12 @@ error: { get_platform(); switch(platform_type) { - case PF_POWERKVM_HOST: - return "PowerKVM Host"; + case PF_OPAL: + return "OPAL"; case PF_POWERVM_LPAR: return "PowerVM pSeries LPAR"; - case PF_POWERKVM_PSERIES_GUEST: - return "PowerKVM pSeries Guest"; + case PF_PSERIES_KVM_GUEST: + return "pSeries KVM Guest"; case PF_ERROR: return "Unknown"; } Index: lsvpd-1.7.5/src/internal/updater.cpp =================================================================== --- lsvpd-1.7.5.orig/src/internal/updater.cpp +++ lsvpd-1.7.5/src/internal/updater.cpp @@ -82,15 +82,16 @@ int main( int argc, char** argv ) bool done = false; string idNode; int index = 0; - int rc; + int rc = 1; bool limitSCSISize = false; string platform = PlatformCollector::get_platform_name(); switch (PlatformCollector::platform_type) { - case PF_POWERKVM_PSERIES_GUEST: + case PF_PSERIES_KVM_GUEST: + rc = 0; case PF_ERROR: cout<< "vpdupdate is not supported on the " << platform << endl; - return 1; + return rc; } struct option longOpts [] = Index: lsvpd-1.7.5/src/output/lscfg.cpp =================================================================== --- lsvpd-1.7.5.orig/src/output/lscfg.cpp +++ lsvpd-1.7.5/src/output/lscfg.cpp @@ -600,9 +600,47 @@ int initCPUModelList(const string& filen return 0; } +int getCPUModelNameFromList(System *root, string &name) +{ + vector<model_conv *>::iterator i, end; + + if (initCPUModelList(IBM_CPU_MODEL_LIST)) + return -ENOENT; + + i = cpu_models.begin(); + end = cpu_models.end(); + while (++i != end) { + if ((*i)->model_number == root->getMachineModel()) { + name = (*i)->model_name; + return 0; + } + } + + return -1; +} + +int OpalgetCPUModelName(System *root, string &name) +{ + FILE *fin; + char buf[512]; + + fin = fopen ("/proc/device-tree/model-name", "r"); + if (fin != NULL) { + if (fgets(buf, 512, fin) != NULL) { + name = string (buf); + fclose(fin); + return 0; + } + fclose(fin); + } + + return -1; +} + int getCPUModelName(System *root, string &name) { vector<model_conv *>::iterator i, end; + int platform = PlatformCollector::platform_type; if (root->getMachineModel().length() <= 0) { /* Likely on a non-Power system. Get CPU model info from /proc/cpuinfo */ @@ -616,18 +654,14 @@ int getCPUModelName(System *root, string return -1; } - if (initCPUModelList(IBM_CPU_MODEL_LIST)) - return -ENOENT; - - i = cpu_models.begin(); - end = cpu_models.end(); - while (++i != end) { - if ((*i)->model_number == root->getMachineModel()) { - name = (*i)->model_name; - return 0; - } - } - return -1; + /* + * On PowerNV platform we get model name in device tree. + * On pSeries we have to rely on static file. + */ + if (platform == PF_OPAL) + return OpalgetCPUModelName(root, name); + else + return getCPUModelNameFromList(root, name); } @@ -721,6 +755,7 @@ int main( int argc, char** argv ) System * root = NULL; VpdRetriever* vpd = NULL; int index; + int rc = 1; struct option longOpts [] = { @@ -738,11 +773,12 @@ int main( int argc, char** argv ) string platform = PlatformCollector::get_platform_name(); switch (PlatformCollector::platform_type) { - case PF_POWERKVM_PSERIES_GUEST: + case PF_PSERIES_KVM_GUEST: + rc = 0; case PF_ERROR: cout<< argv[0] << " is not supported on the " << platform << endl; - return 1; + return rc; } if (geteuid() != 0) { Index: lsvpd-1.7.5/src/output/lsmcode.cpp =================================================================== --- lsvpd-1.7.5.orig/src/output/lsmcode.cpp +++ lsvpd-1.7.5/src/output/lsmcode.cpp @@ -308,13 +308,16 @@ int main( int argc, char** argv ) System * root = NULL; VpdRetriever* vpd = NULL; int index; + int rc = 1; string platform = PlatformCollector::get_platform_name(); switch (PlatformCollector::platform_type) { - case PF_POWERKVM_PSERIES_GUEST: + case PF_PSERIES_KVM_GUEST: + rc = 0; + case PF_NULL: case PF_ERROR: cout<< "lsmcode is not supported on the " << platform << endl; - return 1; + return rc; } struct option longOpts [] = Index: lsvpd-1.7.5/src/output/lsvio.cpp =================================================================== --- lsvpd-1.7.5.orig/src/output/lsvio.cpp +++ lsvpd-1.7.5/src/output/lsvio.cpp @@ -214,15 +214,18 @@ int main( int argc, char** argv ) System * root = NULL; VpdRetriever* vpd = NULL; int index; + int rc = 1; string platform = PlatformCollector::get_platform_name(); switch (PlatformCollector::platform_type) { - case PF_POWERKVM_PSERIES_GUEST: - case PF_POWERKVM_HOST: + case PF_PSERIES_KVM_GUEST: + case PF_OPAL: + rc = 0; + case PF_NULL: case PF_ERROR: cout<< "lsvio is not supported on the " << platform << endl; - return 1; + return rc; } struct option longOpts [] = Index: lsvpd-1.7.5/src/output/lsvpd.cpp =================================================================== --- lsvpd-1.7.5.orig/src/output/lsvpd.cpp +++ lsvpd-1.7.5/src/output/lsvpd.cpp @@ -399,14 +399,16 @@ int main( int argc, char** argv ) System * root = NULL; VpdRetriever* vpd = NULL; int index; + int rc = 1; string platform = PlatformCollector::get_platform_name(); switch (PlatformCollector::platform_type) { - case PF_POWERKVM_PSERIES_GUEST: + case PF_PSERIES_KVM_GUEST: + rc = 0; case PF_ERROR: cout<< "lsvpd is not supported on the " << platform << " platform" << endl; - return 1; + return rc; } struct option longOpts [] =
