rteval: Don't attempt to get DMIinfo if there are dmi warnings
PATCH 1/1 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 **
--- rteval-cmd | 4 ++-- rteval/sysinfo/__init__.py | 2 +- rteval/sysinfo/dmi.py | 34 +++++++++++++++++++++------------- 3 files changed, 24 insertions(+), 16 deletions(-)
rteval-cmd +2 -2
@@ -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)
rteval/sysinfo/__init__.py +1 -1
@@ -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)
rteval/sysinfo/dmi.py +21 -13
@@ -1,6 +1,7 @@ # # Copyright 2009 - 2013 Clark Williams <[email protected]> # Copyright 2009 - 2013 David Sommerseth <[email protected]> +# Copyright 2022 John Kacur <[email protected]> # # 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)
Signature · 1 line
2.37.3