Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cf_cc_binary(
deps = [
"//cuttlefish/common/libs/fs",
"//cuttlefish/host/commands/kernel_log_monitor:kernel_log_monitor_utils",
"//cuttlefish/host/libs/config:config_instance_derived",
"//cuttlefish/host/libs/config:cuttlefish_config",
"//cuttlefish/host/libs/config:logging",
"//cuttlefish/posix:strerror",
Expand Down
5 changes: 3 additions & 2 deletions base/cvd/cuttlefish/host/commands/console_forwarder/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include "cuttlefish/common/libs/fs/shared_fd.h"
#include "cuttlefish/common/libs/fs/shared_select.h"
#include "cuttlefish/host/libs/config/config_instance_derived.h"
#include "cuttlefish/host/libs/config/cuttlefish_config.h"
#include "cuttlefish/host/libs/config/logging.h"
#include "cuttlefish/posix/strerror.h"
Expand Down Expand Up @@ -239,8 +240,8 @@ int ConsoleForwarderMain(int argc, char** argv) {
auto console_log = instance.PerInstancePath("console_log");
auto console_log_fd =
SharedFD::Open(console_log.c_str(), O_CREAT | O_APPEND | O_WRONLY, 0666);
auto kernel_log_fd = SharedFD::Open(instance.kernel_log_pipe_name(),
O_APPEND | O_WRONLY, 0666);
SharedFD kernel_log_fd =
SharedFD::Open(KernelLogPipeName(instance), O_APPEND | O_WRONLY, 0666);
ConsoleForwarder console_forwarder(console_path, console_in, console_out,
console_log_fd, kernel_log_fd);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ cf_cc_binary(
deps = [
":kernel_log_monitor_utils",
"//cuttlefish/common/libs/fs",
"//cuttlefish/host/libs/config:config_instance_derived",
"//cuttlefish/host/libs/config:cuttlefish_config",
"//cuttlefish/host/libs/config:logging",
"//cuttlefish/result",
Expand Down
9 changes: 5 additions & 4 deletions base/cvd/cuttlefish/host/commands/kernel_log_monitor/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@

#include "cuttlefish/common/libs/fs/shared_fd.h"
#include "cuttlefish/common/libs/fs/shared_select.h"
#include "cuttlefish/host/libs/config/cuttlefish_config.h"
#include "cuttlefish/host/libs/config/logging.h"
#include "cuttlefish/host/commands/kernel_log_monitor/kernel_log_server.h"
#include "cuttlefish/host/commands/kernel_log_monitor/utils.h"
#include "cuttlefish/host/libs/config/config_instance_derived.h"
#include "cuttlefish/host/libs/config/cuttlefish_config.h"
#include "cuttlefish/host/libs/config/logging.h"

DEFINE_int32(log_pipe_fd, -1,
"A file descriptor representing a (UNIX) socket from which to "
Expand Down Expand Up @@ -89,8 +90,8 @@ int KernelLogMonitorMain(int argc, char** argv) {

SharedFD pipe;
if (FLAGS_log_pipe_fd < 0) {
auto log_name = instance.kernel_log_pipe_name();
pipe = SharedFD::Open(log_name.c_str(), O_RDONLY);
std::string log_name = KernelLogPipeName(instance);
pipe = SharedFD::Open(log_name, O_RDONLY);
} else {
pipe = SharedFD::Dup(FLAGS_log_pipe_fd);
close(FLAGS_log_pipe_fd);
Expand Down
2 changes: 2 additions & 0 deletions base/cvd/cuttlefish/host/commands/run_cvd/launch/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ cf_cc_library(
deps = [
"//cuttlefish/common/libs/fs",
"//cuttlefish/common/libs/utils:subprocess",
"//cuttlefish/host/libs/config:config_instance_derived",
"//cuttlefish/host/libs/config:cuttlefish_config",
"//cuttlefish/host/libs/config:known_paths",
"//cuttlefish/host/libs/feature",
Expand Down Expand Up @@ -174,6 +175,7 @@ cf_cc_library(
deps = [
"//cuttlefish/common/libs/utils:subprocess",
"//cuttlefish/host/commands/run_cvd:reporting",
"//cuttlefish/host/libs/config:config_instance_derived",
"//cuttlefish/host/libs/config:cuttlefish_config",
"//cuttlefish/host/libs/config:known_paths",
"//cuttlefish/host/libs/config:logging",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "cuttlefish/common/libs/fs/shared_fd.h"
#include "cuttlefish/common/libs/utils/subprocess.h"
#include "cuttlefish/host/libs/config/config_instance_derived.h"
#include "cuttlefish/host/libs/config/cuttlefish_config.h"
#include "cuttlefish/host/libs/config/known_paths.h"
#include "cuttlefish/host/libs/feature/command_source.h"
Expand All @@ -42,15 +43,12 @@ Result<std::optional<MonitorCommand>> ConsoleForwarder(
}
// These fds will only be read from or written to, but open them with
// read and write access to keep them open in case the subprocesses exit
auto console_in_pipe_name = instance.console_in_pipe_name();
auto console_forwarder_in_wr =
CF_EXPECT(SharedFD::Fifo(console_in_pipe_name, 0600));
SharedFD console_forwarder_in_wr =
CF_EXPECT(SharedFD::Fifo(ConsoleInPipeName(instance), 0600));

auto console_out_pipe_name = instance.console_out_pipe_name();
auto console_forwarder_out_rd =
CF_EXPECT(SharedFD::Fifo(console_out_pipe_name, 0600));
SharedFD console_forwarder_out_rd =
CF_EXPECT(SharedFD::Fifo(ConsoleOutPipeName(instance), 0600));

Command console_forwarder_cmd(ConsoleForwarderBinary());
return Command(ConsoleForwarderBinary())
.AddParameter("--console_in_fd=", console_forwarder_in_wr)
.AddParameter("--console_out_fd=", console_forwarder_out_rd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include "cuttlefish/common/libs/utils/subprocess.h"
#include "cuttlefish/host/commands/run_cvd/reporting.h"
#include "cuttlefish/host/libs/config/config_instance_derived.h"
#include "cuttlefish/host/libs/config/cuttlefish_config.h"
#include "cuttlefish/host/libs/config/known_paths.h"
#include "cuttlefish/host/libs/feature/command_source.h"
Expand Down Expand Up @@ -99,7 +100,7 @@ class KernelLogMonitor : public CommandSource,
private:
std::unordered_set<SetupFeature*> Dependencies() const override { return {}; }
Result<void> ResultSetup() override {
auto log_name = instance_.kernel_log_pipe_name();
std::string log_name = KernelLogPipeName(instance_);
// Open the pipe here (from the launcher) to ensure the pipe is not deleted
// due to the usage counters in the kernel reaching zero. If this is not
// done and the kernel_log_monitor crashes for some reason the VMM may get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@ void ServerLoopImpl::HandleActionWithNoData(const LauncherAction action,
void ServerLoopImpl::DeleteFifos() {
// TODO(schuffelen): Create these FIFOs in assemble_cvd instead of run_cvd.
std::vector<std::string> pipes = {
instance_.kernel_log_pipe_name(),
instance_.console_in_pipe_name(),
instance_.console_out_pipe_name(),
KernelLogPipeName(instance_),
ConsoleInPipeName(instance_),
ConsoleOutPipeName(instance_),
LogcatPipeName(instance_),
instance_.PerInstanceInternalPath("keymaster_fifo_vm.in"),
instance_.PerInstanceInternalPath("keymaster_fifo_vm.out"),
Expand Down
16 changes: 16 additions & 0 deletions base/cvd/cuttlefish/host/libs/config/config_instance_derived.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ std::string AccessKregistryPath(const CuttlefishConfig::InstanceSpecific& ins) {
return AbsolutePath(ins.PerInstancePath("access-kregistry"));
}

std::string ConsoleInPipeName(const CuttlefishConfig::InstanceSpecific& ins) {
return ConsolePipePrefix(ins) + ".in";
}

std::string ConsoleOutPipeName(const CuttlefishConfig::InstanceSpecific& ins) {
return ConsolePipePrefix(ins) + ".out";
}

std::string ConsolePipePrefix(const CuttlefishConfig::InstanceSpecific& ins) {
return AbsolutePath(ins.PerInstanceInternalPath("console"));
}

std::string KernelLogPipeName(const CuttlefishConfig::InstanceSpecific& ins) {
return AbsolutePath(ins.PerInstanceInternalPath("kernel-log-pipe"));
}

std::string LogcatPipeName(const CuttlefishConfig::InstanceSpecific& ins) {
return AbsolutePath(ins.PerInstanceInternalPath("logcat-pipe"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
namespace cuttlefish {

std::string AccessKregistryPath(const CuttlefishConfig::InstanceSpecific&);
std::string ConsoleInPipeName(const CuttlefishConfig::InstanceSpecific&);
std::string ConsoleOutPipeName(const CuttlefishConfig::InstanceSpecific&);
std::string ConsolePipePrefix(const CuttlefishConfig::InstanceSpecific&);
std::string KernelLogPipeName(const CuttlefishConfig::InstanceSpecific& ins);
std::string LogcatPipeName(const CuttlefishConfig::InstanceSpecific&);
std::string RestoreAdbdPipeName(const CuttlefishConfig::InstanceSpecific&);

Expand Down
10 changes: 0 additions & 10 deletions base/cvd/cuttlefish/host/libs/config/cuttlefish_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,16 +363,6 @@ class CuttlefishConfig {

std::string logcat_path() const;

std::string kernel_log_pipe_name() const;

std::string console_pipe_prefix() const;
std::string console_in_pipe_name() const;
std::string console_out_pipe_name() const;

std::string gnss_pipe_prefix() const;
std::string gnss_in_pipe_name() const;
std::string gnss_out_pipe_name() const;

std::string launcher_log_path() const;

std::string launcher_monitor_socket_path() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,34 +478,6 @@ void CuttlefishConfig::MutableInstanceSpecific::set_external_network_mode(
(*Dictionary())[kExternalNetworkMode] = fmt::format("{}", mode);
}

std::string CuttlefishConfig::InstanceSpecific::kernel_log_pipe_name() const {
return AbsolutePath(PerInstanceInternalPath("kernel-log-pipe"));
}

std::string CuttlefishConfig::InstanceSpecific::console_pipe_prefix() const {
return AbsolutePath(PerInstanceInternalPath("console"));
}

std::string CuttlefishConfig::InstanceSpecific::console_in_pipe_name() const {
return console_pipe_prefix() + ".in";
}

std::string CuttlefishConfig::InstanceSpecific::console_out_pipe_name() const {
return console_pipe_prefix() + ".out";
}

std::string CuttlefishConfig::InstanceSpecific::gnss_pipe_prefix() const {
return AbsolutePath(PerInstanceInternalPath("gnss"));
}

std::string CuttlefishConfig::InstanceSpecific::gnss_in_pipe_name() const {
return gnss_pipe_prefix() + ".in";
}

std::string CuttlefishConfig::InstanceSpecific::gnss_out_pipe_name() const {
return gnss_pipe_prefix() + ".out";
}

static constexpr char kGnssGrpcProxyServerPort[] =
"gnss_grpc_proxy_server_port";
int CuttlefishConfig::InstanceSpecific::gnss_grpc_proxy_server_port() const {
Expand Down
12 changes: 6 additions & 6 deletions base/cvd/cuttlefish/host/libs/vm_manager/crosvm_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ Result<std::vector<MonitorCommand>> CrosvmManager::StartCommands(
// kernel log event features working. If an alternative "earlycon" boot
// console is configured below on a legacy serial port, it will control
// the main log until the virtio-console takes over.
crosvm_cmd.AddHvcReadOnly(instance.kernel_log_pipe_name(),
crosvm_cmd.AddHvcReadOnly(KernelLogPipeName(instance),
instance.enable_kernel_log());

// /dev/hvc1 = serial console
Expand All @@ -757,8 +757,8 @@ Result<std::vector<MonitorCommand>> CrosvmManager::StartCommands(
// only the serial port output is received by the console forwarder as
// crosvm may print other messages to stdout.
if (instance.kgdb() || instance.use_bootloader()) {
crosvm_cmd.AddSerialConsoleReadWrite(instance.console_out_pipe_name(),
instance.console_in_pipe_name(),
crosvm_cmd.AddSerialConsoleReadWrite(ConsoleOutPipeName(instance),
ConsoleInPipeName(instance),
instance.enable_kernel_log());
// In kgdb mode, we have the interactive console on ttyS0 (both Android's
// console and kdb), so we can disable the virtio-console port usually
Expand All @@ -768,8 +768,8 @@ Result<std::vector<MonitorCommand>> CrosvmManager::StartCommands(
crosvm_cmd.AddHvcSink();
} else {
crosvm_cmd.AddSerialSink();
crosvm_cmd.AddHvcReadWrite(instance.console_out_pipe_name(),
instance.console_in_pipe_name());
crosvm_cmd.AddHvcReadWrite(ConsoleOutPipeName(instance),
ConsoleInPipeName(instance));
}
} else {
// Use an 8250 UART (ISA or platform device) for earlycon, as the
Expand All @@ -778,7 +778,7 @@ Result<std::vector<MonitorCommand>> CrosvmManager::StartCommands(
// dmesg will go there instead of the kernel.log
if (instance.enable_kernel_log() &&
(instance.kgdb() || instance.use_bootloader())) {
crosvm_cmd.AddSerialConsoleReadOnly(instance.kernel_log_pipe_name());
crosvm_cmd.AddSerialConsoleReadOnly(KernelLogPipeName(instance));
}

// as above, create a fake virtio-console 'sink' port when the serial
Expand Down
8 changes: 4 additions & 4 deletions base/cvd/cuttlefish/host/libs/vm_manager/qemu_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ Result<std::vector<MonitorCommand>> QemuManager::StartCommands(
// flags appear in the right order and "append=on" does the right thing
if (instance.enable_kernel_log() &&
(instance.kgdb() || instance.use_bootloader())) {
add_serial_console_ro(instance.kernel_log_pipe_name());
add_serial_console_ro(KernelLogPipeName(instance));
}
}

Expand All @@ -534,12 +534,12 @@ Result<std::vector<MonitorCommand>> QemuManager::StartCommands(
// (Note that QEMU does not automatically generate console= parameters for
// the bootloader/kernel cmdline, so the control of whether this pipe is
// actually managed by the kernel as a console is handled elsewhere.)
add_hvc_ro(instance.kernel_log_pipe_name());
add_hvc_ro(KernelLogPipeName(instance));

// /dev/hvc1 = serial console
if (instance.console()) {
if (instance.kgdb() || instance.use_bootloader()) {
add_serial_console(instance.console_pipe_prefix());
add_serial_console(ConsolePipePrefix(instance));

// In kgdb mode, we have the interactive console on ttyS0 (both Android's
// console and kdb), so we can disable the virtio-console port usually
Expand All @@ -549,7 +549,7 @@ Result<std::vector<MonitorCommand>> QemuManager::StartCommands(
add_hvc_sink();
} else {
add_serial_sink();
add_hvc(instance.console_pipe_prefix());
add_hvc(ConsolePipePrefix(instance));
}
} else {
if (instance.kgdb() || instance.use_bootloader()) {
Expand Down
Loading