diff options
author | Peter Schiffer <pschiffe@redhat.com> | 2013-04-04 19:02:29 +0200 |
---|---|---|
committer | Peter Schiffer <pschiffe@redhat.com> | 2013-04-04 19:02:29 +0200 |
commit | 381f0c0a5cd98a48dc6d5a5e0b98443707d8ea81 (patch) | |
tree | bdad2e739aac00eb02e71dfe7d4074268c6f69a4 /src/hardware/LMI_ProcessorProvider.c | |
parent | c47c5c19c5857439db30e40d4a691f5b700adf5f (diff) | |
download | openlmi-providers-381f0c0a5cd98a48dc6d5a5e0b98443707d8ea81.tar.gz openlmi-providers-381f0c0a5cd98a48dc6d5a5e0b98443707d8ea81.tar.xz openlmi-providers-381f0c0a5cd98a48dc6d5a5e0b98443707d8ea81.zip |
Hardware: Added Processor Cache Memory Provider
New Providers:
* LMI_ProcessorCacheMemoryProvider
* LMI_AssociatedProcessorCacheMemoryProvider
Other Changes:
* Optimized usage of string constats
* Fixed wrong usage of pointers in dmidecode.c
* Filled unknown mandatory fields in providers with "Unknown" value
* Replaced hard coded numbers with LMI constants
* Minor optimization - don't gather data which won't be used
Diffstat (limited to 'src/hardware/LMI_ProcessorProvider.c')
-rw-r--r-- | src/hardware/LMI_ProcessorProvider.c | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/src/hardware/LMI_ProcessorProvider.c b/src/hardware/LMI_ProcessorProvider.c index c3b78e2..6280bbd 100644 --- a/src/hardware/LMI_ProcessorProvider.c +++ b/src/hardware/LMI_ProcessorProvider.c @@ -19,9 +19,11 @@ */ #include <konkret/konkret.h> -#include <sys/utsname.h> +#include <stdio.h> #include <string.h> +#include <sys/utsname.h> #include "LMI_Processor.h" +#include "LMI_Hardware.h" #include "globals.h" #include "dmidecode.h" #include "lscpu.h" @@ -72,10 +74,10 @@ static CMPIStatus LMI_ProcessorEnumInstances( CMPIUint32 current_speed = 0, max_speed = 0, external_clock = 0; unsigned i, j, cpus_nb = 0; char *other_family = NULL, *architecture = NULL, *cpu_name = NULL, - *stepping = NULL, *error_msg = NULL; + *stepping = NULL, *error_msg = NULL, *instance_id = NULL; struct utsname utsname_buf; - DmiProcessor *dmi_cpus; - unsigned dmi_cpus_nb; + DmiProcessor *dmi_cpus = NULL; + unsigned dmi_cpus_nb = 0; LscpuProcessor lscpu; CpuinfoProcessor proc_cpu; @@ -116,8 +118,8 @@ static CMPIStatus LMI_ProcessorEnumInstances( LMI_Processor_Set_SystemCreationClassName(&lmi_cpu, get_system_creation_class_name()); LMI_Processor_Set_SystemName(&lmi_cpu, get_system_name()); - LMI_Processor_Set_CreationClassName(&lmi_cpu, "LMI_Processor"); - LMI_Processor_Set_Caption(&lmi_cpu, "Processor"); + LMI_Processor_Set_CreationClassName(&lmi_cpu, ORGID "_" CPU_CLASS_NAME); + LMI_Processor_Set_Caption(&lmi_cpu, CPU_CLASS_NAME); LMI_Processor_Set_Description(&lmi_cpu, "This object represents one processor in system."); @@ -137,6 +139,12 @@ static CMPIStatus LMI_ProcessorEnumInstances( cpu_name = dmi_cpus[i].name; enabled_cores = dmi_cpus[i].enabled_cores; stepping = dmi_cpus[i].stepping; + if (asprintf(&instance_id, ORGID ":" CPU_CLASS_NAME ":%s", + dmi_cpus[i].id) < 0) { + instance_id = NULL; + error_msg = "Not enough available memory."; + goto done; + } LMI_Processor_Set_DeviceID(&lmi_cpu, dmi_cpus[i].id); LMI_Processor_Set_Family(&lmi_cpu, family); @@ -160,7 +168,8 @@ static CMPIStatus LMI_ProcessorEnumInstances( LMI_Processor_Set_Characteristics(&lmi_cpu, count, charact); LMI_Processor_Set_EnabledProcessorCharacteristics( - &lmi_cpu, count, 0); + &lmi_cpu, count, + LMI_Processor_EnabledProcessorCharacteristics_Unknown); count++; } } @@ -172,6 +181,12 @@ static CMPIStatus LMI_ProcessorEnumInstances( error_msg = "Not enough available memory."; goto done; } + if (asprintf(&instance_id, ORGID ":" CPU_CLASS_NAME ":%s", + cpu_id) < 0) { + instance_id = NULL; + error_msg = "Not enough available memory."; + goto done; + } LMI_Processor_Set_DeviceID(&lmi_cpu, cpu_id); free(cpu_id); cpu_id = NULL; @@ -187,18 +202,18 @@ static CMPIStatus LMI_ProcessorEnumInstances( stepping = lscpu.stepping; } + LMI_Processor_Set_InstanceID(&lmi_cpu, instance_id); LMI_Processor_Set_CPUStatus(&lmi_cpu, cpustatus); LMI_Processor_Set_EnabledState(&lmi_cpu, enabledstate); LMI_Processor_Set_NumberOfEnabledCores(&lmi_cpu, enabled_cores); - if (current_speed) { - LMI_Processor_Set_CurrentClockSpeed(&lmi_cpu, current_speed); - } - if (max_speed) { - LMI_Processor_Set_MaxClockSpeed(&lmi_cpu, max_speed); - } - if (external_clock) { - LMI_Processor_Set_ExternalBusClockSpeed(&lmi_cpu, external_clock); - } + LMI_Processor_Set_CurrentClockSpeed(&lmi_cpu, current_speed); + LMI_Processor_Set_MaxClockSpeed(&lmi_cpu, max_speed); + LMI_Processor_Set_ExternalBusClockSpeed(&lmi_cpu, external_clock); + LMI_Processor_Init_OperationalStatus(&lmi_cpu, 1); + LMI_Processor_Set_OperationalStatus(&lmi_cpu, 0, + LMI_Processor_OperationalStatus_Unknown); + LMI_Processor_Set_HealthState(&lmi_cpu, + LMI_Processor_HealthState_Unknown); if (cpu_name && strlen(cpu_name)) { LMI_Processor_Set_Name(&lmi_cpu, cpu_name); LMI_Processor_Set_UniqueID(&lmi_cpu, cpu_name); @@ -239,6 +254,10 @@ done: free(architecture); } architecture = NULL; + if (instance_id) { + free(instance_id); + } + instance_id = NULL; dmi_free_processors(&dmi_cpus, &dmi_cpus_nb); lscpu_free_processor(&lscpu); |