dbus_handler: Get previous data when not rebooting
The reboot data will be store as "previous" reboot data once the current
reboot process is done.
So for the object that is not rebooting, `getCheckpointList` and
`getAdditionalDurations` function should return previous reboot data
since current reboot data will be empty.
Tested:
```
\# Before
bmc:~# busctl --verbose call \
com.google.gbmc.boot_time_monitor \
/xyz/openbmc_project/time/boot/bmc \
xyz.openbmc_project.Time.Boot.Duration \
GetAdditionalDurations
MESSAGE "a(sx)" {
ARRAY "(sx)" {
};
};
\#After
bmc:~# busctl --verbose call \
com.google.gbmc.boot_time_monitor \
/xyz/openbmc_project/time/boot/bmc \
xyz.openbmc_project.Time.Boot.Duration \
GetAdditionalDurations
MESSAGE "a(sx)" {
ARRAY "(sx)" {
STRUCT "sx" {
STRING "Firmware";
INT64 0;
};
STRUCT "sx" {
STRING "Loader";
INT64 0;
};
STRUCT "sx" {
STRING "Kernel";
INT64 6125;
};
STRUCT "sx" {
STRING "InitRD";
INT64 0;
};
STRUCT "sx" {
STRING "Userspace";
INT64 371105;
};
};
};
```
Google-Bug-Id: 296530445
Change-Id: I753c49fab562ac7b8d10df55b1be6741a3dac921
Signed-off-by: Michael Shen <gpgpgp@google.com>
diff --git a/src/dbus_handler.cpp b/src/dbus_handler.cpp
index 8dcf281..5927cb1 100644
--- a/src/dbus_handler.cpp
+++ b/src/dbus_handler.cpp
@@ -42,7 +42,9 @@
DbusHandler::getCheckpointList()
{
std::vector<std::tuple<std::string, int64_t, int64_t>> result;
- for (const auto& cp : bm->getCheckpoints())
+
+ for (const auto& cp :
+ (bm->isRebooting() ? bm->getCheckpoints() : bm->getPreCheckpoints()))
{
result.emplace_back(std::make_tuple(cp.name, cp.wallTime, cp.monoTime));
}
@@ -76,7 +78,9 @@
DbusHandler::getAdditionalDurations()
{
std::vector<std::tuple<std::string, int64_t>> result;
- for (const auto& dur : bm->getDurations())
+
+ for (const auto& dur :
+ (bm->isRebooting() ? bm->getDurations() : bm->getPreDurations()))
{
result.emplace_back(std::make_tuple(dur.name, dur.duration));
}