summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeter Schiffer <pschiffe@redhat.com>2013-03-26 15:35:34 +0100
committerPeter Schiffer <pschiffe@redhat.com>2013-03-26 15:35:34 +0100
commitc47c5c19c5857439db30e40d4a691f5b700adf5f (patch)
tree2cf25719bd0a4e87d56a51cf19cf7d509507a222 /src
parent338db1b89aa1276f5c57ba4f970df3c28bfb03ec (diff)
downloadopenlmi-providers-c47c5c19c5857439db30e40d4a691f5b700adf5f.tar.gz
openlmi-providers-c47c5c19c5857439db30e40d4a691f5b700adf5f.tar.xz
openlmi-providers-c47c5c19c5857439db30e40d4a691f5b700adf5f.zip
Hardware: added new providers
Providers added: * LMI_ProcessorCapabilitiesProvider * LMI_ProcessorElementCapabilitiesProvider
Diffstat (limited to 'src')
-rw-r--r--src/globals.h4
-rw-r--r--src/hardware/CMakeLists.txt2
-rw-r--r--src/hardware/LMI_Hardware.h26
-rw-r--r--src/hardware/LMI_ProcessorCapabilitiesProvider.c275
-rw-r--r--src/hardware/LMI_ProcessorElementCapabilitiesProvider.c328
-rw-r--r--src/hardware/LMI_ProcessorProvider.c10
-rw-r--r--src/hardware/dmidecode.c18
-rw-r--r--src/hardware/dmidecode.h2
-rw-r--r--src/hardware/lscpu.c11
-rw-r--r--src/hardware/lscpu.h1
10 files changed, 670 insertions, 7 deletions
diff --git a/src/globals.h b/src/globals.h
index 6cf272c..a1cb18c 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -34,4 +34,6 @@ void _debug(int level, const char *file, int line, const char *format, ...);
#define warn(...) _debug(WARN, __FILE__, __LINE__, __VA_ARGS__)
#define error(...) _debug(ERROR, __FILE__, __LINE__, __VA_ARGS__)
-#endif \ No newline at end of file
+#define ORGID "LMI"
+
+#endif
diff --git a/src/hardware/CMakeLists.txt b/src/hardware/CMakeLists.txt
index ebf79fb..352cebe 100644
--- a/src/hardware/CMakeLists.txt
+++ b/src/hardware/CMakeLists.txt
@@ -8,6 +8,8 @@ set(provider_SRCS
lscpu.c
cpuinfo.c
LMI_ProcessorProvider.c
+ LMI_ProcessorCapabilitiesProvider.c
+ LMI_ProcessorElementCapabilitiesProvider.c
)
konkretcmpi_generate(${MOF}
diff --git a/src/hardware/LMI_Hardware.h b/src/hardware/LMI_Hardware.h
new file mode 100644
index 0000000..e93f9fe
--- /dev/null
+++ b/src/hardware/LMI_Hardware.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2013 Red Hat, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Peter Schiffer <pschiffe@redhat.com>
+ */
+
+#ifndef LMI_HARDWARE_H_
+#define LMI_HARDWARE_H_
+
+#define CPU_CAP_CLASS_NAME "ProcessorCapabilities"
+
+#endif /* LMI_HARDWARE_H_ */
diff --git a/src/hardware/LMI_ProcessorCapabilitiesProvider.c b/src/hardware/LMI_ProcessorCapabilitiesProvider.c
new file mode 100644
index 0000000..c9f7e14
--- /dev/null
+++ b/src/hardware/LMI_ProcessorCapabilitiesProvider.c
@@ -0,0 +1,275 @@
+/*
+ * Copyright (C) 2013 Red Hat, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Peter Schiffer <pschiffe@redhat.com>
+ */
+
+#include <konkret/konkret.h>
+#include "LMI_ProcessorCapabilities.h"
+#include "LMI_Hardware.h"
+#include "globals.h"
+#include "dmidecode.h"
+#include "lscpu.h"
+
+static const CMPIBroker* _cb = NULL;
+
+static void LMI_ProcessorCapabilitiesInitialize()
+{
+}
+
+static CMPIStatus LMI_ProcessorCapabilitiesCleanup(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus LMI_ProcessorCapabilitiesEnumInstanceNames(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ return KDefaultEnumerateInstanceNames(
+ _cb, mi, cc, cr, cop);
+}
+
+static CMPIStatus LMI_ProcessorCapabilitiesEnumInstances(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ LMI_ProcessorCapabilities lmi_cpu_cap;
+ CMPIUint16 cores = 1, threads = 1;
+ const char *ns = KNameSpace(cop),
+ *element_name_string = "Capabilities of processor ";
+ char *error_msg = NULL, *instance_id = NULL, *element_name = NULL;
+ unsigned i, cpus_nb = 0;
+ DmiProcessor *dmi_cpus;
+ unsigned dmi_cpus_nb;
+ LscpuProcessor lscpu;
+
+ if (dmi_get_processors(&dmi_cpus, &dmi_cpus_nb) != 0 || dmi_cpus_nb < 1) {
+ dmi_free_processors(&dmi_cpus, &dmi_cpus_nb);
+ }
+
+ if (lscpu_get_processor(&lscpu) != 0) {
+ error_msg = "Unable to get processor information.";
+ goto done;
+ }
+
+ if (dmi_cpus_nb > 0) {
+ cpus_nb = dmi_cpus_nb;
+ } else if (lscpu.processors > 0) {
+ cpus_nb = lscpu.processors;
+ } else {
+ error_msg = "Unable to get processor information.";
+ goto done;
+ }
+
+ for (i = 0; i < cpus_nb; i++) {
+ LMI_ProcessorCapabilities_Init(&lmi_cpu_cap, _cb, ns);
+
+ /* do we have output from dmidecode program? */
+ if (dmi_cpus_nb > 0) {
+ if (asprintf(&instance_id, "%s:%s:%s", ORGID,
+ CPU_CAP_CLASS_NAME, dmi_cpus[i].id) < 0) {
+ instance_id = NULL;
+ error_msg = "Not enough available memory.";
+ goto done;
+ }
+
+ cores = dmi_cpus[i].cores;
+ threads = dmi_cpus[i].threads;
+
+ if (asprintf(&element_name, "%s%s",
+ element_name_string, dmi_cpus[i].id) < 0) {
+ element_name = NULL;
+ error_msg = "Not enough available memory.";
+ goto done;
+ }
+ } else {
+ if (asprintf(&instance_id, "%s:%s:%u", ORGID,
+ CPU_CAP_CLASS_NAME, i) < 0) {
+ instance_id = NULL;
+ error_msg = "Not enough available memory.";
+ goto done;
+ }
+
+ cores = lscpu.cores;
+ threads = lscpu.threads_per_core * lscpu.cores;
+
+ if (asprintf(&element_name, "%s%u",
+ element_name_string, i) < 0) {
+ element_name = NULL;
+ error_msg = "Not enough available memory.";
+ goto done;
+ }
+ }
+
+ LMI_ProcessorCapabilities_Set_InstanceID(&lmi_cpu_cap, instance_id);
+ LMI_ProcessorCapabilities_Set_NumberOfProcessorCores(&lmi_cpu_cap,
+ cores);
+ LMI_ProcessorCapabilities_Set_NumberOfHardwareThreads(&lmi_cpu_cap,
+ threads);
+ LMI_ProcessorCapabilities_Set_ElementNameEditSupported(&lmi_cpu_cap, 0);
+ LMI_ProcessorCapabilities_Set_Caption(&lmi_cpu_cap,
+ "Processor Capabilities");
+ LMI_ProcessorCapabilities_Set_Description(&lmi_cpu_cap,
+ "This object represents (mainly multi-core and multi-thread) capabilities of processor in system.");
+ LMI_ProcessorCapabilities_Set_ElementName(&lmi_cpu_cap, element_name);
+
+ KReturnInstance(cr, lmi_cpu_cap);
+
+ if (instance_id) {
+ free(instance_id);
+ }
+ instance_id = NULL;
+ if (element_name) {
+ free(element_name);
+ }
+ element_name = NULL;
+ }
+
+done:
+ if (instance_id) {
+ free(instance_id);
+ }
+ instance_id = NULL;
+ if (element_name) {
+ free(element_name);
+ }
+ element_name = NULL;
+
+ dmi_free_processors(&dmi_cpus, &dmi_cpus_nb);
+ lscpu_free_processor(&lscpu);
+
+ if (error_msg) {
+ KReturn2(_cb, ERR_FAILED, error_msg);
+ }
+
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus LMI_ProcessorCapabilitiesGetInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ return KDefaultGetInstance(
+ _cb, mi, cc, cr, cop, properties);
+}
+
+static CMPIStatus LMI_ProcessorCapabilitiesCreateInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const CMPIInstance* ci)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_ProcessorCapabilitiesModifyInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const CMPIInstance* ci,
+ const char** properties)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_ProcessorCapabilitiesDeleteInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_ProcessorCapabilitiesExecQuery(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* lang,
+ const char* query)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+CMInstanceMIStub(
+ LMI_ProcessorCapabilities,
+ LMI_ProcessorCapabilities,
+ _cb,
+ LMI_ProcessorCapabilitiesInitialize())
+
+static CMPIStatus LMI_ProcessorCapabilitiesMethodCleanup(
+ CMPIMethodMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus LMI_ProcessorCapabilitiesInvokeMethod(
+ CMPIMethodMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* meth,
+ const CMPIArgs* in,
+ CMPIArgs* out)
+{
+ return LMI_ProcessorCapabilities_DispatchMethod(
+ _cb, mi, cc, cr, cop, meth, in, out);
+}
+
+CMMethodMIStub(
+ LMI_ProcessorCapabilities,
+ LMI_ProcessorCapabilities,
+ _cb,
+ LMI_ProcessorCapabilitiesInitialize())
+
+KUint16 LMI_ProcessorCapabilities_CreateGoalSettings(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const LMI_ProcessorCapabilitiesRef* self,
+ const KStringA* TemplateGoalSettings,
+ KStringA* SupportedGoalSettings,
+ CMPIStatus* status)
+{
+ KUint16 result = KUINT16_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KONKRET_REGISTRATION(
+ "root/cimv2",
+ "LMI_ProcessorCapabilities",
+ "LMI_ProcessorCapabilities",
+ "instance method")
diff --git a/src/hardware/LMI_ProcessorElementCapabilitiesProvider.c b/src/hardware/LMI_ProcessorElementCapabilitiesProvider.c
new file mode 100644
index 0000000..a477717
--- /dev/null
+++ b/src/hardware/LMI_ProcessorElementCapabilitiesProvider.c
@@ -0,0 +1,328 @@
+/*
+ * Copyright (C) 2013 Red Hat, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Peter Schiffer <pschiffe@redhat.com>
+ */
+
+#include <konkret/konkret.h>
+#include "LMI_ProcessorElementCapabilities.h"
+#include "LMI_ProcessorCapabilities.h"
+#include "LMI_Processor.h"
+#include "LMI_Hardware.h"
+#include "globals.h"
+#include "dmidecode.h"
+#include "lscpu.h"
+
+static const CMPIBroker* _cb;
+
+static void LMI_ProcessorElementCapabilitiesInitialize()
+{
+}
+
+static CMPIStatus LMI_ProcessorElementCapabilitiesCleanup(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus LMI_ProcessorElementCapabilitiesEnumInstanceNames(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ return KDefaultEnumerateInstanceNames(
+ _cb, mi, cc, cr, cop);
+}
+
+static CMPIStatus LMI_ProcessorElementCapabilitiesEnumInstances(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ LMI_ProcessorElementCapabilities lmi_cpu_el_cap;
+ LMI_ProcessorCapabilitiesRef lmi_cpu_cap;
+ LMI_ProcessorRef lmi_cpu;
+ const char *ns = KNameSpace(cop);
+ char *error_msg = NULL, *instance_id = NULL;
+ unsigned i, cpus_nb = 0;
+ DmiProcessor *dmi_cpus;
+ unsigned dmi_cpus_nb;
+ LscpuProcessor lscpu;
+
+ if (dmi_get_processors(&dmi_cpus, &dmi_cpus_nb) != 0 || dmi_cpus_nb < 1) {
+ dmi_free_processors(&dmi_cpus, &dmi_cpus_nb);
+ }
+
+ if (lscpu_get_processor(&lscpu) != 0) {
+ error_msg = "Unable to get processor information.";
+ goto done;
+ }
+
+ if (dmi_cpus_nb > 0) {
+ cpus_nb = dmi_cpus_nb;
+ } else if (lscpu.processors > 0) {
+ cpus_nb = lscpu.processors;
+ } else {
+ error_msg = "Unable to get processor information.";
+ goto done;
+ }
+
+ for (i = 0; i < cpus_nb; i++) {
+ LMI_ProcessorElementCapabilities_Init(&lmi_cpu_el_cap, _cb, ns);
+
+ LMI_ProcessorRef_Init(&lmi_cpu, _cb, ns);
+ LMI_ProcessorRef_Set_SystemCreationClassName(&lmi_cpu,
+ get_system_creation_class_name());
+ LMI_ProcessorRef_Set_SystemName(&lmi_cpu, get_system_name());
+ LMI_ProcessorRef_Set_CreationClassName(&lmi_cpu, "LMI_Processor");
+
+ LMI_ProcessorCapabilitiesRef_Init(&lmi_cpu_cap, _cb, ns);
+
+ /* do we have output from dmidecode program? */
+ if (dmi_cpus_nb > 0) {
+ LMI_ProcessorRef_Set_DeviceID(&lmi_cpu, dmi_cpus[i].id);
+
+ if (asprintf(&instance_id, "%s:%s:%s", ORGID,
+ CPU_CAP_CLASS_NAME, dmi_cpus[i].id) < 0) {
+ instance_id = NULL;
+ error_msg = "Not enough available memory.";
+ goto done;
+ }
+ } else {
+ char *cpu_id;
+ if (asprintf(&cpu_id, "%u", i) < 0) {
+ cpu_id = NULL;
+ error_msg = "Not enough available memory.";
+ goto done;
+ }
+ LMI_ProcessorRef_Set_DeviceID(&lmi_cpu, cpu_id);
+ free(cpu_id);
+ cpu_id = NULL;
+
+ if (asprintf(&instance_id, "%s:%s:%u", ORGID,
+ CPU_CAP_CLASS_NAME, i) < 0) {
+ instance_id = NULL;
+ error_msg = "Not enough available memory.";
+ goto done;
+ }
+ }
+
+ LMI_ProcessorCapabilitiesRef_Set_InstanceID(&lmi_cpu_cap, instance_id);
+
+ LMI_ProcessorElementCapabilities_Set_ManagedElement(&lmi_cpu_el_cap,
+ &lmi_cpu);
+ LMI_ProcessorElementCapabilities_Set_Capabilities(&lmi_cpu_el_cap,
+ &lmi_cpu_cap);
+ LMI_ProcessorElementCapabilities_Init_Characteristics(
+ &lmi_cpu_el_cap, 1);
+ LMI_ProcessorElementCapabilities_Set_Characteristics(&lmi_cpu_el_cap,
+ 0, LMI_ProcessorElementCapabilities_Characteristics_Current);
+
+ KReturnInstance(cr, lmi_cpu_el_cap);
+
+ if (instance_id) {
+ free(instance_id);
+ }
+ instance_id = NULL;
+ }
+
+done:
+ if (instance_id) {
+ free(instance_id);
+ }
+ instance_id = NULL;
+
+ dmi_free_processors(&dmi_cpus, &dmi_cpus_nb);
+ lscpu_free_processor(&lscpu);
+
+ if (error_msg) {
+ KReturn2(_cb, ERR_FAILED, error_msg);
+ }
+
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus LMI_ProcessorElementCapabilitiesGetInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ return KDefaultGetInstance(
+ _cb, mi, cc, cr, cop, properties);
+}
+
+static CMPIStatus LMI_ProcessorElementCapabilitiesCreateInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const CMPIInstance* ci)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_ProcessorElementCapabilitiesModifyInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const CMPIInstance* ci,
+ const char**properties)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_ProcessorElementCapabilitiesDeleteInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_ProcessorElementCapabilitiesExecQuery(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* lang,
+ const char* query)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_ProcessorElementCapabilitiesAssociationCleanup(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus LMI_ProcessorElementCapabilitiesAssociators(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* resultClass,
+ const char* role,
+ const char* resultRole,
+ const char** properties)
+{
+ return KDefaultAssociators(
+ _cb,
+ mi,
+ cc,
+ cr,
+ cop,
+ LMI_ProcessorElementCapabilities_ClassName,
+ assocClass,
+ resultClass,
+ role,
+ resultRole,
+ properties);
+}
+
+static CMPIStatus LMI_ProcessorElementCapabilitiesAssociatorNames(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* resultClass,
+ const char* role,
+ const char* resultRole)
+{
+ return KDefaultAssociatorNames(
+ _cb,
+ mi,
+ cc,
+ cr,
+ cop,
+ LMI_ProcessorElementCapabilities_ClassName,
+ assocClass,
+ resultClass,
+ role,
+ resultRole);
+}
+
+static CMPIStatus LMI_ProcessorElementCapabilitiesReferences(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* role,
+ const char** properties)
+{
+ return KDefaultReferences(
+ _cb,
+ mi,
+ cc,
+ cr,
+ cop,
+ LMI_ProcessorElementCapabilities_ClassName,
+ assocClass,
+ role,
+ properties);
+}
+
+static CMPIStatus LMI_ProcessorElementCapabilitiesReferenceNames(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* role)
+{
+ return KDefaultReferenceNames(
+ _cb,
+ mi,
+ cc,
+ cr,
+ cop,
+ LMI_ProcessorElementCapabilities_ClassName,
+ assocClass,
+ role);
+}
+
+CMInstanceMIStub(
+ LMI_ProcessorElementCapabilities,
+ LMI_ProcessorElementCapabilities,
+ _cb,
+ LMI_ProcessorElementCapabilitiesInitialize())
+
+CMAssociationMIStub(
+ LMI_ProcessorElementCapabilities,
+ LMI_ProcessorElementCapabilities,
+ _cb,
+ LMI_ProcessorElementCapabilitiesInitialize())
+
+KONKRET_REGISTRATION(
+ "root/cimv2",
+ "LMI_ProcessorElementCapabilities",
+ "LMI_ProcessorElementCapabilities",
+ "instance association")
diff --git a/src/hardware/LMI_ProcessorProvider.c b/src/hardware/LMI_ProcessorProvider.c
index 8e92fdd..c3b78e2 100644
--- a/src/hardware/LMI_ProcessorProvider.c
+++ b/src/hardware/LMI_ProcessorProvider.c
@@ -71,8 +71,8 @@ static CMPIStatus LMI_ProcessorEnumInstances(
CMPIUint16 cpustatus, enabledstate, family, charact, enabled_cores;
CMPIUint32 current_speed = 0, max_speed = 0, external_clock = 0;
unsigned i, j, cpus_nb = 0;
- char *other_family = NULL, *architecture = NULL, *cpu_id = NULL,
- *cpu_name = NULL, *stepping = NULL, *error_msg = NULL;
+ char *other_family = NULL, *architecture = NULL, *cpu_name = NULL,
+ *stepping = NULL, *error_msg = NULL;
struct utsname utsname_buf;
DmiProcessor *dmi_cpus;
unsigned dmi_cpus_nb;
@@ -166,12 +166,12 @@ static CMPIStatus LMI_ProcessorEnumInstances(
}
}
} else {
- cpu_id = (char *)malloc(10 * sizeof(char));
- if (!cpu_id) {
+ char *cpu_id;
+ if (asprintf(&cpu_id, "%u", i) < 0) {
+ cpu_id = NULL;
error_msg = "Not enough available memory.";
goto done;
}
- snprintf(cpu_id, 10, "%u", i);
LMI_Processor_Set_DeviceID(&lmi_cpu, cpu_id);
free(cpu_id);
cpu_id = NULL;
diff --git a/src/hardware/dmidecode.c b/src/hardware/dmidecode.c
index 6a038fb..14e4ac9 100644
--- a/src/hardware/dmidecode.c
+++ b/src/hardware/dmidecode.c
@@ -34,7 +34,9 @@ void init_dmiprocessor_struct(DmiProcessor *cpu)
cpu->max_speed = 0;
cpu->external_clock = 0;
cpu->name = NULL;
+ cpu->cores = 1;
cpu->enabled_cores = 1;
+ cpu->threads = 1;
cpu->type = NULL;
cpu->stepping = NULL;
cpu->upgrade = NULL;
@@ -204,6 +206,14 @@ short dmi_get_processors(DmiProcessor **cpus, unsigned *cpus_nb)
buf = NULL;
continue;
}
+ /* Cores */
+ buf = copy_string_part_after_delim(buffer[i], "Core Count: ");
+ if (buf) {
+ sscanf(buf, "%u", &cpus[curr_cpu]->cores);
+ free(buf);
+ buf = NULL;
+ continue;
+ }
/* Enabled Cores */
buf = copy_string_part_after_delim(buffer[i], "Core Enabled: ");
if (buf) {
@@ -212,6 +222,14 @@ short dmi_get_processors(DmiProcessor **cpus, unsigned *cpus_nb)
buf = NULL;
continue;
}
+ /* Threads */
+ buf = copy_string_part_after_delim(buffer[i], "Thread Count: ");
+ if (buf) {
+ sscanf(buf, "%u", &cpus[curr_cpu]->threads);
+ free(buf);
+ buf = NULL;
+ continue;
+ }
/* CPU Type/Role */
buf = copy_string_part_after_delim(buffer[i], "Type: ");
if (buf) {
diff --git a/src/hardware/dmidecode.h b/src/hardware/dmidecode.h
index f7e76a9..9a8c6c8 100644
--- a/src/hardware/dmidecode.h
+++ b/src/hardware/dmidecode.h
@@ -37,7 +37,9 @@ typedef struct _DmiProcessor {
unsigned max_speed; /* Max Speed in MHz */
unsigned external_clock; /* External Clock Speed in MHz */
char *name; /* CPU name, version in dmidecode */
+ unsigned cores; /* Number of cores */
unsigned enabled_cores; /* Number of enabled cores */
+ unsigned threads; /* Number of threads */
char *type; /* CPU Type/Role */
char *stepping; /* Stepping (revision level within family) */
char *upgrade; /* CPU upgrade method - socket */
diff --git a/src/hardware/lscpu.c b/src/hardware/lscpu.c
index 124ed7b..d4546cb 100644
--- a/src/hardware/lscpu.c
+++ b/src/hardware/lscpu.c
@@ -29,7 +29,8 @@ void init_lscpuprocessor_struct(LscpuProcessor *cpu)
{
cpu->data_width = 0;
cpu->processors = 0;
- cpu->cores = 0;
+ cpu->cores = 1;
+ cpu->threads_per_core = 1;
cpu->stepping = NULL;
cpu->current_speed = 0;
}
@@ -88,6 +89,14 @@ short lscpu_get_processor(LscpuProcessor *cpu)
buf = NULL;
continue;
}
+ /* Threads per core */
+ buf = copy_string_part_after_delim(buffer[i], "Thread(s) per core:");
+ if (buf) {
+ sscanf(buf, "%u", &cpu->threads_per_core);
+ free(buf);
+ buf = NULL;
+ continue;
+ }
/* Cores per processor */
buf = copy_string_part_after_delim(buffer[i], "Core(s) per socket:");
if (buf) {
diff --git a/src/hardware/lscpu.h b/src/hardware/lscpu.h
index 892141e..5dc5bd5 100644
--- a/src/hardware/lscpu.h
+++ b/src/hardware/lscpu.h
@@ -33,6 +33,7 @@ typedef struct _LscpuProcessor {
unsigned data_width; /* Data width */
unsigned processors; /* Number of processors */
unsigned cores; /* Cores per processor */
+ unsigned threads_per_core; /* Threads per core */
char *stepping; /* Stepping */
unsigned current_speed; /* Current speed in MHz */
} LscpuProcessor;