summaryrefslogtreecommitdiffstats
path: root/src/hardware/dmidecode.c
diff options
context:
space:
mode:
authorPeter Schiffer <pschiffe@redhat.com>2013-05-07 19:49:41 +0200
committerPeter Schiffer <pschiffe@redhat.com>2013-05-07 19:49:41 +0200
commit1c3bd366f82d4f53c76b89f8fff9359356781622 (patch)
tree2f7dbc5d915daf47391af01abd43f5c87b775c87 /src/hardware/dmidecode.c
parent7f5607358182d779cf5d3355d4f8d0e3a3f8e607 (diff)
downloadopenlmi-providers-1c3bd366f82d4f53c76b89f8fff9359356781622.tar.gz
openlmi-providers-1c3bd366f82d4f53c76b89f8fff9359356781622.tar.xz
openlmi-providers-1c3bd366f82d4f53c76b89f8fff9359356781622.zip
Hardware: Better support for multi CPU systems and kvm guests.
Changes: * Fixed problem when CPU ID from dmidecode is not unique * Use cache info from sysfs if dmi cpu info is available, but not dmi cache * When using sysfs cache, create all caches for every CPU * Fixed physical memory tag when serial number field is missing in dmidecode output * Tiny clean-up Hardware provider was tested in kvm guest with pegasus and this patch is result of the test. Now, thanks to the all fallback options, hardware provider works fine in this environment with and without selinux enabled.
Diffstat (limited to 'src/hardware/dmidecode.c')
-rw-r--r--src/hardware/dmidecode.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/hardware/dmidecode.c b/src/hardware/dmidecode.c
index dfff7e3..b3d00ef 100644
--- a/src/hardware/dmidecode.c
+++ b/src/hardware/dmidecode.c
@@ -203,7 +203,13 @@ short dmi_get_processors(DmiProcessor **cpus, unsigned *cpus_nb)
/* ID */
buf = copy_string_part_after_delim(buffer[i], "ID: ");
if (buf) {
- (*cpus)[curr_cpu].id = buf;
+ char curr_cpu_str[LONG_INT_LEN];
+ snprintf(curr_cpu_str, LONG_INT_LEN, "-%u", curr_cpu);
+ (*cpus)[curr_cpu].id = append_str(buf, curr_cpu_str, NULL);
+ if (!(*cpus)[curr_cpu].id) {
+ ret = -8;
+ goto done;
+ }
buf = NULL;
continue;
}
@@ -745,30 +751,43 @@ short check_dmi_memory_attributes(DmiMemory *memory)
for (i = 0; i < memory->modules_nb; i++) {
if (!memory->modules[i].serial_number) {
- if (!(memory->modules[i].serial_number = strdup(""))) {
+ if (asprintf(&memory->modules[i].serial_number, "%u", i) < 0) {
+ memory->modules[i].serial_number = NULL;
ret = -2;
goto done;
}
+ }
+ if (!memory->modules[i].form_factor) {
if (!(memory->modules[i].form_factor = strdup("Unknown"))) {
ret = -3;
goto done;
}
+ }
+ if (!memory->modules[i].type) {
if (!(memory->modules[i].type = strdup("Unknown"))) {
ret = -4;
goto done;
}
+ }
+ if (!memory->modules[i].bank_label) {
if (!(memory->modules[i].bank_label = strdup(""))) {
ret = -5;
goto done;
}
+ }
+ if (!memory->modules[i].name) {
if (!(memory->modules[i].name = strdup("Memory Module"))) {
ret = -6;
goto done;
}
+ }
+ if (!memory->modules[i].manufacturer) {
if (!(memory->modules[i].manufacturer = strdup(""))) {
ret = -7;
goto done;
}
+ }
+ if (!memory->modules[i].part_number) {
if (!(memory->modules[i].part_number = strdup(""))) {
ret = -8;
goto done;