Hello OpenHPI developers!
We observe a possible problem in the function saHpiSensorThresholdsSet
(OpenHPI version 2.8.0).
The HPI spec (SAF_HPI_B.01.01) says that:
"Thresholds are required to be set progressively in-order, so that Upper
Critical >= Upper Major >= UpperMinor >= Lower Minor >= Lower Major >= Lower
Critical."
This requirement is verified if multiple thresholds are set with a single
call to saHpiSensorThresholdsSet.
However, if multiple calls to saHpiSensorThresholdsSet are issued, and each
call sets one specific threshold, this requirement is not verified. As a
result, with multiple calls, it is possible to set thresholds out of order,
so that, for example a lower threshold will be greater than an upper
threshold:
For a sensor that has the following thresholds:
Lower Minor Threshold -56.000
Lower Major Threshold -56.000
Lower Critical Threshold -56.000
Upper Minor Threshold 40.000
Upper Major Threshold 50.000
Upper Critical Threshold 65.000
We can use the following code to set just the Lower Minor Threshold:
memset( &thresholds, 0, sizeof(thresholds) );
thresholds.LowMinor.IsSupported = SAHPI_TRUE;
thresholds.LowMinor.Type = SAHPI_SENSOR_READING_TYPE_FLOAT64;
thresholds.LowMinor.Value.SensorFloat64 = 120.0;
saHpiSensorThresholdsSet( session, resId, sensor, &thresholds );
As a result we`ve got the following threshold values for this sensor:
Lower Minor Threshold 120.000
Lower Major Threshold -56.000
Lower Critical Threshold -56.000
Upper Minor Threshold 40.000
Upper Major Threshold 50.000
Upper Critical Threshold 65.000
Do you think this is an issue in OpenHPI that needs to be fixed?
If so, the only fix we can propose is to read the current values of
thresholds via saHpiThresholdsGet in every call to saHpiSensorThresholdsSet,
and then merge the new and old thresholds together and verify the order. The
proposed diff is attached. However we have some concerns about potential
performance implications of this change.
What say?
Thanks and regards,
Serge Zhukov
Project manager
Pigeon Point Systems
--- safhpi.c 2006-09-05 22:30:27.000000000 +0400
+++ safhpi.c.new 2007-04-06 17:28:06.000000000 +0400
@@ -1664,7 +1664,33 @@
return SA_ERR_HPI_NOT_PRESENT;
}
- rv = oh_valid_thresholds(SensorThresholds, rdr);
+ SaHpiSensorThresholdsT tmp;
+
+ rv = saHpiSensorThresholdsGet( SessionId, ResourceId, SensorNum, &tmp );
+
+ if (rv != SA_OK) {
+ dbg("Can't get sensor thresholds. Sensor %d, ResourceId %d,
Domain %d",
+ SensorNum, ResourceId, did);
+ oh_release_domain(d);
+ return rv;
+ }
+
+ /* Merging thresholds*/
+ if (tmp.UpCritical.IsSupported == SAHPI_TRUE &&
SensorThresholds->UpCritical.IsSupported == SAHPI_TRUE)
+ tmp.UpCritical.Value.SensorFloat64 =
SensorThresholds->UpCritical.Value.SensorFloat64;
+ if (tmp.UpMajor.IsSupported == SAHPI_TRUE &&
SensorThresholds->UpMajor.IsSupported == SAHPI_TRUE)
+ tmp.UpMajor.Value.SensorFloat64 =
SensorThresholds->UpMajor.Value.SensorFloat64;
+ if (tmp.UpMinor.IsSupported == SAHPI_TRUE &&
SensorThresholds->UpMinor.IsSupported == SAHPI_TRUE)
+ tmp.UpMinor.Value.SensorFloat64 =
SensorThresholds->UpMinor.Value.SensorFloat64;
+ if (tmp.LowCritical.IsSupported == SAHPI_TRUE &&
SensorThresholds->LowCritical.IsSupported == SAHPI_TRUE)
+ tmp.LowCritical.Value.SensorFloat64 =
SensorThresholds->LowCritical.Value.SensorFloat64;
+ if (tmp.LowMajor.IsSupported == SAHPI_TRUE &&
SensorThresholds->LowMajor.IsSupported == SAHPI_TRUE)
+ tmp.LowMajor.Value.SensorFloat64 =
SensorThresholds->LowMajor.Value.SensorFloat64;
+ if (tmp.LowMinor.IsSupported == SAHPI_TRUE &&
SensorThresholds->LowMinor.IsSupported == SAHPI_TRUE)
+ tmp.LowMinor.Value.SensorFloat64 =
SensorThresholds->LowMinor.Value.SensorFloat64;
+
+
+ rv = oh_valid_thresholds(&tmp, rdr);
if (rv != SA_OK) { /* Invalid sensor threshold */
dbg("Invalid sensor threshold.");
oh_release_domain(d);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Openhpi-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openhpi-devel