dbus-sdr: Reset last device ID to 0xff when writing done
Issue: when requests to write incorrect FRU data via "ipmitool fru 0
<binFile>" command, this request returns a fail result. Request to read
FRU information via "ipmitool fru print 0" and "busctl introspect
xyz.openbmc_project.FruDevice <FruPath>" commands:
- Expect result: FRU information from 2 of commands are old FRU data
- Actual result: FRU information from 2 of commnads are different.
+ "busctl introspect xyz.openbmc_project.FruDevice <FruPath>"
return old FRU data as expectation.
+ "ipmitool fru print 0" return new FRU data, this is incorrect
behavior.
Root cause: When the written data is incorrect data, it will not be
wrote to FRU device. But dbus-sdr stored FruCache as written data.
Therefore, when users request to read FRU information as written device
ID, dbus-sdr returns FruCache data without reads data via dbus method
(in this time, FruCache is including incorrect data).
Solution: Reset last device ID to 0xff when writing done.
Tested:
1. Request to read FRU information
ipmitool fru print 0
2. Request to write incorrect FRU data
ipmitool fru 0 write <binFile>
3. Request to read FRU information
ipmitool fru print 0
The result as step 1.
Signed-off-by: Thang Tran <thuutran@amperecomputing.com>
Change-Id: I5a55640d0f111a12965966588f9bbeab4aa286ba
diff --git a/dbus-sdr/storagecommands.cpp b/dbus-sdr/storagecommands.cpp
index 4910aae..33be2dd 100644
--- a/dbus-sdr/storagecommands.cpp
+++ b/dbus-sdr/storagecommands.cpp
@@ -133,6 +133,7 @@
{
return true;
}
+ lastDevId = 0xFF;
std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
sdbusplus::message::message writeFru = dbus->new_method_call(
fruDeviceServiceName, "/xyz/openbmc_project/FruDevice",