update_engine: Added more logging and debugging for rollback checking
To help troubleshoot issues similar to http://crbug.com/356975 I added
more logging in DBus methods of update_engine to trace various stages
of determining available boot partitions, etc.
Also added two more DBus methods - to get the suggested rollback
partition name (and switched CanRollback to use this method) and
the list of availavle kernel partitions along with the 'bootable'
flag for each.
Changed update_engine_client to show the name of avaiable rollback
partition with --can_rollback and also added --show_kernels to
output list of available kernel partitions and whether each partition
is bootable or not.
BUG=None
TEST=Unit tests pass
Change-Id: Ib7f92a6460c578953ea1ba9b23bd0669acb0e22f
Reviewed-on: https://chromium-review.googlesource.com/191949
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/dbus_service.cc b/dbus_service.cc
index 7235be1..03bc602 100644
--- a/dbus_service.cc
+++ b/dbus_service.cc
@@ -8,6 +8,7 @@
#include <string>
#include <base/logging.h>
+#include <base/strings/stringprintf.h>
#include <policy/device_policy.h>
#include "update_engine/clock_interface.h"
@@ -196,8 +197,33 @@
gboolean* out_can_rollback,
GError **error)
{
- LOG(INFO) << "Checking for a rollback partition.";
- *out_can_rollback = self->system_state_->update_attempter()->CanRollback();
+ bool can_rollback = self->system_state_->update_attempter()->CanRollback();
+ LOG(INFO) << "Checking for a rollback partition. Result: " << can_rollback;
+ *out_can_rollback = can_rollback;
+ return TRUE;
+}
+
+gboolean update_engine_service_get_rollback_partition(
+ UpdateEngineService* self,
+ gchar** out_rollback_partition_name,
+ GError **error) {
+ auto name = self->system_state_->update_attempter()->GetRollbackPartition();
+ LOG(INFO) << "Getting rollback partition name. Result: " << name;
+ *out_rollback_partition_name = g_strdup(name.c_str());
+ return TRUE;
+}
+
+gboolean update_engine_service_get_kernel_devices(UpdateEngineService* self,
+ gchar** out_kernel_devices,
+ GError **error) {
+ auto devices = self->system_state_->update_attempter()->GetKernelDevices();
+ std::string info;
+ for (auto&& device : devices) {
+ base::StringAppendF(&info, "%d:%s\n",
+ device.second ? 1 : 0, device.first.c_str());
+ }
+ LOG(INFO) << "Available kernel devices: " << info;
+ *out_kernel_devices = g_strdup(info.c_str());
return TRUE;
}