Merge changes I3ec2bc0b,I87eae110 into cuttlefish-testing
* changes:
Avoid unnecessary error messages from hwcomposer under crosvm
Don't configure input in crosvm when running without frontend
diff --git a/guest/hals/hwcomposer/cutf_cvm/Android.bp b/guest/hals/hwcomposer/cutf_cvm/Android.bp
index 09bccd8..5a54d14 100644
--- a/guest/hals/hwcomposer/cutf_cvm/Android.bp
+++ b/guest/hals/hwcomposer/cutf_cvm/Android.bp
@@ -30,6 +30,7 @@
export_include_dirs: ["."],
static_libs: ["libyuv_static", "hwcomposer_common"],
shared_libs: [
+ "cuttlefish_auto_resources",
"liblog",
"libhardware",
"libbase",
diff --git a/guest/hals/hwcomposer/cutf_cvm/base_composer.cpp b/guest/hals/hwcomposer/cutf_cvm/base_composer.cpp
index 23be7e1..a1f1597 100644
--- a/guest/hals/hwcomposer/cutf_cvm/base_composer.cpp
+++ b/guest/hals/hwcomposer/cutf_cvm/base_composer.cpp
@@ -77,30 +77,34 @@
}
FrameBuffer::FrameBuffer()
- : screen_server_(cvd::SharedFD::VsockClient(
- 2, property_get_int32("ro.boot.vsock_frames_port", 5580),
- SOCK_STREAM)),
- broadcast_thread_([this]() { BroadcastLoop(); }) {
- if (screen_server_->IsOpen()) {
- // TODO(b/128842613): Get this info from the configuration server
- int32_t screen_params[4];
- auto res = screen_server_->Read(screen_params, sizeof(screen_params));
- if (res == sizeof(screen_params)) {
- x_res_ = screen_params[0];
- y_res_ = screen_params[1];
- dpi_ = screen_params[2];
- refresh_rate_ = screen_params[3];
+ : broadcast_thread_([this]() { BroadcastLoop(); }) {
+ auto vsock_frames_port = property_get_int32("ro.boot.vsock_frames_port", -1);
+ if (vsock_frames_port > 0) {
+ screen_server_ = cvd::SharedFD::VsockClient(2, vsock_frames_port,
+ SOCK_STREAM);
+ if (screen_server_->IsOpen()) {
+ // TODO(b/128842613): Get this info from the configuration server
+ int32_t screen_params[4];
+ auto res = screen_server_->Read(screen_params, sizeof(screen_params));
+ if (res == sizeof(screen_params)) {
+ x_res_ = screen_params[0];
+ y_res_ = screen_params[1];
+ dpi_ = screen_params[2];
+ refresh_rate_ = screen_params[3];
+ } else {
+ LOG(ERROR) << "Unable to get screen configuration parameters from screen "
+ << "server (" << res << "): " << screen_server_->StrError();
+ }
} else {
- LOG(ERROR) << "Unable to get screen configuration parameters from screen "
- << "server (" << res << "): " << screen_server_->StrError();
+ LOG(ERROR) << "Unable to connect to screen server: "
+ << screen_server_->StrError();
}
} else {
- LOG(ERROR) << "Unable to connect to screen server: "
- << screen_server_->StrError();
+ LOG(INFO) << "No screen server configured, operating on headless mode";
}
// This needs to happen no matter what, otherwise there won't be a buffer for
// the set calls to compose on.
- inner_buffer_ = std::vector<char>(FrameBuffer::buffer_size() * 8);
+ inner_buffer_ = std::vector<char>(buffer_size() * 8);
}
FrameBuffer::~FrameBuffer() {
diff --git a/host/commands/launch/flags.cc b/host/commands/launch/flags.cc
index ed50269..6c0867d 100644
--- a/host/commands/launch/flags.cc
+++ b/host/commands/launch/flags.cc
@@ -486,7 +486,7 @@
tmp_config_obj.set_logcat_vsock_port(FLAGS_logcat_vsock_port);
tmp_config_obj.set_config_server_port(FLAGS_config_server_port);
tmp_config_obj.set_frames_vsock_port(FLAGS_frames_vsock_port);
- if (!tmp_config_obj.enable_ivserver()) {
+ if (!tmp_config_obj.enable_ivserver() && tmp_config_obj.enable_vnc_server()) {
tmp_config_obj.add_kernel_cmdline(concat("androidboot.vsock_frames_port=",
FLAGS_frames_vsock_port));
}
diff --git a/host/commands/launch/launch.cc b/host/commands/launch/launch.cc
index e5f6d37..7d8892d 100644
--- a/host/commands/launch/launch.cc
+++ b/host/commands/launch/launch.cc
@@ -262,7 +262,7 @@
return server;
}
-void LaunchVNCServerIfEnabled(const vsoc::CuttlefishConfig& config,
+bool LaunchVNCServerIfEnabled(const vsoc::CuttlefishConfig& config,
cvd::ProcessMonitor* process_monitor,
std::function<bool(MonitorEntry*)> callback) {
if (config.enable_vnc_server()) {
@@ -276,14 +276,14 @@
// crosvm)
auto touch_server = CreateVncInputServer(config.touch_socket_path());
if (!touch_server->IsOpen()) {
- return;
+ return false;
}
vnc_server.AddParameter("-touch_fd=", touch_server);
auto keyboard_server =
CreateVncInputServer(config.keyboard_socket_path());
if (!keyboard_server->IsOpen()) {
- return;
+ return false;
}
vnc_server.AddParameter("-keyboard_fd=", keyboard_server);
// TODO(b/128852363): This should be handled through the wayland mock
@@ -293,12 +293,14 @@
auto frames_server =
cvd::SharedFD::VsockServer(config.frames_vsock_port(), SOCK_STREAM);
if (!frames_server->IsOpen()) {
- return;
+ return false;
}
vnc_server.AddParameter("-frame_server_fd=", frames_server);
}
process_monitor->StartSubprocess(std::move(vnc_server), callback);
+ return true;
}
+ return false;
}
void LaunchStreamAudioIfEnabled(const vsoc::CuttlefishConfig& config,
diff --git a/host/commands/launch/launch.h b/host/commands/launch/launch.h
index 4b23958..ec95c24 100644
--- a/host/commands/launch/launch.h
+++ b/host/commands/launch/launch.h
@@ -21,7 +21,7 @@
cvd::ProcessMonitor* process_monitor);
void LaunchUsbServerIfEnabled(const vsoc::CuttlefishConfig& config,
cvd::ProcessMonitor* process_monitor);
-void LaunchVNCServerIfEnabled(const vsoc::CuttlefishConfig& config,
+bool LaunchVNCServerIfEnabled(const vsoc::CuttlefishConfig& config,
cvd::ProcessMonitor* process_monitor,
std::function<bool(cvd::MonitorEntry*)> callback);
void LaunchStreamAudioIfEnabled(const vsoc::CuttlefishConfig& config,
diff --git a/host/commands/launch/main.cc b/host/commands/launch/main.cc
index a9c8e3e..5b05102 100644
--- a/host/commands/launch/main.cc
+++ b/host/commands/launch/main.cc
@@ -433,15 +433,19 @@
// Launch the e2e tests after the ivserver is ready
LaunchE2eTestIfEnabled(&process_monitor, boot_state_machine, *config);
+ // The vnc server needs to be launched after the ivserver because it connects
+ // to it when using qemu. It needs to launch before the VMM because it serves
+ // on several sockets (input devices, vsock frame server) when using crosvm.
+ auto frontend_enabled = LaunchVNCServerIfEnabled(
+ *config, &process_monitor, GetOnSubprocessExitCallback(*config));
+
// Start the guest VM
- process_monitor.StartSubprocess(vm_manager->StartCommand(),
+ process_monitor.StartSubprocess(vm_manager->StartCommand(frontend_enabled),
GetOnSubprocessExitCallback(*config));
// Start other host processes
LaunchSocketForwardProxyIfEnabled(&process_monitor, *config);
LaunchSocketVsockProxyIfEnabled(&process_monitor, *config);
- LaunchVNCServerIfEnabled(*config, &process_monitor,
- GetOnSubprocessExitCallback(*config));
LaunchStreamAudioIfEnabled(*config, &process_monitor,
GetOnSubprocessExitCallback(*config));
LaunchAdbConnectorIfEnabled(&process_monitor, *config, adbd_events_pipe);
diff --git a/host/libs/vm_manager/crosvm_manager.cpp b/host/libs/vm_manager/crosvm_manager.cpp
index 8ae3359..21f0518 100644
--- a/host/libs/vm_manager/crosvm_manager.cpp
+++ b/host/libs/vm_manager/crosvm_manager.cpp
@@ -85,7 +85,7 @@
CrosvmManager::CrosvmManager(const vsoc::CuttlefishConfig* config)
: VmManager(config) {}
-cvd::Command CrosvmManager::StartCommand() {
+cvd::Command CrosvmManager::StartCommand(bool with_frontend) {
// TODO Add aarch64 support
// TODO Add the tap interfaces (--tap-fd)
// TODO Redirect logcat output
@@ -124,9 +124,12 @@
if (!config_->gsi_fstab_path().empty()) {
command.AddParameter("--android-fstab=", config_->gsi_fstab_path());
}
- command.AddParameter("--single-touch=", config_->touch_socket_path(), ":",
- config_->x_res(), ":", config_->y_res());
- command.AddParameter("--keyboard=", config_->keyboard_socket_path());
+
+ if (with_frontend) {
+ command.AddParameter("--single-touch=", config_->touch_socket_path(), ":",
+ config_->x_res(), ":", config_->y_res());
+ command.AddParameter("--keyboard=", config_->keyboard_socket_path());
+ }
AddTapFdParameter(&command, config_->wifi_tap_name());
AddTapFdParameter(&command, config_->mobile_tap_name());
diff --git a/host/libs/vm_manager/crosvm_manager.h b/host/libs/vm_manager/crosvm_manager.h
index ac26ee8..4640cfa 100644
--- a/host/libs/vm_manager/crosvm_manager.h
+++ b/host/libs/vm_manager/crosvm_manager.h
@@ -34,7 +34,7 @@
CrosvmManager(const vsoc::CuttlefishConfig* config);
virtual ~CrosvmManager() = default;
- cvd::Command StartCommand() override;
+ cvd::Command StartCommand(bool with_frontend) override;
bool Stop() override;
};
diff --git a/host/libs/vm_manager/qemu_manager.cpp b/host/libs/vm_manager/qemu_manager.cpp
index ac83972..a9bb5cf 100644
--- a/host/libs/vm_manager/qemu_manager.cpp
+++ b/host/libs/vm_manager/qemu_manager.cpp
@@ -81,7 +81,7 @@
QemuManager::QemuManager(const vsoc::CuttlefishConfig* config)
: VmManager(config) {}
-cvd::Command QemuManager::StartCommand(){
+cvd::Command QemuManager::StartCommand(bool /*with_frontend*/){
// Set the config values in the environment
LogAndSetEnv("qemu_binary", config_->qemu_binary());
LogAndSetEnv("instance_name", config_->instance_name());
diff --git a/host/libs/vm_manager/qemu_manager.h b/host/libs/vm_manager/qemu_manager.h
index ea24644..66ff8d6 100644
--- a/host/libs/vm_manager/qemu_manager.h
+++ b/host/libs/vm_manager/qemu_manager.h
@@ -32,7 +32,7 @@
QemuManager(const vsoc::CuttlefishConfig* config);
virtual ~QemuManager() = default;
- cvd::Command StartCommand() override;
+ cvd::Command StartCommand(bool with_frontend) override;
bool Stop() override;
};
diff --git a/host/libs/vm_manager/vm_manager.h b/host/libs/vm_manager/vm_manager.h
index ac93e26..6b1661e 100644
--- a/host/libs/vm_manager/vm_manager.h
+++ b/host/libs/vm_manager/vm_manager.h
@@ -42,7 +42,7 @@
virtual ~VmManager() = default;
- virtual cvd::Command StartCommand() = 0;
+ virtual cvd::Command StartCommand(bool with_frontend = true) = 0;
virtual bool Stop() = 0;
virtual bool ValidateHostConfiguration(