Add remote_boot_uuid to Context
This lets us track which boot a message came from and finally fix the
logger relying on ServerStatistics having all the required information
needed to build up the logfile header.
Change-Id: I17fc4c5718d5d69c7a1e154afdd83b1ccb388a8f
diff --git a/aos/uuid.cc b/aos/uuid.cc
index 71e688c..2e3290b 100644
--- a/aos/uuid.cc
+++ b/aos/uuid.cc
@@ -7,8 +7,12 @@
#include <random>
#include <string_view>
+#include "gflags/gflags.h"
#include "glog/logging.h"
+DEFINE_string(boot_uuid, "",
+ "If set, override the boot UUID to have this value instead.");
+
namespace aos {
namespace {
void ToHex(const uint8_t *val, char *result, size_t count) {
@@ -150,6 +154,10 @@
}
UUID UUID::BootUUID() {
+ if (!FLAGS_boot_uuid.empty()) {
+ return UUID::FromString(FLAGS_boot_uuid);
+ }
+
int fd = open("/proc/sys/kernel/random/boot_id", O_RDONLY);
PCHECK(fd != -1);