Use the config to control the kernel log monitor.
Bug: 123592422
Test: Ran aosp_cf_x86_phone-userdebug
Change-Id: I25fef943b930d41859431086877178d5b0dc484f
diff --git a/host/commands/launch/launch.cc b/host/commands/launch/launch.cc
index d48f91d..de4dd44 100644
--- a/host/commands/launch/launch.cc
+++ b/host/commands/launch/launch.cc
@@ -1,14 +1,21 @@
#include "host/commands/launch/launch.h"
+#include <glog/logging.h>
+
#include "common/libs/fs/shared_fd.h"
#include "common/libs/utils/size_utils.h"
#include "common/vsoc/shm/screen_layout.h"
+#include "host/commands/launch/launcher_defs.h"
#include "host/commands/launch/vsoc_shared_memory.h"
+using cvd::LauncherExitCodes;
+
+namespace {
cvd::SharedFD CreateIvServerUnixSocket(const std::string& path) {
return cvd::SharedFD::SocketLocalServer(path.c_str(), false, SOCK_STREAM,
0666);
}
+} // namespace
cvd::Command GetIvServerCommand(const vsoc::CuttlefishConfig& config) {
// Resize gralloc region
@@ -35,3 +42,24 @@
CreateIvServerUnixSocket(config.ivshmem_client_socket_path()));
return ivserver;
}
+
+// Build the kernel log monitor command. If boot_event_pipe is not NULL, a
+// subscription to boot events from the kernel log monitor will be created and
+// events will appear on *boot_events_pipe
+cvd::Command GetKernelLogMonitorCommand(const vsoc::CuttlefishConfig& config,
+ cvd::SharedFD* boot_events_pipe) {
+ auto log_name = config.kernel_log_socket_name();
+ auto server = cvd::SharedFD::SocketLocalServer(log_name.c_str(), false,
+ SOCK_STREAM, 0666);
+ cvd::Command kernel_log_monitor(config.kernel_log_monitor_binary());
+ kernel_log_monitor.AddParameter("-log_server_fd=", server);
+ if (boot_events_pipe) {
+ cvd::SharedFD pipe_write_end;
+ if (!cvd::SharedFD::Pipe(boot_events_pipe, &pipe_write_end)) {
+ LOG(ERROR) << "Unable to create boot events pipe: " << strerror(errno);
+ std::exit(LauncherExitCodes::kPipeIOError);
+ }
+ kernel_log_monitor.AddParameter("-subscriber_fd=", pipe_write_end);
+ }
+ return kernel_log_monitor;
+}
diff --git a/host/commands/launch/launch.h b/host/commands/launch/launch.h
index ffe79f1..a8b57fd 100644
--- a/host/commands/launch/launch.h
+++ b/host/commands/launch/launch.h
@@ -4,3 +4,5 @@
#include "host/libs/config/cuttlefish_config.h"
cvd::Command GetIvServerCommand(const vsoc::CuttlefishConfig& config);
+cvd::Command GetKernelLogMonitorCommand(const vsoc::CuttlefishConfig& config,
+ cvd::SharedFD* boot_events_pipe);
diff --git a/host/commands/launch/main.cc b/host/commands/launch/main.cc
index de196cb..9f07ffb 100644
--- a/host/commands/launch/main.cc
+++ b/host/commands/launch/main.cc
@@ -532,27 +532,6 @@
});
}
-// Build the kernel log monitor command. If boot_event_pipe is not NULL, a
-// subscription to boot events from the kernel log monitor will be created and
-// events will appear on *boot_events_pipe
-cvd::Command GetKernelLogMonitorCommand(const vsoc::CuttlefishConfig& config,
- cvd::SharedFD* boot_events_pipe) {
- auto log_name = config.kernel_log_socket_name();
- auto server = cvd::SharedFD::SocketLocalServer(log_name.c_str(), false,
- SOCK_STREAM, 0666);
- cvd::Command kernel_log_monitor(FLAGS_kernel_log_monitor_binary);
- kernel_log_monitor.AddParameter("-log_server_fd=", server);
- if (boot_events_pipe) {
- cvd::SharedFD pipe_write_end;
- if (!cvd::SharedFD::Pipe(boot_events_pipe, &pipe_write_end)) {
- LOG(ERROR) << "Unable to create boot events pipe: " << strerror(errno);
- std::exit(LauncherExitCodes::kPipeIOError);
- }
- kernel_log_monitor.AddParameter("-subscriber_fd=", pipe_write_end);
- }
- return kernel_log_monitor;
-}
-
void LaunchAdbConnectorIfEnabled(cvd::ProcessMonitor* process_monitor) {
if (AdbConnectorEnabled()) {
cvd::Command adb_connector(FLAGS_adb_connector_binary);
@@ -827,6 +806,7 @@
tmp_config_obj.set_qemu_binary(FLAGS_qemu_binary);
tmp_config_obj.set_ivserver_binary(FLAGS_ivserver_binary);
+ tmp_config_obj.set_kernel_log_monitor_binary(FLAGS_kernel_log_monitor_binary);
tmp_config_obj.set_hypervisor_uri(FLAGS_hypervisor_uri);
tmp_config_obj.set_log_xml(FLAGS_log_xml);
diff --git a/host/libs/config/cuttlefish_config.cpp b/host/libs/config/cuttlefish_config.cpp
index c802fe3..6903860 100644
--- a/host/libs/config/cuttlefish_config.cpp
+++ b/host/libs/config/cuttlefish_config.cpp
@@ -124,6 +124,7 @@
const char* kHypervisorUri = "hypervisor_uri";
const char* kQemuBinary = "qemu_binary";
const char* kIvServerBinary = "ivserver_binary";
+const char* kKernelLogMonitorBinary = "kernel_log_monitor_binary";
} // namespace
namespace vsoc {
@@ -558,6 +559,15 @@
(*dictionary_)[kIvServerBinary] = ivserver_binary;
}
+std::string CuttlefishConfig::kernel_log_monitor_binary() const {
+ return (*dictionary_)[kKernelLogMonitorBinary].asString();
+}
+
+void CuttlefishConfig::set_kernel_log_monitor_binary(
+ const std::string& kernel_log_monitor_binary) {
+ (*dictionary_)[kKernelLogMonitorBinary] = kernel_log_monitor_binary;
+}
+
// Creates the (initially empty) config object and populates it with values from
// the config file if the CUTTLEFISH_CONFIG_FILE env variable is present.
// Returns nullptr if there was an error loading from file
diff --git a/host/libs/config/cuttlefish_config.h b/host/libs/config/cuttlefish_config.h
index 9a68ca4..aba3116 100644
--- a/host/libs/config/cuttlefish_config.h
+++ b/host/libs/config/cuttlefish_config.h
@@ -217,6 +217,10 @@
void set_ivserver_binary(const std::string& ivserver_binary);
std::string ivserver_binary() const;
+ void set_kernel_log_monitor_binary(
+ const std::string& kernel_log_monitor_binary);
+ std::string kernel_log_monitor_binary() const;
+
private:
std::unique_ptr<Json::Value> dictionary_;