File lsvpd.bug-941938_add_powerkvm_guest_detection2.patch of Package lsvpd
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 [] =