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/update_engine_client.cc b/update_engine_client.cc
index d27f027..3ee2a2a 100644
--- a/update_engine_client.cc
+++ b/update_engine_client.cc
@@ -59,6 +59,8 @@
"Listen for status updates and print them to the screen.");
DEFINE_bool(prev_version, false,
"Show the previous OS version used before the update reboot.");
+DEFINE_bool(show_kernels, false, "Show the list of kernel patritions and "
+ "whether each of them is bootable or not");
namespace {
@@ -211,20 +213,40 @@
return true;
}
-bool CanRollback() {
+std::string GetRollbackPartition() {
DBusGProxy* proxy;
GError* error = NULL;
CHECK(GetProxy(&proxy));
- gboolean can_rollback = FALSE;
- gboolean rc = update_engine_client_can_rollback(proxy,
- &can_rollback,
- &error);
+ char* rollback_partition = nullptr;
+ gboolean rc = update_engine_client_get_rollback_partition(proxy,
+ &rollback_partition,
+ &error);
CHECK_EQ(rc, TRUE) << "Error while querying rollback partition availabilty: "
<< GetAndFreeGError(&error);
- return can_rollback;
+ std::string partition = rollback_partition;
+ g_free(rollback_partition);
+ return partition;
}
+
+std::string GetKernelDevices() {
+ DBusGProxy* proxy;
+ GError* error = nullptr;
+
+ CHECK(GetProxy(&proxy));
+
+ char* kernel_devices = nullptr;
+ gboolean rc = update_engine_client_get_kernel_devices(proxy,
+ &kernel_devices,
+ &error);
+ CHECK_EQ(rc, TRUE) << "Error while getting a list of kernel devices: "
+ << GetAndFreeGError(&error);
+ std::string devices = kernel_devices;
+ g_free(kernel_devices);
+ return devices;
+}
+
bool CheckForUpdates(const string& app_version, const string& omaha_url) {
DBusGProxy* proxy;
GError* error = NULL;
@@ -452,9 +474,13 @@
// Show the rollback availability.
if (FLAGS_can_rollback) {
- bool can_rollback = CanRollback();
- LOG(INFO) << "Rollback partition: "
- << (can_rollback ? "AVAILABLE" : "UNAVAILABLE");
+ std::string rollback_partition = GetRollbackPartition();
+ if (rollback_partition.empty())
+ rollback_partition = "UNAVAILABLE";
+ else
+ rollback_partition = "AVAILABLE: " + rollback_partition;
+
+ LOG(INFO) << "Rollback partition: " << rollback_partition;
}
// Show the current P2P enabled setting.
@@ -547,6 +573,11 @@
ShowPrevVersion();
}
+ if (FLAGS_show_kernels) {
+ LOG(INFO) << "Kernel partitions:\n"
+ << GetKernelDevices();
+ }
+
LOG(INFO) << "Done.";
return 0;
}