170 lines
5.8 KiB
Diff
170 lines
5.8 KiB
Diff
From bce23ecc5d8bb6cab86843f7a42164ee44ef091f Mon Sep 17 00:00:00 2001
|
|
From: John Kacur <jkacur@redhat.com>
|
|
Date: Thu, 27 Oct 2022 11:14:27 -0400
|
|
Subject: [PATCH 3/3] rteval: Don't attempt to get DMIinfo if there are dmi
|
|
warnings
|
|
|
|
If the python module dmidecode is available, but produces warnings,
|
|
you can get a traceback. This happens on some arm boxes,
|
|
as shown in the traceback below.
|
|
|
|
Fix this by treating any warnings that are not listed in the
|
|
ignorable warnings as if dmi info is not available.
|
|
|
|
Also add logging to dmi.ProcessWarnings()
|
|
|
|
./rteval-cmd -d10s
|
|
** DMI WARNING ** /sys/firmware/efi/systab: SMBIOS entry point missing
|
|
got system topology: 1 node system (4 cores per node)
|
|
rteval run on 5.19.16-200.fc36.aarch64 started at Fri Oct 21 16:11:51 2022
|
|
started 3 loads on 4 cores
|
|
started measurement threads on 4 cores
|
|
Run duration: 10.0 seconds
|
|
stopping run at Fri Oct 21 16:13:26 2022
|
|
Traceback (most recent call last):
|
|
File "/root/src/rteval/./rteval-cmd", line 402, in <module>
|
|
ec = rteval.Measure()
|
|
File "/root/src/rteval/rteval/__init__.py", line 286, in Measure
|
|
self._report(measure_start, self.__rtevcfg.xslt_report)
|
|
File "/root/src/rteval/rteval/rtevalReport.py", line 76, in _report
|
|
self.__xmlreport.AppendXMLnodes(self._sysinfo.MakeReport())
|
|
File "/root/src/rteval/rteval/sysinfo/__init__.py", line 69, in MakeReport
|
|
report_n.addChild(dmi.DMIinfo.MakeReport(self))
|
|
File "/root/src/rteval/rteval/sysinfo/dmi.py", line 111, in MakeReport
|
|
dmiqry = xmlout.convert_libxml2_to_lxml_doc(self.__dmixml.QuerySection('all'))
|
|
File "/usr/lib64/python3.10/site-packages/dmidecode.py", line 64, in QuerySection
|
|
ret = libxml2.xmlDoc( _obj = xmlapi(query_type='s',
|
|
RuntimeError: [src/dmidecodemodule.c:331] Error decoding DMI data
|
|
|
|
** COLLECTED WARNINGS **
|
|
/sys/firmware/efi/systab: SMBIOS entry point missing
|
|
** END OF WARNINGS **
|
|
|
|
Signed-off-by: John Kacur <jkacur@redhat.com>
|
|
---
|
|
rteval-cmd | 4 ++--
|
|
rteval/sysinfo/__init__.py | 2 +-
|
|
rteval/sysinfo/dmi.py | 34 +++++++++++++++++++++-------------
|
|
3 files changed, 24 insertions(+), 16 deletions(-)
|
|
|
|
diff --git a/rteval-cmd b/rteval-cmd
|
|
index 6a928362828f..1e6a7fc86baa 100755
|
|
--- a/rteval-cmd
|
|
+++ b/rteval-cmd
|
|
@@ -210,8 +210,6 @@ def remove_offline(cpulist):
|
|
if __name__ == '__main__':
|
|
from rteval.sysinfo import dmi
|
|
|
|
- dmi.ProcessWarnings()
|
|
-
|
|
# set LD_BIND_NOW to resolve shared library symbols
|
|
# note: any string will do, nothing significant about 'rteval'
|
|
|
|
@@ -261,6 +259,8 @@ if __name__ == '__main__':
|
|
| (rtevcfg.debugging and Log.DEBUG)
|
|
logger.SetLogVerbosity(loglev)
|
|
|
|
+ dmi.ProcessWarnings(logger=logger)
|
|
+
|
|
# Load modules
|
|
loadmods = LoadModules(config, logger=logger)
|
|
measuremods = MeasurementModules(config, logger=logger)
|
|
diff --git a/rteval/sysinfo/__init__.py b/rteval/sysinfo/__init__.py
|
|
index bb1d00810856..5767e5b7f6fe 100644
|
|
--- a/rteval/sysinfo/__init__.py
|
|
+++ b/rteval/sysinfo/__init__.py
|
|
@@ -49,7 +49,7 @@ class SystemInfo(KernelInfo, SystemServices, dmi.DMIinfo, CPUtopology,
|
|
NetworkInfo.__init__(self, logger=logger)
|
|
|
|
# Parse initial DMI decoding errors
|
|
- dmi.ProcessWarnings()
|
|
+ dmi.ProcessWarnings(logger=logger)
|
|
|
|
# Parse CPU info
|
|
CPUtopology._parse(self)
|
|
diff --git a/rteval/sysinfo/dmi.py b/rteval/sysinfo/dmi.py
|
|
index 5965c128c093..83f347623b58 100644
|
|
--- a/rteval/sysinfo/dmi.py
|
|
+++ b/rteval/sysinfo/dmi.py
|
|
@@ -1,6 +1,7 @@
|
|
#
|
|
# Copyright 2009 - 2013 Clark Williams <williams@redhat.com>
|
|
# Copyright 2009 - 2013 David Sommerseth <davids@redhat.com>
|
|
+# Copyright 2022 John Kacur <jkacur@redhat.com>
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
@@ -34,14 +35,19 @@ from rteval import rtevalConfig
|
|
|
|
try:
|
|
import dmidecode
|
|
- dmidecode_loaded = True
|
|
+ dmidecode_avail = True
|
|
except ModuleNotFoundError:
|
|
- dmidecode_loaded = False
|
|
+ dmidecode_avail = False
|
|
|
|
-def ProcessWarnings():
|
|
+def set_dmidecode_avail(val):
|
|
+ """ Used to set global variable dmidecode_avail from a function """
|
|
+ global dmidecode_avail
|
|
+ dmidecode_avail = val
|
|
+
|
|
+def ProcessWarnings(logger=None):
|
|
""" Process Warnings from dmidecode """
|
|
|
|
- if not dmidecode_loaded:
|
|
+ if not dmidecode_avail:
|
|
return
|
|
|
|
if not hasattr(dmidecode, 'get_warnings'):
|
|
@@ -62,7 +68,8 @@ def ProcessWarnings():
|
|
|
|
# All other warnings will be printed
|
|
if len(warnline) > 0:
|
|
- print(f"** DMI WARNING ** {warnline}")
|
|
+ logger.log(Log.DEBUG, f"** DMI WARNING ** {warnline}")
|
|
+ set_dmidecode_avail(False)
|
|
|
|
dmidecode.clear_warnings()
|
|
|
|
@@ -70,11 +77,11 @@ def ProcessWarnings():
|
|
class DMIinfo:
|
|
'''class used to obtain DMI info via python-dmidecode'''
|
|
|
|
- def __init__(self, logger):
|
|
- self.__version = '0.5'
|
|
+ def __init__(self, logger=None):
|
|
+ self.__version = '0.6'
|
|
|
|
- if not dmidecode_loaded:
|
|
- logger.log(Log.DEBUG|Log.WARN, "No dmidecode module found, ignoring DMI tables")
|
|
+ if not dmidecode_avail:
|
|
+ logger.log(Log.DEBUG, "DMI info unavailable, ignoring DMI tables")
|
|
self.__fake = True
|
|
return
|
|
|
|
@@ -127,14 +134,15 @@ def unit_test(rootdir):
|
|
self.__dict__[k] = self.config[k]
|
|
|
|
try:
|
|
- ProcessWarnings()
|
|
+ log = Log()
|
|
+ log.SetLogVerbosity(Log.DEBUG|Log.INFO)
|
|
+
|
|
+ ProcessWarnings(logger=log)
|
|
if os.getuid() != 0:
|
|
print("** ERROR ** Must be root to run this unit_test()")
|
|
return 1
|
|
|
|
- log = Log()
|
|
- log.SetLogVerbosity(Log.DEBUG|Log.INFO)
|
|
- d = DMIinfo(log)
|
|
+ d = DMIinfo(logger=log)
|
|
dx = d.MakeReport()
|
|
x = libxml2.newDoc("1.0")
|
|
x.setRootElement(dx)
|
|
--
|
|
2.37.3
|
|
|