[PATCH] Moved the last CPU APIs out of Host and into Processor.
by Darryl L. Pierce
Now the model, count and number of cores come from the Processor agent.
Signed-off-by: Darryl L. Pierce <dpierce(a)redhat.com>
---
src/host.cpp | 24 ------------------------
src/host.h | 17 -----------------
src/processor.cpp | 36 ++++++++++++++++++++++++++++++++++++
src/processor.h | 8 +++++++-
src/qmf/hostagent.cpp | 4 ----
src/qmf/processoragent.cpp | 3 +++
src/schema-host.xml | 6 +++---
7 files changed, 49 insertions(+), 49 deletions(-)
diff --git a/src/host.cpp b/src/host.cpp
index cdf47e9..730529c 100644
--- a/src/host.cpp
+++ b/src/host.cpp
@@ -287,30 +287,6 @@ host_get_memory()
return memory;
}
-string
-host_get_cpu_model()
-{
- cpu_get_details();
-
- return cpuinfo.model;
-}
-
-unsigned int
-host_get_number_of_cpus()
-{
- cpu_get_details();
-
- return cpuinfo.cpus;
-}
-
-unsigned int
-host_get_number_of_cpu_cores()
-{
- cpu_get_details();
-
- return cpuinfo.cores;
-}
-
void
host_get_load_averages(double& one, double& five, double& fifteen)
{
diff --git a/src/host.h b/src/host.h
index e1dd02b..a680861 100644
--- a/src/host.h
+++ b/src/host.h
@@ -27,17 +27,6 @@
using namespace std;
-typedef struct cpuinfo_
-{
- static bool initialized;
- string model;
- unsigned int cpus;
- unsigned int cores;
- unsigned int wordsize;
-} cpuinfo_t;
-
-extern cpuinfo_t cpuinfo;
-
void host_register_listener(HostListener* listener);
void host_remove_istener(HostListener* listener);
@@ -56,12 +45,6 @@ string host_get_architecture();
unsigned int host_get_memory();
-string host_get_cpu_model();
-
-unsigned int host_get_number_of_cpus();
-
-unsigned int host_get_number_of_cpu_cores();
-
void host_get_load_averages(double& one, double& five, double& fifteen);
void host_identify(const unsigned int iterations);
diff --git a/src/processor.cpp b/src/processor.cpp
index bc72757..65de27e 100644
--- a/src/processor.cpp
+++ b/src/processor.cpp
@@ -24,6 +24,18 @@
#include <pcre.h>
#include "processor.h"
#include <stdexcept>
+#include <string>
+
+using namespace std;
+
+typedef struct cpuinfo_
+{
+ static bool initialized;
+ string model;
+ unsigned int cpus;
+ unsigned int cores;
+ unsigned int wordsize;
+} cpuinfo_t;
cpuinfo_t cpuinfo;
bool cpuinfo_t::initialized = false;
@@ -167,3 +179,27 @@ cpu_get_wordsize()
return wordsize;
}
+
+string
+cpu_get_model()
+{
+ cpu_get_details();
+
+ return cpuinfo.model;
+}
+
+unsigned int
+cpu_get_count()
+{
+ cpu_get_details();
+
+ return cpuinfo.cpus;
+}
+
+unsigned int
+cpu_get_number_of_cores()
+{
+ cpu_get_details();
+
+ return cpuinfo.cores;
+}
diff --git a/src/processor.h b/src/processor.h
index f56f177..7abd9b6 100644
--- a/src/processor.h
+++ b/src/processor.h
@@ -20,7 +20,13 @@
* also available at http://www.gnu.org/copyleft/gpl.html.
*/
-void cpu_get_details();
unsigned int cpu_get_wordsize();
+string cpu_get_model();
+
+unsigned int cpu_get_count();
+
+unsigned int cpu_get_number_of_cores();
+
+
#endif
diff --git a/src/qmf/hostagent.cpp b/src/qmf/hostagent.cpp
index c9c18f7..49bb40b 100644
--- a/src/qmf/hostagent.cpp
+++ b/src/qmf/hostagent.cpp
@@ -46,10 +46,6 @@ HostAgent::setup(ManagementAgent* agent)
_management_object->set_platform(host_get_platform());
_management_object->set_arch(host_get_architecture());
_management_object->set_memory(host_get_memory());
-
- _management_object->set_cpu_model(host_get_cpu_model());
- _management_object->set_cpu_count(host_get_number_of_cpus());
- _management_object->set_cpu_cores(host_get_number_of_cpu_cores());
}
Manageable::status_t
diff --git a/src/qmf/processoragent.cpp b/src/qmf/processoragent.cpp
index 7c0d6ec..67e0ac5 100644
--- a/src/qmf/processoragent.cpp
+++ b/src/qmf/processoragent.cpp
@@ -36,6 +36,9 @@ ProcessorAgent::setup(ManagementAgent* agent, HostAgent& parent)
_management_object->set_host(parent.GetManagementObject()->getObjectId());
_management_object->set_wordsize(cpu_get_wordsize());
+ _management_object->set_model(cpu_get_model());
+ _management_object->set_count(cpu_get_count());
+ _management_object->set_cores(cpu_get_number_of_cores());
}
ManagementObject*
diff --git a/src/schema-host.xml b/src/schema-host.xml
index 2c6e52e..b0895c6 100644
--- a/src/schema-host.xml
+++ b/src/schema-host.xml
@@ -10,9 +10,6 @@
<property name="arch" type="sstr" access="RO" desc="Architecture of host" />
<property name="hypervisor" type="sstr" access="RO" desc="Hypervisor used by host" />
<property name="platform" type="uint8" access="RO" desc="The wordsize for the host." />
- <property name="cpu_model" type="lstr" access="RO" desc="The process model description." />
- <property name="cpu_count" type="uint8" access="RO" desc="The number of physical CPUs." />
- <property name="cpu_cores" type="uint8" access="RO" desc="The total number of processor cores." />
<!-- statistics -->
<statistic name="last_updated" type="absTime" desc="The last time a heartbeat occurred." />
@@ -31,6 +28,9 @@
<!-- properties -->
<property name="host" type="objId" access="RO" desc="The host agent." />
<property name="wordsize" type="uint8" access="RO" desc="The wordsize for the processor." />
+ <property name="model" type="lstr" access="RO" desc="The process model description." />
+ <property name="count" type="uint8" access="RO" desc="The number of physical CPUs." />
+ <property name="cores" type="uint8" access="RO" desc="The total number of processor cores." />
</class>
<eventArguments>
--
1.7.2
13 years, 9 months
New CPU functionality and Host wordsize
by Darryl L. Pierce
The following patch set includes code to report the wordsize of the
system's processor, as reported by CPU flags. It also determines the
host's binary wordsize by checking the size of a memory address and
multiplying it by the size of a single byte.
13 years, 9 months