summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-11-11 21:26:48 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-11-11 21:26:48 +0000
commit0af512baf22c2750a609b2b0861337bf4cb7ffbb (patch)
treed296b496c1f6e061c6e5502ab46b60eac5ac13d8
parent8b3ea98139f3854bceda97dd4c543591a2ecb257 (diff)
parent3f5327ec7edd8e6005403b21324e720bf4dbdf0c (diff)
downloadcuttlefish_common-android10-mainline-networking-release.tar.gz
Snap for 6001391 from 3f5327ec7edd8e6005403b21324e720bf4dbdf0c to qt-aml-networking-releaseandroid-mainline-10.0.0_r6android10-mainline-networking-release
Change-Id: If79a8c6cc173dc2da01029a3e8805d05c4c8fde6
-rw-r--r--guest/commands/vsoc_input_service/Android.bp7
-rw-r--r--guest/commands/vsoc_input_service/main.cpp4
-rw-r--r--guest/commands/vsoc_input_service/virtual_device_base.cpp3
-rw-r--r--guest/commands/vsoc_input_service/vsoc_input_service.cpp95
-rw-r--r--guest/hals/health/android.hardware.health@2.0-service.cuttlefish.rc4
-rw-r--r--guest/monitoring/tombstone_transmit/tombstone_transmit.cpp4
-rw-r--r--host/commands/assemble_cvd/Android.bp5
-rw-r--r--host/commands/assemble_cvd/flags.cc59
-rw-r--r--host/commands/launch/filesystem_explorer.cc12
-rw-r--r--host/commands/run_cvd/launch.cc73
-rw-r--r--host/frontend/vnc_server/virtual_inputs.cpp52
-rw-r--r--host/libs/config/cuttlefish_config.cpp20
-rw-r--r--host/libs/config/cuttlefish_config.h6
-rw-r--r--host/libs/config/fetcher_config.cpp16
-rw-r--r--host/libs/config/fetcher_config.h2
-rw-r--r--host/libs/vm_manager/Android.bp5
-rwxr-xr-xhost/libs/vm_manager/cf_qemu.sh7
-rw-r--r--host/libs/vm_manager/qemu_manager.cpp5
-rw-r--r--tests/hidl/hidl_implementation_test.cpp1
19 files changed, 256 insertions, 124 deletions
diff --git a/guest/commands/vsoc_input_service/Android.bp b/guest/commands/vsoc_input_service/Android.bp
index 76aae19f..73ca0671 100644
--- a/guest/commands/vsoc_input_service/Android.bp
+++ b/guest/commands/vsoc_input_service/Android.bp
@@ -24,12 +24,19 @@ cc_binary {
"virtual_touchscreen.cpp",
"vsoc_input_service.cpp",
],
+ static_libs: [
+ "libgflags",
+ ],
shared_libs: [
"cuttlefish_auto_resources",
+ "libcuttlefish_device_config",
"libcuttlefish_fs",
"libbase",
"liblog",
"vsoc_lib",
],
+ header_libs: [
+ "cuttlefish_glog",
+ ],
defaults: ["cuttlefish_guest_only"]
}
diff --git a/guest/commands/vsoc_input_service/main.cpp b/guest/commands/vsoc_input_service/main.cpp
index 47b02a5f..c9e93ede 100644
--- a/guest/commands/vsoc_input_service/main.cpp
+++ b/guest/commands/vsoc_input_service/main.cpp
@@ -15,10 +15,12 @@
*/
#include "log/log.h"
+#include <gflags/gflags.h>
#include "vsoc_input_service.h"
-int main(int /* arg */, char* /* argv */[]) {
+int main(int argc, char* argv[]) {
+ gflags::ParseCommandLineFlags(&argc, &argv, true);
vsoc_input_service::VSoCInputService service;
if (!service.SetUpDevices()) {
return -1;
diff --git a/guest/commands/vsoc_input_service/virtual_device_base.cpp b/guest/commands/vsoc_input_service/virtual_device_base.cpp
index d0c16bda..0abb0cd9 100644
--- a/guest/commands/vsoc_input_service/virtual_device_base.cpp
+++ b/guest/commands/vsoc_input_service/virtual_device_base.cpp
@@ -16,6 +16,7 @@
#include "virtual_device_base.h"
+#include <glog/logging.h>
#include <errno.h>
#include <inttypes.h>
#include <string.h>
@@ -103,6 +104,8 @@ bool VirtualDeviceBase::SetUp() {
return false;
}
+ LOG(INFO) << "set up virtual device";
+
return true;
}
diff --git a/guest/commands/vsoc_input_service/vsoc_input_service.cpp b/guest/commands/vsoc_input_service/vsoc_input_service.cpp
index d100a527..8753735c 100644
--- a/guest/commands/vsoc_input_service/vsoc_input_service.cpp
+++ b/guest/commands/vsoc_input_service/vsoc_input_service.cpp
@@ -18,37 +18,35 @@
#include <linux/input.h>
#include <linux/uinput.h>
+#include <linux/virtio_input.h>
#include <thread>
+#include <gflags/gflags.h>
#include "log/log.h"
+#include <glog/logging.h>
-#include "common/vsoc/lib/screen_region_view.h"
+#include "common/libs/fs/shared_fd.h"
+#include "common/libs/device_config/device_config.h"
#include "common/vsoc/lib/input_events_region_view.h"
-using vsoc::screen::ScreenRegionView;
using vsoc::input_events::InputEvent;
-using vsoc::input_events::InputEventsRegionView;
using vsoc_input_service::VirtualDeviceBase;
using vsoc_input_service::VirtualKeyboard;
using vsoc_input_service::VirtualPowerButton;
using vsoc_input_service::VirtualTouchScreen;
using vsoc_input_service::VSoCInputService;
+DEFINE_uint32(keyboard_port, 0, "keyboard vsock port");
+DEFINE_uint32(touch_port, 0, "keyboard vsock port");
+
namespace {
void EventLoop(std::shared_ptr<VirtualDeviceBase> device,
- std::function<int(InputEvent*, int)> next_events) {
+ std::function<InputEvent()> next_event) {
while (1) {
- InputEvent events[InputEventsRegionView::kMaxEventsPerPacket];
- int count = next_events(events, InputEventsRegionView::kMaxEventsPerPacket);
- if (count <= 0) {
- SLOGE("Error getting events from the queue: Maybe check packet size");
- continue;
- }
- for (int i = 0; i < count; ++i) {
- device->EmitEvent(events[i].type, events[i].code, events[i].value);
- }
+ InputEvent event = next_event();
+ device->EmitEvent(event.type, event.code, event.value);
}
}
@@ -64,14 +62,14 @@ bool VSoCInputService::SetUpDevices() {
return false;
}
- auto screen_view = ScreenRegionView::GetInstance();
- if (!screen_view) {
- SLOGE("Failed to open framebuffer broadcast region");
+ auto config = cvd::DeviceConfig::Get();
+ if (!config) {
+ LOG(ERROR) << "Failed to open device config";
return false;
}
virtual_touchscreen_.reset(
- new VirtualTouchScreen(screen_view->x_res(), screen_view->y_res()));
+ new VirtualTouchScreen(config->screen_x_res(), config->screen_y_res()));
if (!virtual_touchscreen_->SetUp()) {
return false;
}
@@ -80,35 +78,56 @@ bool VSoCInputService::SetUpDevices() {
}
bool VSoCInputService::ProcessEvents() {
- auto input_events_rv = InputEventsRegionView::GetInstance();
- // TODO(jemoreira): Post available devices to region
- auto worker = input_events_rv->StartWorker();
+ cvd::SharedFD keyboard_fd;
+ cvd::SharedFD touch_fd;
+
+ LOG(INFO) << "Connecting to the keyboard at " << FLAGS_keyboard_port;
+ if (FLAGS_keyboard_port) {
+ keyboard_fd = cvd::SharedFD::VsockClient(2, FLAGS_keyboard_port, SOCK_STREAM);
+ if (!keyboard_fd->IsOpen()) {
+ LOG(ERROR) << "Could not connect to the keyboard at vsock:2:" << FLAGS_keyboard_port;
+ }
+ LOG(INFO) << "Connected to keyboard";
+ }
+ LOG(INFO) << "Connecting to the touchscreen at " << FLAGS_keyboard_port;
+ if (FLAGS_touch_port) {
+ touch_fd = cvd::SharedFD::VsockClient(2, FLAGS_touch_port, SOCK_STREAM);
+ if (!touch_fd->IsOpen()) {
+ LOG(ERROR) << "Could not connect to the touch at vsock:2:" << FLAGS_touch_port;
+ }
+ LOG(INFO) << "Connected to touch";
+ }
// Start device threads
- std::thread screen_thread([this]() {
- EventLoop(
- virtual_touchscreen_, [](InputEvent* event_buffer, int max_events) {
- return InputEventsRegionView::GetInstance()->GetScreenEventsOrWait(
- event_buffer, max_events);
- });
- });
- std::thread keyboard_thread([this]() {
- EventLoop(virtual_keyboard_, [](InputEvent* event_buffer, int max_events) {
- return InputEventsRegionView::GetInstance()->GetKeyboardEventsOrWait(
- event_buffer, max_events);
+ std::thread screen_thread([this, touch_fd]() {
+ EventLoop(virtual_touchscreen_, [touch_fd]() {
+ struct virtio_input_event event;
+ if (touch_fd->Read(&event, sizeof(event)) != sizeof(event)) {
+ LOG(FATAL) << "Could not read touch event: " << touch_fd->StrError();
+ }
+ return InputEvent {
+ .type = event.type,
+ .code = event.code,
+ .value = event.value,
+ };
});
});
- std::thread button_thread([this]() {
- EventLoop(virtual_power_button_,
- [](InputEvent* event_buffer, int max_events) {
- return InputEventsRegionView::GetInstance()
- ->GetPowerButtonEventsOrWait(event_buffer, max_events);
- });
+ std::thread keyboard_thread([this, keyboard_fd]() {
+ EventLoop(virtual_keyboard_, [keyboard_fd]() {
+ struct virtio_input_event event;
+ if (keyboard_fd->Read(&event, sizeof(event)) != sizeof(event)) {
+ LOG(FATAL) << "Could not read keyboard event: " << keyboard_fd->StrError();
+ }
+ return InputEvent {
+ .type = event.type,
+ .code = event.code,
+ .value = event.value,
+ };
+ });
});
screen_thread.join();
keyboard_thread.join();
- button_thread.join();
// Should never return
return false;
diff --git a/guest/hals/health/android.hardware.health@2.0-service.cuttlefish.rc b/guest/hals/health/android.hardware.health@2.0-service.cuttlefish.rc
deleted file mode 100644
index c225ee8d..00000000
--- a/guest/hals/health/android.hardware.health@2.0-service.cuttlefish.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service vendor.health-hal-2-0 /vendor/bin/hw/android.hardware.health@2.0-service.cuttlefish
- class hal
- user system
- group system
diff --git a/guest/monitoring/tombstone_transmit/tombstone_transmit.cpp b/guest/monitoring/tombstone_transmit/tombstone_transmit.cpp
index 3633612c..8fc3586c 100644
--- a/guest/monitoring/tombstone_transmit/tombstone_transmit.cpp
+++ b/guest/monitoring/tombstone_transmit/tombstone_transmit.cpp
@@ -86,7 +86,6 @@ DEFINE_uint32(port, property_get_int32("ro.boot.vsock_tombstone_port", 0),
"VSOCK port to send tombstones to");
DEFINE_uint32(cid, 2, "VSOCK CID to send logcat output to");
#define TOMBSTONE_BUFFER_SIZE (1024)
-#define MAX_TOMBSTONE_SIZE (50 * TOMBSTONE_BUFFER_SIZE)
int main(int argc, char** argv) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
@@ -114,8 +113,7 @@ int main(int argc, char** argv) {
char buffer[TOMBSTONE_BUFFER_SIZE];
uint num_transfers = 0;
int num_bytes_read = 0;
- while (log_fd->IsOpen() && ifs.is_open() && !ifs.eof() &&
- num_bytes_read < MAX_TOMBSTONE_SIZE) {
+ while (log_fd->IsOpen() && ifs.is_open() && !ifs.eof()) {
ifs.read(buffer, sizeof(buffer));
num_bytes_read += ifs.gcount();
log_fd->Write(buffer, ifs.gcount());
diff --git a/host/commands/assemble_cvd/Android.bp b/host/commands/assemble_cvd/Android.bp
index b03d8bfb..10f4e311 100644
--- a/host/commands/assemble_cvd/Android.bp
+++ b/host/commands/assemble_cvd/Android.bp
@@ -66,8 +66,7 @@ cc_binary_host {
defaults: ["cuttlefish_host_only", "cuttlefish_libicuuc"],
}
-cc_prebuilt_binary {
+sh_binary_host {
name: "cf_bpttool",
- srcs: ["cf_bpttool"],
- defaults: ["cuttlefish_host_only"],
+ src: "cf_bpttool",
}
diff --git a/host/commands/assemble_cvd/flags.cc b/host/commands/assemble_cvd/flags.cc
index 54eefcc0..38fada30 100644
--- a/host/commands/assemble_cvd/flags.cc
+++ b/host/commands/assemble_cvd/flags.cc
@@ -180,7 +180,6 @@ DEFINE_string(console_forwarder_binary,
vsoc::DefaultHostArtifactsPath("bin/console_forwarder"),
"The Console Forwarder binary to use");
DEFINE_bool(restart_subprocesses, true, "Restart any crashed host process");
-DEFINE_bool(run_e2e_test, true, "Run e2e test after device launches");
DEFINE_string(e2e_test_binary,
vsoc::DefaultHostArtifactsPath("bin/host_region_e2e_test"),
"Location of the region end to end test binary");
@@ -205,6 +204,10 @@ DEFINE_string(tombstone_receiver_binary,
"Binary for the tombstone server");
DEFINE_int32(tombstone_receiver_port, vsoc::GetPerInstanceDefault(5630),
"The vsock port for tombstones");
+DEFINE_int32(keyboard_server_port, GetPerInstanceDefault(5540),
+ "The port on which the vsock keyboard server should listen");
+DEFINE_int32(touch_server_port, GetPerInstanceDefault(5640),
+ "The port on which the vsock touch server should listen");
DEFINE_bool(use_bootloader, false, "Boots the device using a bootloader");
DEFINE_string(bootloader, "", "Bootloader binary path");
DEFINE_string(boot_slot, "", "Force booting into the given slot. If empty, "
@@ -214,7 +217,9 @@ DEFINE_string(boot_slot, "", "Force booting into the given slot. If empty, "
namespace {
-std::string kRamdiskConcatExt = ".concat";
+const std::string kKernelDefaultPath = "kernel";
+const std::string kInitramfsImg = "initramfs.img";
+const std::string kRamdiskConcatExt = ".concat";
template<typename S, typename T>
static std::string concat(const S& s, const T& t) {
@@ -273,7 +278,8 @@ int GetHostPort() {
// Initializes the config object and saves it to file. It doesn't return it, all
// further uses of the config should happen through the singleton
bool InitializeCuttlefishConfiguration(
- const cvd::BootImageUnpacker& boot_image_unpacker) {
+ const cvd::BootImageUnpacker& boot_image_unpacker,
+ const cvd::FetcherConfig& fetcher_config) {
vsoc::CuttlefishConfig tmp_config_obj;
auto& memory_layout = *vsoc::VSoCMemoryLayout::Get();
// Set this first so that calls to PerInstancePath below are correct
@@ -316,12 +322,14 @@ bool InitializeCuttlefishConfiguration(
tmp_config_obj.set_adb_ip_and_port("127.0.0.1:" + std::to_string(GetHostPort()));
tmp_config_obj.set_device_title(FLAGS_device_title);
- if (FLAGS_kernel_path.size()) {
- tmp_config_obj.set_kernel_image_path(FLAGS_kernel_path);
+ std::string discovered_kernel = fetcher_config.FindCvdFileWithSuffix(kKernelDefaultPath);
+ std::string foreign_kernel = FLAGS_kernel_path.size() ? FLAGS_kernel_path : discovered_kernel;
+ if (foreign_kernel.size()) {
+ tmp_config_obj.set_kernel_image_path(foreign_kernel);
tmp_config_obj.set_use_unpacked_kernel(false);
} else {
tmp_config_obj.set_kernel_image_path(
- tmp_config_obj.PerInstancePath("kernel"));
+ tmp_config_obj.PerInstancePath(kKernelDefaultPath.c_str()));
tmp_config_obj.set_use_unpacked_kernel(true);
}
tmp_config_obj.set_decompress_kernel(FLAGS_decompress_kernel);
@@ -394,9 +402,6 @@ bool InitializeCuttlefishConfiguration(
tmp_config_obj.add_kernel_cmdline("audit=0");
}
}
- if (FLAGS_run_e2e_test) {
- tmp_config_obj.add_kernel_cmdline("androidboot.vsoc_e2e_test=1");
- }
if (FLAGS_extra_kernel_cmdline.size()) {
tmp_config_obj.add_kernel_cmdline(FLAGS_extra_kernel_cmdline);
}
@@ -418,7 +423,9 @@ bool InitializeCuttlefishConfiguration(
// Boot as recovery is set so normal boot needs to be forced every boot
tmp_config_obj.add_kernel_cmdline("androidboot.force_normal_boot=1");
- if (FLAGS_kernel_path.size() && !FLAGS_initramfs_path.size()) {
+ std::string discovered_ramdisk = fetcher_config.FindCvdFileWithSuffix(kInitramfsImg);
+ std::string foreign_ramdisk = FLAGS_initramfs_path.size () ? FLAGS_initramfs_path : discovered_ramdisk;
+ if (foreign_kernel.size() && !foreign_ramdisk.size()) {
// If there's a kernel that's passed in without an initramfs, that implies
// user error or a kernel built with no modules. In either case, let's
// choose to avoid loading the modules from the vendor ramdisk which are
@@ -427,8 +434,8 @@ bool InitializeCuttlefishConfiguration(
tmp_config_obj.set_final_ramdisk_path(ramdisk_path);
} else {
tmp_config_obj.set_final_ramdisk_path(ramdisk_path + kRamdiskConcatExt);
- if(FLAGS_initramfs_path.size()) {
- tmp_config_obj.set_initramfs_path(FLAGS_initramfs_path);
+ if(foreign_ramdisk.size()) {
+ tmp_config_obj.set_initramfs_path(foreign_ramdisk);
}
}
@@ -493,7 +500,7 @@ bool InitializeCuttlefishConfiguration(
FLAGS_socket_forward_proxy_binary);
tmp_config_obj.set_socket_vsock_proxy_binary(FLAGS_socket_vsock_proxy_binary);
tmp_config_obj.set_run_as_daemon(FLAGS_daemon);
- tmp_config_obj.set_run_e2e_test(FLAGS_run_e2e_test);
+ tmp_config_obj.set_run_e2e_test(false);
tmp_config_obj.set_e2e_test_binary(FLAGS_e2e_test_binary);
tmp_config_obj.set_data_policy(FLAGS_data_policy);
@@ -526,6 +533,15 @@ bool InitializeCuttlefishConfiguration(
tmp_config_obj.add_kernel_cmdline("androidboot.tombstone_transmit=0");
}
+ tmp_config_obj.set_touch_socket_port(FLAGS_touch_server_port);
+ tmp_config_obj.set_keyboard_socket_port(FLAGS_keyboard_server_port);
+ if (FLAGS_vm_manager == vm_manager::QemuManager::name()) {
+ tmp_config_obj.add_kernel_cmdline(concat("androidboot.vsock_touch_port=",
+ FLAGS_touch_server_port));
+ tmp_config_obj.add_kernel_cmdline(concat("androidboot.vsock_keyboard_port=",
+ FLAGS_keyboard_server_port));
+ }
+
tmp_config_obj.set_use_bootloader(FLAGS_use_bootloader);
tmp_config_obj.set_bootloader(FLAGS_bootloader);
@@ -568,9 +584,11 @@ void SetDefaultFlagsForQemu() {
SetCommandLineOptionWithMode("instance_dir",
default_instance_dir.c_str(),
google::FlagSettingMode::SET_FLAGS_DEFAULT);
- SetCommandLineOptionWithMode("hardware_name", "cutf_ivsh",
+ // TODO(b/144111429): Consolidate to one hardware name
+ SetCommandLineOptionWithMode("hardware_name", "cutf_cvm",
google::FlagSettingMode::SET_FLAGS_DEFAULT);
- SetCommandLineOptionWithMode("logcat_mode", cvd::kLogcatSerialMode,
+ // TODO(b/144119457) Use the serial port.
+ SetCommandLineOptionWithMode("logcat_mode", cvd::kLogcatVsockMode,
google::FlagSettingMode::SET_FLAGS_DEFAULT);
}
@@ -586,10 +604,9 @@ void SetDefaultFlagsForCrosvm() {
SetCommandLineOptionWithMode("x_display",
getenv("DISPLAY"),
google::FlagSettingMode::SET_FLAGS_DEFAULT);
+ // TODO(b/144111429): Consolidate to one hardware name
SetCommandLineOptionWithMode("hardware_name", "cutf_cvm",
google::FlagSettingMode::SET_FLAGS_DEFAULT);
- SetCommandLineOptionWithMode("run_e2e_test", "false",
- google::FlagSettingMode::SET_FLAGS_DEFAULT);
SetCommandLineOptionWithMode("logcat_mode", cvd::kLogcatVsockMode,
google::FlagSettingMode::SET_FLAGS_DEFAULT);
}
@@ -796,7 +813,7 @@ const vsoc::CuttlefishConfig* InitFilesystemAndCreateConfig(
cvd::BootImageUnpacker::FromImages(FLAGS_boot_image,
FLAGS_vendor_boot_image);
- if (!InitializeCuttlefishConfiguration(*boot_img_unpacker)) {
+ if (!InitializeCuttlefishConfiguration(*boot_img_unpacker, fetcher_config)) {
LOG(ERROR) << "Failed to initialize configuration";
exit(AssemblerExitCodes::kCuttlefishConfigurationInitError);
}
@@ -829,7 +846,11 @@ const vsoc::CuttlefishConfig* InitFilesystemAndCreateConfig(
// boot ramdisk. If a kernel IS provided with no initramfs, it is safe to
// safe to assume that the kernel was built with no modules and expects no
// modules for cf to run properly.
- if(!FLAGS_kernel_path.size() || FLAGS_initramfs_path.size()) {
+ std::string discovered_kernel = fetcher_config.FindCvdFileWithSuffix(kKernelDefaultPath);
+ std::string foreign_kernel = FLAGS_kernel_path.size() ? FLAGS_kernel_path : discovered_kernel;
+ std::string discovered_ramdisk = fetcher_config.FindCvdFileWithSuffix(kInitramfsImg);
+ std::string foreign_ramdisk = FLAGS_initramfs_path.size () ? FLAGS_initramfs_path : discovered_ramdisk;
+ if(!foreign_kernel.size() || foreign_ramdisk.size()) {
const std::string& vendor_ramdisk_path =
config->initramfs_path().size() ? config->initramfs_path()
: config->vendor_ramdisk_image_path();
diff --git a/host/commands/launch/filesystem_explorer.cc b/host/commands/launch/filesystem_explorer.cc
index 5be4ef05..18ed0d8a 100644
--- a/host/commands/launch/filesystem_explorer.cc
+++ b/host/commands/launch/filesystem_explorer.cc
@@ -36,7 +36,8 @@ namespace {
* This is a shallow exploration that ignores directories, i.e. it only prints
* any regular files.
*/
-std::set<std::string> ReportFiles(const std::string& directory_path) {
+std::set<std::string> ReportFiles(const std::string& directory_path,
+ const std::string& suffix = "") {
// TODO(schuffelen): Put this in a common library.
DIR* directory = opendir(directory_path.c_str());
if (!directory) {
@@ -51,7 +52,12 @@ std::set<std::string> ReportFiles(const std::string& directory_path) {
if (entry->d_type == DT_DIR) {
continue;
}
- found_files.insert(directory_path + "/" + std::string(entry->d_name));
+ std::string full_path = directory_path + "/" + std::string(entry->d_name);
+ if (suffix != "" && full_path.compare(full_path.length() - suffix.length(),
+ suffix.length(), suffix) != 0) {
+ continue;
+ }
+ found_files.insert(full_path);
}
closedir(directory);
return found_files;
@@ -94,7 +100,7 @@ cvd::FetcherConfig AvailableFilesReport() {
std::string product_out = cvd::StringFromEnv("ANDROID_PRODUCT_OUT", "");
if (product_out != "") {
- files.merge(ReportFiles(cvd::AbsolutePath(product_out)));
+ files.merge(ReportFiles(cvd::AbsolutePath(product_out), ".img"));
}
files.merge(HeuristicFileReport(current_directory));
diff --git a/host/commands/run_cvd/launch.cc b/host/commands/run_cvd/launch.cc
index 47cf2e26..5c42e593 100644
--- a/host/commands/run_cvd/launch.cc
+++ b/host/commands/run_cvd/launch.cc
@@ -12,6 +12,8 @@
#include "host/commands/run_cvd/runner_defs.h"
#include "host/commands/run_cvd/pre_launch_initializers.h"
#include "host/commands/run_cvd/vsoc_shared_memory.h"
+#include "host/libs/vm_manager/crosvm_manager.h"
+#include "host/libs/vm_manager/qemu_manager.h"
using cvd::RunnerExitCodes;
using cvd::MonitorEntry;
@@ -246,10 +248,20 @@ void LaunchUsbServerIfEnabled(const vsoc::CuttlefishConfig& config,
GetOnSubprocessExitCallback(config));
}
-cvd::SharedFD CreateVncInputServer(const std::string& path) {
+cvd::SharedFD CreateUnixVncInputServer(const std::string& path) {
auto server = cvd::SharedFD::SocketLocalServer(path.c_str(), false, SOCK_STREAM, 0666);
if (!server->IsOpen()) {
- LOG(ERROR) << "Unable to create mouse server: "
+ LOG(ERROR) << "Unable to create unix input server: "
+ << server->StrError();
+ return cvd::SharedFD();
+ }
+ return server;
+}
+
+cvd::SharedFD CreateVsockVncInputServer(int port) {
+ auto server = cvd::SharedFD::VsockServer(port, SOCK_STREAM);
+ if (!server->IsOpen()) {
+ LOG(ERROR) << "Unable to create vsock input server: "
<< server->StrError();
return cvd::SharedFD();
}
@@ -264,33 +276,38 @@ bool LaunchVNCServerIfEnabled(const vsoc::CuttlefishConfig& config,
auto port_options = "-port=" + std::to_string(config.vnc_server_port());
cvd::Command vnc_server(config.vnc_server_binary());
vnc_server.AddParameter(port_options);
- if (!config.enable_ivserver()) {
- // When the ivserver is not enabled, the vnc touch_server needs to serve
- // on unix sockets and send input events to whoever connects to it (namely
- // crosvm)
- auto touch_server = CreateVncInputServer(config.touch_socket_path());
- if (!touch_server->IsOpen()) {
- return false;
- }
- vnc_server.AddParameter("-touch_fd=", touch_server);
-
- auto keyboard_server =
- CreateVncInputServer(config.keyboard_socket_path());
- if (!keyboard_server->IsOpen()) {
- return false;
- }
- vnc_server.AddParameter("-keyboard_fd=", keyboard_server);
- // TODO(b/128852363): This should be handled through the wayland mock
- // instead.
- // Additionally it receives the frame updates from a virtual socket
- // instead
- auto frames_server =
- cvd::SharedFD::VsockServer(config.frames_vsock_port(), SOCK_STREAM);
- if (!frames_server->IsOpen()) {
- return false;
- }
- vnc_server.AddParameter("-frame_server_fd=", frames_server);
+ if (config.vm_manager() == vm_manager::QemuManager::name()) {
+ vnc_server.AddParameter("-write_virtio_input");
+ }
+ // When the ivserver is not enabled, the vnc touch_server needs to serve
+ // on sockets and send input events to whoever connects to it (the VMM).
+ auto touch_server =
+ config.vm_manager() == vm_manager::CrosvmManager::name()
+ ? CreateUnixVncInputServer(config.touch_socket_path())
+ : CreateVsockVncInputServer(config.touch_socket_port());
+ if (!touch_server->IsOpen()) {
+ return false;
+ }
+ vnc_server.AddParameter("-touch_fd=", touch_server);
+
+ auto keyboard_server =
+ config.vm_manager() == vm_manager::CrosvmManager::name()
+ ? CreateUnixVncInputServer(config.keyboard_socket_path())
+ : CreateVsockVncInputServer(config.keyboard_socket_port());
+ if (!keyboard_server->IsOpen()) {
+ return false;
+ }
+ vnc_server.AddParameter("-keyboard_fd=", keyboard_server);
+ // TODO(b/128852363): This should be handled through the wayland mock
+ // instead.
+ // Additionally it receives the frame updates from a virtual socket
+ // instead
+ auto frames_server =
+ cvd::SharedFD::VsockServer(config.frames_vsock_port(), SOCK_STREAM);
+ if (!frames_server->IsOpen()) {
+ return false;
}
+ vnc_server.AddParameter("-frame_server_fd=", frames_server);
process_monitor->StartSubprocess(std::move(vnc_server), callback);
return true;
}
diff --git a/host/frontend/vnc_server/virtual_inputs.cpp b/host/frontend/vnc_server/virtual_inputs.cpp
index e7e37577..31c03282 100644
--- a/host/frontend/vnc_server/virtual_inputs.cpp
+++ b/host/frontend/vnc_server/virtual_inputs.cpp
@@ -19,6 +19,7 @@
#include <linux/input.h>
#include <linux/uinput.h>
+#include <cstdint>
#include <mutex>
#include "keysyms.h"
@@ -34,7 +35,18 @@ DEFINE_int32(touch_fd, -1,
DEFINE_int32(keyboard_fd, -1,
"A fd for a socket where to accept keyboard connections");
+DEFINE_bool(write_virtio_input, false,
+ "Whether to write the virtio_input struct over the socket");
+
namespace {
+// Necessary to define here as the virtio_input.h header is not available
+// in the host glibc.
+struct virtio_input_event {
+ std::uint16_t type;
+ std::uint16_t code;
+ std::int32_t value;
+};
+
void AddKeyMappings(std::map<uint32_t, uint16_t>* key_mapping) {
(*key_mapping)[cvd::xk::AltLeft] = KEY_LEFTALT;
(*key_mapping)[cvd::xk::ControlLeft] = KEY_LEFTCTRL;
@@ -274,7 +286,7 @@ class SocketVirtualInputs : public VirtualInputs {
InitInputEvent(&events[0], EV_KEY, keymapping_[key_code], down);
InitInputEvent(&events[1], EV_SYN, 0, 0);
- SendEvents(keyboard_socket_, events, sizeof(events));
+ SendEvents(keyboard_socket_, events);
}
void PressPowerButton(bool down) override {
@@ -282,7 +294,7 @@ class SocketVirtualInputs : public VirtualInputs {
InitInputEvent(&events[0], EV_KEY, KEY_POWER, down);
InitInputEvent(&events[1], EV_SYN, 0, 0);
- SendEvents(keyboard_socket_, events, sizeof(events));
+ SendEvents(keyboard_socket_, events);
}
void HandlePointerEvent(bool touch_down, int x, int y) override {
@@ -293,11 +305,12 @@ class SocketVirtualInputs : public VirtualInputs {
InitInputEvent(&events[2], EV_KEY, BTN_TOUCH, touch_down);
InitInputEvent(&events[3], EV_SYN, 0, 0);
- SendEvents(touch_socket_, events, sizeof(events));
+ SendEvents(touch_socket_, events);
}
private:
- void SendEvents(cvd::SharedFD socket, void* event_buffer, int byte_count) {
+ template<size_t num_events>
+ void SendEvents(cvd::SharedFD socket, struct input_event (&event_buffer)[num_events]) {
std::lock_guard<std::mutex> lock(socket_mutex_);
if (!socket->IsOpen()) {
// This is unlikely as it would only happen between the start of the vnc
@@ -306,9 +319,25 @@ class SocketVirtualInputs : public VirtualInputs {
// handle it.
return;
}
- auto ret = socket->Write(event_buffer, byte_count);
- if (ret < 0) {
- LOG(ERROR) << "Error sending input event: " << socket->StrError();
+
+ if (FLAGS_write_virtio_input) {
+ struct virtio_input_event virtio_events[num_events];
+ for (size_t i = 0; i < num_events; i++) {
+ virtio_events[i] = (struct virtio_input_event) {
+ .type = event_buffer[i].type,
+ .code = event_buffer[i].code,
+ .value = event_buffer[i].value,
+ };
+ }
+ auto ret = socket->Write(virtio_events, sizeof(virtio_events));
+ if (ret < 0) {
+ LOG(ERROR) << "Error sending input events: " << socket->StrError();
+ }
+ } else {
+ auto ret = socket->Write(event_buffer, sizeof(event_buffer));
+ if (ret < 0) {
+ LOG(ERROR) << "Error sending input events: " << socket->StrError();
+ }
}
}
@@ -320,6 +349,7 @@ class SocketVirtualInputs : public VirtualInputs {
auto keyboard_server = cvd::SharedFD::Dup(FLAGS_keyboard_fd);
close(FLAGS_keyboard_fd);
FLAGS_keyboard_fd = -1;
+ LOG(INFO) << "Input socket host accepting connections...";
while (1) {
cvd::SharedFDSet read_set;
@@ -330,9 +360,11 @@ class SocketVirtualInputs : public VirtualInputs {
std::lock_guard<std::mutex> lock(socket_mutex_);
if (read_set.IsSet(touch_server)) {
touch_socket_ = cvd::SharedFD::Accept(*touch_server);
+ LOG(INFO) << "connected to touch";
}
if (read_set.IsSet(keyboard_server)) {
keyboard_socket_ = cvd::SharedFD::Accept(*keyboard_server);
+ LOG(INFO) << "connected to keyboard";
}
}
}
@@ -346,9 +378,5 @@ class SocketVirtualInputs : public VirtualInputs {
VirtualInputs::VirtualInputs() { AddKeyMappings(&keymapping_); }
VirtualInputs* VirtualInputs::Get() {
- if (vsoc::CuttlefishConfig::Get()->enable_ivserver()) {
- return new VSoCVirtualInputs();
- } else {
- return new SocketVirtualInputs();
- }
+ return new SocketVirtualInputs();
}
diff --git a/host/libs/config/cuttlefish_config.cpp b/host/libs/config/cuttlefish_config.cpp
index 882a951e..17dcb6e5 100644
--- a/host/libs/config/cuttlefish_config.cpp
+++ b/host/libs/config/cuttlefish_config.cpp
@@ -168,6 +168,10 @@ const char* kBootloader = "bootloader";
const char* kUseBootloader = "use_bootloader";
const char* kBootSlot = "boot_slot";
+
+const char* kTouchSocketPort = "touch_socket_port";
+const char* kKeyboardSocketPort = "keyboard_socket_port";
+
} // namespace
namespace vsoc {
@@ -938,6 +942,22 @@ std::string CuttlefishConfig::keyboard_socket_path() const {
return PerInstanceInternalPath("keyboard.sock");
}
+void CuttlefishConfig::set_touch_socket_port(int port) {
+ (*dictionary_)[kTouchSocketPort] = port;
+}
+
+int CuttlefishConfig::touch_socket_port() const {
+ return (*dictionary_)[kTouchSocketPort].asInt();
+}
+
+void CuttlefishConfig::set_keyboard_socket_port(int port) {
+ (*dictionary_)[kKeyboardSocketPort] = port;
+}
+
+int CuttlefishConfig::keyboard_socket_port() const {
+ return (*dictionary_)[kKeyboardSocketPort].asInt();
+}
+
// 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 0fca9f0d..fc479ec7 100644
--- a/host/libs/config/cuttlefish_config.h
+++ b/host/libs/config/cuttlefish_config.h
@@ -356,6 +356,12 @@ class CuttlefishConfig {
std::string touch_socket_path() const;
std::string keyboard_socket_path() const;
+ void set_touch_socket_port(int touch_socket_port);
+ int touch_socket_port() const;
+
+ void set_keyboard_socket_port(int keyboard_socket_port);
+ int keyboard_socket_port() const;
+
private:
std::unique_ptr<Json::Value> dictionary_;
diff --git a/host/libs/config/fetcher_config.cpp b/host/libs/config/fetcher_config.cpp
index d2183514..86e16dcf 100644
--- a/host/libs/config/fetcher_config.cpp
+++ b/host/libs/config/fetcher_config.cpp
@@ -197,4 +197,20 @@ std::map<std::string, CvdFile> FetcherConfig::get_cvd_files() const {
return files;
}
+std::string FetcherConfig::FindCvdFileWithSuffix(const std::string& suffix) const {
+ if (!dictionary_->isMember(kCvdFiles)) {
+ return {};
+ }
+ const auto& json_files = (*dictionary_)[kCvdFiles];
+ for (auto it = json_files.begin(); it != json_files.end(); it++) {
+ auto file = it.key().asString();
+ auto expected_pos = file.size() - suffix.size();
+ if (file.rfind(suffix) == expected_pos) {
+ return file;
+ }
+ }
+ LOG(ERROR) << "Could not find file ending in " << suffix;
+ return "";
+}
+
} // namespace cvd
diff --git a/host/libs/config/fetcher_config.h b/host/libs/config/fetcher_config.h
index 41fd396b..825fbc60 100644
--- a/host/libs/config/fetcher_config.h
+++ b/host/libs/config/fetcher_config.h
@@ -78,6 +78,8 @@ public:
bool add_cvd_file(const CvdFile& file, bool override_entry = false);
std::map<std::string, CvdFile> get_cvd_files() const;
+
+ std::string FindCvdFileWithSuffix(const std::string& suffix) const;
};
} // namespace cvd
diff --git a/host/libs/vm_manager/Android.bp b/host/libs/vm_manager/Android.bp
index 6c638ea1..eadcb123 100644
--- a/host/libs/vm_manager/Android.bp
+++ b/host/libs/vm_manager/Android.bp
@@ -38,8 +38,7 @@ cc_library_host_static {
defaults: ["cuttlefish_host_only"],
}
-cc_prebuilt_binary {
+sh_binary_host {
name: "cf_qemu.sh",
- srcs: ["cf_qemu.sh"],
- defaults: ["cuttlefish_host_only"],
+ src: "cf_qemu.sh",
}
diff --git a/host/libs/vm_manager/cf_qemu.sh b/host/libs/vm_manager/cf_qemu.sh
index 75707eda..969332d6 100755
--- a/host/libs/vm_manager/cf_qemu.sh
+++ b/host/libs/vm_manager/cf_qemu.sh
@@ -61,11 +61,6 @@ default_wifi_tap_name="cvd-wtap-${CUTTLEFISH_INSTANCE}"
qemu_binary=${qemu_binary=/usr/bin/qemu-system-x86_64}
dtc_binary=${dtc_binary:-dtc}
-if [[ -z "${ivshmem_vector_count}" ]]; then
- echo "The required ivshmem_vector_count environment variable is not set" >&2
- exit 1
-fi
-
if [[ "${qemu_binary##*/}" = "qemu-system-aarch64" ]]; then
# On ARM, the early console can be PCI, and ISA is not supported
kernel_console_serial="pci-serial"
@@ -147,8 +142,6 @@ args+=(
-device "${kernel_console_serial},chardev=charserial0,id=serial0"
-chardev "socket,id=charserial1,path=${console_path:-${default_dir}/console},server,nowait"
-device "${kernel_console_serial},chardev=charserial1,id=serial1"
- -chardev "socket,path=${ivshmem_qemu_socket_path:-${default_internal_dir}/ivshmem_socket_qemu},id=ivsocket"
- -device "ivshmem-doorbell,chardev=ivsocket,vectors=${ivshmem_vector_count}"
)
if [[ "${logcat_mode}" == "serial" ]]; then
diff --git a/host/libs/vm_manager/qemu_manager.cpp b/host/libs/vm_manager/qemu_manager.cpp
index 5130afe6..138aac4c 100644
--- a/host/libs/vm_manager/qemu_manager.cpp
+++ b/host/libs/vm_manager/qemu_manager.cpp
@@ -110,9 +110,8 @@ bool QemuManager::ConfigureGpu(vsoc::CuttlefishConfig *config) {
// HALs.
config->add_kernel_cmdline("androidboot.hardware.gralloc=cutf_ashmem");
config->add_kernel_cmdline(
- "androidboot.hardware.hwcomposer=cutf_ivsh_ashmem");
- config->add_kernel_cmdline(
- "androidboot.hardware.egl=swiftshader");
+ "androidboot.hardware.hwcomposer=cutf_cvm_ashmem");
+ config->add_kernel_cmdline("androidboot.hardware.egl=swiftshader");
return true;
}
diff --git a/tests/hidl/hidl_implementation_test.cpp b/tests/hidl/hidl_implementation_test.cpp
index a4782f2b..85a58fe3 100644
--- a/tests/hidl/hidl_implementation_test.cpp
+++ b/tests/hidl/hidl_implementation_test.cpp
@@ -45,6 +45,7 @@ static std::set<std::string> kKnownMissing = {
"android.hardware.camera.device@1.0",
"android.hardware.camera.device@3.5",
"android.hardware.camera.provider@2.5",
+ "android.hardware.cas@1.2",
"android.hardware.cas.native@1.0",
"android.hardware.confirmationui@1.0",
"android.hardware.contexthub@1.0",