Merge "Minimal change to set ro.boot.hardware.egl=swiftshader" into cuttlefish-testing
diff --git a/Android.bp b/Android.bp
index a604f8c..4e19401 100644
--- a/Android.bp
+++ b/Android.bp
@@ -26,6 +26,13 @@
host_supported: true,
}
+cc_library_headers {
+ name: "cuttlefish_common_headers_product",
+ product_specific: true,
+ export_include_dirs: ["."],
+ host_supported: true,
+}
+
// TODO(b/67435044) Update the include paths and remove this
cc_library_headers {
name: "cuttlefish_glog",
@@ -34,6 +41,14 @@
host_supported: true,
}
+// TODO(b/67435044) Update the include paths and remove this
+cc_library_headers {
+ name: "cuttlefish_glog_product",
+ product_specific: true,
+ export_include_dirs: ["common/libs"],
+ host_supported: true,
+}
+
cc_defaults {
name: "cuttlefish_base",
gnu_extensions: false,
@@ -58,6 +73,29 @@
}
cc_defaults {
+ name: "cuttlefish_guest_product_only",
+ product_specific: true,
+ gnu_extensions: false,
+ header_libs: [
+ "cuttlefish_common_headers_product",
+ "cuttlefish_kernel_headers_product",
+ "cuttlefish_shared_config_product",
+ ],
+ target: {
+ host: {
+ host_ldlibs: ["-lrt"],
+ cflags: ["-DCUTTLEFISH_HOST"],
+ compile_multilib: "64",
+ },
+ // We don't need Darwin host-side builds
+ darwin: {
+ enabled: false,
+ },
+ },
+ cflags: ["-Werror", "-Wall"],
+}
+
+cc_defaults {
name: "cuttlefish_guest_only",
defaults: ["cuttlefish_base"],
}
diff --git a/common/libs/auto_resources/Android.bp b/common/libs/auto_resources/Android.bp
index 2c575ce..d3de52b 100644
--- a/common/libs/auto_resources/Android.bp
+++ b/common/libs/auto_resources/Android.bp
@@ -21,6 +21,14 @@
defaults: ["cuttlefish_host_and_guest"],
}
+cc_library_static {
+ name: "cuttlefish_auto_resources_static",
+ srcs: [
+ "auto_resources.cpp",
+ ],
+ defaults: ["cuttlefish_guest_product_only"],
+}
+
cc_test_host {
name: "auto_free_buffer_test",
srcs: [
diff --git a/common/libs/fs/Android.bp b/common/libs/fs/Android.bp
index 1522c50..9255b4f 100644
--- a/common/libs/fs/Android.bp
+++ b/common/libs/fs/Android.bp
@@ -26,3 +26,20 @@
],
defaults: ["cuttlefish_host_and_guest"],
}
+
+cc_library_static {
+ name: "libcuttlefish_fs_static",
+ static_libs: [
+ "cuttlefish_auto_resources_static",
+ ],
+ srcs: [
+ "gce_fs.cpp",
+ "shared_fd.cpp",
+ ],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ ],
+ stl: "libc++_static",
+ defaults: ["cuttlefish_guest_product_only"],
+}
diff --git a/guest/Android.bp b/guest/Android.bp
index ba07c2e..6b2406c 100644
--- a/guest/Android.bp
+++ b/guest/Android.bp
@@ -15,6 +15,7 @@
subdirs = [
"commands",
- "hals/health",
- "hals/hwcomposer",
+ "hals",
+ "monitoring",
+ "vsoc/lib",
]
diff --git a/guest/commands/Android.bp b/guest/commands/Android.bp
index 5c7c3c2..df15067 100644
--- a/guest/commands/Android.bp
+++ b/guest/commands/Android.bp
@@ -15,4 +15,8 @@
subdirs = [
"vsock_logcat",
+ "ip_link_add",
+ "usbforward",
+ "vport_trigger",
+ "vsoc_input_service",
]
diff --git a/guest/commands/ip_link_add/Android.bp b/guest/commands/ip_link_add/Android.bp
new file mode 100644
index 0000000..d84a5d1
--- /dev/null
+++ b/guest/commands/ip_link_add/Android.bp
@@ -0,0 +1,27 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+cc_binary {
+ name: "ip_link_add",
+ srcs: [
+ "main.cpp",
+ ],
+ shared_libs: [
+ "cuttlefish_net",
+ "cuttlefish_auto_resources",
+ ],
+ defaults: ["cuttlefish_guest_only"]
+}
diff --git a/guest/commands/ip_link_add/Android.mk b/guest/commands/ip_link_add/Android.mk
deleted file mode 100644
index 993dea6..0000000
--- a/guest/commands/ip_link_add/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (C) 2018 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := ip_link_add
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := main.cpp
-LOCAL_SHARED_LIBRARIES := cuttlefish_net cuttlefish_auto_resources
-LOCAL_C_INCLUDES := device/google/cuttlefish_common
-LOCAL_MULTILIB := first
-LOCAL_VENDOR_MODULE := true
-
-include $(BUILD_EXECUTABLE)
diff --git a/guest/commands/usbforward/Android.bp b/guest/commands/usbforward/Android.bp
new file mode 100644
index 0000000..a639567
--- /dev/null
+++ b/guest/commands/usbforward/Android.bp
@@ -0,0 +1,35 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+cc_binary {
+ name: "usbforward",
+ srcs: [
+ "main.cpp",
+ "usb_server.cpp",
+ "transport_request.cpp",
+ ],
+ shared_libs: [
+ "cuttlefish_auto_resources",
+ "libcuttlefish_fs",
+ "libusb",
+ "libbase",
+ "liblog",
+ ],
+ cflags: [
+ "-DLOG_TAG=\"UsbForward\"",
+ ],
+ defaults: ["cuttlefish_guest_only"]
+}
diff --git a/guest/commands/usbforward/Android.mk b/guest/commands/usbforward/Android.mk
deleted file mode 100644
index c8d219d..0000000
--- a/guest/commands/usbforward/Android.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright (C) 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_MODULE := usbforward
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := \
- main.cpp \
- usb_server.cpp \
- transport_request.cpp
-
-LOCAL_C_INCLUDES := \
- device/google/cuttlefish_common \
- device/google/cuttlefish_kernel
-
-LOCAL_HEADER_LIBRARIES := \
- libcutils_headers
-
-LOCAL_SHARED_LIBRARIES := \
- cuttlefish_auto_resources \
- libcuttlefish_fs \
- libusb \
- libbase \
- liblog
-
-LOCAL_CFLAGS += -DLOG_TAG=\"UsbForward\"
-
-LOCAL_MULTILIB := first
-LOCAL_VENDOR_MODULE := true
-include $(BUILD_EXECUTABLE)
-
diff --git a/guest/commands/usbforward/usb_server.cpp b/guest/commands/usbforward/usb_server.cpp
index 8c72137..e8f5525 100644
--- a/guest/commands/usbforward/usb_server.cpp
+++ b/guest/commands/usbforward/usb_server.cpp
@@ -276,7 +276,7 @@
}
int USBServer::HandleDeviceEvent(libusb_context*, libusb_device*,
- libusb_hotplug_event event, void* self_raw) {
+ libusb_hotplug_event, void* self_raw) {
auto self = reinterpret_cast<USBServer*>(self_raw);
int64_t dummy = 1;
self->device_event_fd_->Write(&dummy, sizeof(dummy));
diff --git a/guest/commands/vport_trigger/Android.bp b/guest/commands/vport_trigger/Android.bp
new file mode 100644
index 0000000..621b9c5
--- /dev/null
+++ b/guest/commands/vport_trigger/Android.bp
@@ -0,0 +1,26 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+cc_binary {
+ name: "vport_trigger",
+ srcs: [
+ "main.cpp",
+ ],
+ shared_libs: [
+ "libcutils",
+ ],
+ defaults: ["cuttlefish_guest_only"]
+}
diff --git a/guest/commands/vport_trigger/Android.mk b/guest/commands/vport_trigger/Android.mk
deleted file mode 100644
index e994ce9..0000000
--- a/guest/commands/vport_trigger/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (C) 2018 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := vport_trigger
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := main.cpp
-LOCAL_SHARED_LIBRARIES := libcutils
-LOCAL_MULTILIB := first
-LOCAL_VENDOR_MODULE := true
-
-include $(BUILD_EXECUTABLE)
diff --git a/guest/commands/vsoc_input_service/Android.bp b/guest/commands/vsoc_input_service/Android.bp
new file mode 100644
index 0000000..76aae19
--- /dev/null
+++ b/guest/commands/vsoc_input_service/Android.bp
@@ -0,0 +1,35 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+cc_binary {
+ name: "vsoc_input_service",
+ srcs: [
+ "main.cpp",
+ "virtual_device_base.cpp",
+ "virtual_power_button.cpp",
+ "virtual_keyboard.cpp",
+ "virtual_touchscreen.cpp",
+ "vsoc_input_service.cpp",
+ ],
+ shared_libs: [
+ "cuttlefish_auto_resources",
+ "libcuttlefish_fs",
+ "libbase",
+ "liblog",
+ "vsoc_lib",
+ ],
+ defaults: ["cuttlefish_guest_only"]
+}
diff --git a/guest/commands/vsoc_input_service/Android.mk b/guest/commands/vsoc_input_service/Android.mk
deleted file mode 100644
index 2256ba5..0000000
--- a/guest/commands/vsoc_input_service/Android.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright (C) 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_MODULE := vsoc_input_service
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := \
- virtual_device_base.cpp \
- virtual_power_button.cpp \
- virtual_keyboard.cpp \
- virtual_touchscreen.cpp \
- vsoc_input_service.cpp \
- main.cpp
-
-LOCAL_C_INCLUDES := \
- device/google/cuttlefish_common \
- device/google/cuttlefish_kernel
-
-LOCAL_SHARED_LIBRARIES := \
- cuttlefish_auto_resources \
- libcuttlefish_fs \
- libbase \
- liblog \
- vsoc_lib
-
-LOCAL_CFLAGS += -DLOG_TAG=\"VSoCInputService\" \
- -Wall -Werror
-
-LOCAL_MULTILIB := first
-LOCAL_VENDOR_MODULE := true
-include $(BUILD_EXECUTABLE)
diff --git a/guest/hals/Android.bp b/guest/hals/Android.bp
new file mode 100644
index 0000000..003b3b8
--- /dev/null
+++ b/guest/hals/Android.bp
@@ -0,0 +1,21 @@
+//
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+subdirs = [
+ "gps",
+ "health",
+ "hwcomposer",
+ "power",
+]
diff --git a/guest/hals/gps/Android.bp b/guest/hals/gps/Android.bp
new file mode 100644
index 0000000..22c5998
--- /dev/null
+++ b/guest/hals/gps/Android.bp
@@ -0,0 +1,34 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// HAL module implemenation, not prelinked and stored in
+// hw/<LIGHTS_HARDWARE_MODULE_ID>.<ro.hardware>.so
+cc_library_shared {
+ name: "gps.cutf",
+ relative_install_path: "hw",
+ srcs: [
+ "gps_vsoc.cpp",
+ "gps_thread.cpp",
+ ],
+ shared_libs: [
+ "liblog",
+ "libcutils",
+ ],
+ header_libs: ["libhardware_headers"],
+ cflags: [
+ "-Wno-missing-field-initializers",
+ "-DLOG_TAG=\"VSoCGPS\"",
+ ],
+ defaults: ["cuttlefish_guest_only"],
+}
diff --git a/guest/hals/gps/Android.mk b/guest/hals/gps/Android.mk
deleted file mode 100644
index 9443980..0000000
--- a/guest/hals/gps/Android.mk
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright (C) 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-# HAL module implemenation, not prelinked and stored in
-# hw/<LIGHTS_HARDWARE_MODULE_ID>.<ro.hardware>.so
-include $(CLEAR_VARS)
-
-ifeq (0, $(shell test $(PLATFORM_SDK_VERSION) -ge 21; echo $$?))
-LOCAL_MODULE_RELATIVE_PATH := hw
-else
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
-endif
-LOCAL_MULTILIB := first
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SHARED_LIBRARIES := liblog libcutils
-LOCAL_SRC_FILES := gps_vsoc.cpp gps_thread.cpp
-LOCAL_MODULE := gps.cutf
-LOCAL_C_INCLUDES := device/google/cuttlefish_common
-
-LOCAL_HEADER_LIBRARIES := \
- libhardware_headers
-
-LOCAL_CFLAGS := \
- -Wall -Werror -Wno-missing-field-initializers \
- -DLOG_TAG=\"VSoCGPS\" \
- $(VSOC_VERSION_CFLAGS)
-LOCAL_VENDOR_MODULE := true
-
-include $(BUILD_SHARED_LIBRARY)
-
diff --git a/guest/hals/power/Android.bp b/guest/hals/power/Android.bp
new file mode 100644
index 0000000..ae62b68
--- /dev/null
+++ b/guest/hals/power/Android.bp
@@ -0,0 +1,30 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// HAL module implementation stored in
+// hw/<POWERS_HARDWARE_MODULE_ID>.<ro.hardware>.so
+cc_library_shared {
+ name: "power.cutf",
+ srcs: ["power.c"],
+ relative_install_path: "hw",
+ header_libs: [
+ "libhardware_headers",
+ "libutils_headers",
+ ],
+ shared_libs: [
+ "liblog",
+ "libcutils",
+ ],
+ defaults: ["cuttlefish_guest_only"],
+}
diff --git a/guest/hals/power/Android.mk b/guest/hals/power/Android.mk
deleted file mode 100644
index d73bc0f..0000000
--- a/guest/hals/power/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright (C) 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-# HAL module implementation stored in
-# hw/<POWERS_HARDWARE_MODULE_ID>.<ro.hardware>.so
-include $(CLEAR_VARS)
-
-LOCAL_CFLAGS += $(VSOC_VERSION_CFLAGS)
-
-LOCAL_C_INCLUDES := device/google/cuttlefish_common
-
-ifeq (0, $(shell test $(PLATFORM_SDK_VERSION) -ge 21; echo $$?))
-LOCAL_MODULE_RELATIVE_PATH := hw
-else
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
-endif
-LOCAL_MULTILIB := first
-
-LOCAL_HEADER_LIBRARIES := libhardware_headers libutils_headers
-LOCAL_SHARED_LIBRARIES := liblog libcutils
-LOCAL_SRC_FILES := power.c
-LOCAL_MODULE := power.cutf
-LOCAL_MODULE_TAGS := optional
-LOCAL_VENDOR_MODULE := true
-include $(BUILD_SHARED_LIBRARY)
-
diff --git a/guest/libs/wpa_supplicant_8_lib/Android.mk b/guest/libs/wpa_supplicant_8_lib/Android.mk
deleted file mode 100644
index 95b9662..0000000
--- a/guest/libs/wpa_supplicant_8_lib/Android.mk
+++ /dev/null
@@ -1,80 +0,0 @@
-# Copyright (C) 2016 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-ifeq ($(WPA_SUPPLICANT_VERSION),VER_0_8_X)
-
-ifneq ($(BOARD_WPA_SUPPLICANT_DRIVER),)
- CONFIG_DRIVER_$(BOARD_WPA_SUPPLICANT_DRIVER) := y
-endif
-
-# Use a custom libnl on releases before N
-ifeq (0, $(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?))
-EXTERNAL_VSOC_LIBNL_INCLUDE := external/gce/libnl/include
-else
-EXTERNAL_VSOC_LIBNL_INCLUDE :=
-endif
-
-
-WPA_SUPPL_DIR = external/wpa_supplicant_8
-WPA_SRC_FILE :=
-
-include $(WPA_SUPPL_DIR)/wpa_supplicant/android.config
-
-WPA_SUPPL_DIR_INCLUDE = $(WPA_SUPPL_DIR)/src \
- $(WPA_SUPPL_DIR)/src/common \
- $(WPA_SUPPL_DIR)/src/drivers \
- $(WPA_SUPPL_DIR)/src/l2_packet \
- $(WPA_SUPPL_DIR)/src/utils \
- $(WPA_SUPPL_DIR)/src/wps \
- $(WPA_SUPPL_DIR)/wpa_supplicant \
- $(EXTERNAL_VSOC_LIBNL_INCLUDE)
-
-WPA_SUPPL_DIR_INCLUDE += external/libnl/include
-
-ifdef CONFIG_DRIVER_NL80211
-WPA_SRC_FILE += driver_cmd_nl80211.c
-endif
-
-ifeq ($(TARGET_ARCH),arm)
-# To force sizeof(enum) = 4
-L_CFLAGS += -mabi=aapcs-linux
-endif
-
-ifdef CONFIG_ANDROID_LOG
-L_CFLAGS += -DCONFIG_ANDROID_LOG
-endif
-
-########################
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := lib_driver_cmd_simulated
-LOCAL_VENDOR_MODULE := true
-LOCAL_SHARED_LIBRARIES := libc libcutils
-
-LOCAL_CFLAGS := $(L_CFLAGS) \
- $(VSOC_VERSION_CFLAGS)
-
-LOCAL_SRC_FILES := $(WPA_SRC_FILE)
-
-LOCAL_C_INCLUDES := \
- device/google/cuttlefish_common \
- $(WPA_SUPPL_DIR_INCLUDE)\
-
-include $(BUILD_STATIC_LIBRARY)
-
-########################
-
-endif
diff --git a/guest/libs/wpa_supplicant_8_lib/driver_cmd_nl80211.c b/guest/libs/wpa_supplicant_8_lib/driver_cmd_nl80211.c
deleted file mode 100644
index a2180aa..0000000
--- a/guest/libs/wpa_supplicant_8_lib/driver_cmd_nl80211.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * Driver interaction with extended Linux CFG8021
- */
-
-#include "driver_cmd_nl80211.h"
-
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#if VSOC_PLATFORM_SDK_AFTER(L_MR1)
-// Android M exposes headers more directly.
-#include <netinet/in.h>
-#include <linux/if.h>
-#include <linux/if_ether.h>
-#include "driver_nl80211.h"
-#elif VSOC_PLATFORM_SDK_AFTER(J_MR2)
-// Android versions K and L put structures in hardware_legacy
-#include "hardware_legacy/driver_nl80211.h"
-#else
-// Android version J does not expose structures directly. These structures are
-// manually defined later.
-#include <netinet/in.h>
-#include <linux/if.h>
-#endif
-
-#include "common.h"
-#include "wpa_supplicant_i.h"
-#include "config.h"
-#include "android_drv.h"
-
-
-int wpa_driver_nl80211_driver_cmd(
- void* priv, char* cmd, char* buf, size_t buf_len) {
- struct i802_bss* bss = priv;
- struct wpa_driver_nl80211_data* drv = bss->drv;
- struct ifreq ifr;
- android_wifi_priv_cmd priv_cmd;
- int ret = 0;
-
- D("%s: called", __FUNCTION__);
- if (os_strcasecmp(cmd, "STOP") == 0) {
- linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 0);
- wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STOPPED");
- } else if (os_strcasecmp(cmd, "START") == 0) {
- linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1);
- wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STARTED");
- } else if (os_strcasecmp(cmd, "MACADDR") == 0) {
- u8 macaddr[ETH_ALEN] = {};
-
- ret = linux_get_ifhwaddr(drv->global->ioctl_sock, bss->ifname, macaddr);
- if (!ret)
- ret = os_snprintf(
- buf, buf_len, "Macaddr = " MACSTR "\n", MAC2STR(macaddr));
- } else if (os_strcasecmp(cmd, "RELOAD") == 0) {
- wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "HANGED");
- } else { // Use private command
- return 0;
- }
- return ret;
-}
-
-
-int wpa_driver_set_p2p_noa(void* priv, u8 count, int start, int duration) {
- D("%s: called", __FUNCTION__);
- return 0;
-}
-
-
-int wpa_driver_get_p2p_noa(void* priv, u8* buf, size_t len) {
- D("%s: called", __FUNCTION__);
- return 0;
-}
-
-
-int wpa_driver_set_p2p_ps(void* priv, int legacy_ps, int opp_ps, int ctwindow) {
- D("%s: called", __FUNCTION__);
- return -1;
-}
-
-
-int wpa_driver_set_ap_wps_p2p_ie(
- void* priv, const struct wpabuf* beacon,
- const struct wpabuf* proberesp, const struct wpabuf* assocresp) {
- D("%s: called", __FUNCTION__);
- return 0;
-}
diff --git a/guest/libs/wpa_supplicant_8_lib/driver_cmd_nl80211.h b/guest/libs/wpa_supplicant_8_lib/driver_cmd_nl80211.h
deleted file mode 100644
index 4256664..0000000
--- a/guest/libs/wpa_supplicant_8_lib/driver_cmd_nl80211.h
+++ /dev/null
@@ -1,104 +0,0 @@
-#pragma once
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <guest/libs/platform_support/api_level_fixes.h>
-
-#include <memory.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "common.h"
-#include "linux_ioctl.h"
-#include "wpa_supplicant_i.h"
-#include <linux/if_ether.h>
-
-#define VSOC_WPA_SUPPLICANT_DEBUG 0
-
-#if VSOC_WPA_SUPPLICANT_DEBUG
-# define D(...) ALOGD(__VA_ARGS__)
-#else
-# define D(...) ((void)0)
-#endif
-
-
-typedef struct android_wifi_priv_cmd {
- char* buf;
- int used_len;
- int total_len;
-} android_wifi_priv_cmd;
-
-#if VSOC_PLATFORM_SDK_BEFORE(K)
-
-#include "driver.h"
-
-struct i802_bss {
- struct wpa_driver_nl80211_data* drv;
- struct i802_bss* next;
- int ifindex;
- char ifname[IFNAMSIZ + 1];
- char brname[IFNAMSIZ];
-
- unsigned int beacon_set:1;
- unsigned int added_if_into_bridge:1;
- unsigned int added_bridge:1;
- unsigned int in_deinit:1;
-
- u8 addr[ETH_ALEN];
-
- int freq;
-
- void* ctx;
- struct nl_handle* nl_preq;
- struct nl_handle* nl_mgmt;
- struct nl_cb* nl_cb;
-
- struct nl80211_wiphy_data *wiphy_data;
- struct dl_list wiphy_list;
-};
-
-struct nl80211_global {
- struct dl_list interfaces;
- int if_add_ifindex;
- struct netlink_data *netlink;
- struct nl_cb* nl_cb;
- struct nl_handle* nl;
- int nl80211_id;
- int ioctl_sock; // socket for ioctl() use
-
- struct nl_handle* nl_event;
-};
-
-struct wpa_driver_nl80211_data {
- struct nl80211_global* global;
- struct dl_list list;
- struct dl_list wiphy_list;
- char phyname[32];
- void* ctx;
- int ifindex;
- int if_removed;
- int if_disabled;
- int ignore_if_down_event;
- struct rfkill_data* rfkill;
- struct wpa_driver_capa capa;
- u8* extended_capa;
- u8* extended_capa_mask;
- unsigned int extended_capa_len;
- int has_capability;
- // More internal data follows.
-};
-
-#endif // VSOC_PLATFORM_SDK_AFTER(J)
diff --git a/guest/monitoring/Android.bp b/guest/monitoring/Android.bp
new file mode 100644
index 0000000..a7f69c0
--- /dev/null
+++ b/guest/monitoring/Android.bp
@@ -0,0 +1,19 @@
+//
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+subdirs = [
+ "dumpstate_ext",
+ "tombstone_transmit",
+]
diff --git a/guest/monitoring/dumpstate_ext/Android.bp b/guest/monitoring/dumpstate_ext/Android.bp
new file mode 100644
index 0000000..03f7b9f
--- /dev/null
+++ b/guest/monitoring/dumpstate_ext/Android.bp
@@ -0,0 +1,41 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_binary {
+ name: "android.hardware.dumpstate@1.0-service.cuttlefish",
+ srcs: [
+ "dumpstate_device.cpp",
+ "service.cpp",
+ ],
+ shared_libs: [
+ "android.hardware.dumpstate@1.0",
+ "libbase",
+ "libcutils",
+ "libdumpstateutil",
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ ],
+ cflags: [
+ "-DLOG_TAG=\"VSoC-dumpstate\"",
+ ],
+ relative_install_path: "hw",
+ init_rc: [
+ "android.hardware.dumpstate@1.0-service.cuttlefish.rc",
+ ],
+ defaults: ["cuttlefish_guest_only"]
+}
diff --git a/guest/monitoring/dumpstate_ext/Android.mk b/guest/monitoring/dumpstate_ext/Android.mk
deleted file mode 100644
index d425821..0000000
--- a/guest/monitoring/dumpstate_ext/Android.mk
+++ /dev/null
@@ -1,59 +0,0 @@
-# Copyright (C) 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_C_INCLUDES := \
- device/google/cuttlefish_common
-LOCAL_CFLAGS := $(VSOC_VERSION_CFLAGS) -DLOG_TAG=\"VSoC-dumpstate\"
-LOCAL_SRC_FILES := dumpstate.cpp
-LOCAL_MODULE := libdumpstate.vsoc
-LOCAL_MODULE_TAGS := optional
-LOCAL_SHARED_LIBRARIES := \
- libbase \
- libdumpstateaidl \
- libdumpstateutil \
- libziparchive \
- libz
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := android.hardware.dumpstate@1.0-service.cuttlefish
-LOCAL_INIT_RC := android.hardware.dumpstate@1.0-service.cuttlefish.rc
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_SRC_FILES := \
- dumpstate_device.cpp \
- service.cpp
-LOCAL_CFLAGS := $(VSOC_VERSION_CFLAGS) -DLOG_TAG=\"VSoC-dumpstate\"
-LOCAL_SHARED_LIBRARIES := \
- android.hardware.dumpstate@1.0 \
- libbase \
- libcutils \
- libdumpstateutil \
- libhidlbase \
- libhidltransport \
- libhwbinder \
- liblog \
- libutils
-LOCAL_C_INCLUDES := \
- device/google/cuttlefish_common \
- frameworks/native/cmds/dumpstate
-
-LOCAL_MODULE_TAGS := optional
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_VENDOR_MODULE := true
-include $(BUILD_EXECUTABLE)
diff --git a/guest/monitoring/dumpstate_ext/dumpstate.cpp b/guest/monitoring/dumpstate_ext/dumpstate.cpp
deleted file mode 100644
index 89e820b..0000000
--- a/guest/monitoring/dumpstate_ext/dumpstate.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "guest/libs/platform_support/api_level_fixes.h"
-
-#if VSOC_PLATFORM_SDK_BEFORE(N)
-extern "C" {
-#endif
-#include <dumpstate.h>
-#if VSOC_PLATFORM_SDK_BEFORE(N)
-}
-#endif
-
-void dumpstate_board() { Dumpstate& ds = Dumpstate::GetInstance(); };
diff --git a/guest/monitoring/tombstone_transmit/Android.bp b/guest/monitoring/tombstone_transmit/Android.bp
new file mode 100644
index 0000000..243877e
--- /dev/null
+++ b/guest/monitoring/tombstone_transmit/Android.bp
@@ -0,0 +1,34 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_binary {
+ name: "tombstone_transmit",
+ srcs: [
+ "main.cpp",
+ ],
+ static_libs: [
+ "libcuttlefish_fs_static",
+ "libgflags",
+ "cuttlefish_auto_resources_static",
+ "liblog",
+ "libbase",
+ "libcutils",
+ ],
+ stl: "libc++_static",
+ header_libs: [
+ "cuttlefish_glog_product",
+ ],
+ defaults: ["cuttlefish_guest_product_only"],
+}
diff --git a/guest/monitoring/tombstone_transmit/main.cpp b/guest/monitoring/tombstone_transmit/main.cpp
new file mode 100644
index 0000000..3633612
--- /dev/null
+++ b/guest/monitoring/tombstone_transmit/main.cpp
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android-base/logging.h>
+#include <errno.h>
+#include <log/log.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/inotify.h>
+#include <unistd.h>
+#include <fstream>
+
+#include <cutils/properties.h>
+#include <gflags/gflags.h>
+
+#include "common/libs/fs/shared_fd.h"
+#include "common/libs/utils/subprocess.h"
+
+static const char TOMBSTONE_DIR[] = "/data/tombstones/";
+
+// returns a fd which when read from, provides inotify events when tombstones
+// are created
+static int new_tombstone_create_notifier(void) {
+ int file_create_notification_handle = inotify_init();
+ if (file_create_notification_handle == -1) {
+ ALOGE("%s: inotify_init failure error: '%s' (%d)", __FUNCTION__,
+ strerror(errno), errno);
+ return -1;
+ }
+
+ int watch_descriptor = inotify_add_watch(file_create_notification_handle,
+ TOMBSTONE_DIR, IN_CREATE);
+ if (watch_descriptor == -1) {
+ ALOGE("%s: Could not add watch for '%s', error: '%s' (%d)", __FUNCTION__,
+ TOMBSTONE_DIR, strerror(errno), errno);
+ close(file_create_notification_handle);
+ return -1;
+ }
+
+ return file_create_notification_handle;
+}
+
+#define INOTIFY_MAX_EVENT_SIZE (sizeof(struct inotify_event) + NAME_MAX + 1)
+static std::string get_next_tombstone_path_blocking(int fd) {
+ char event_readout[INOTIFY_MAX_EVENT_SIZE];
+ struct inotify_event *i = (inotify_event*)(event_readout);
+
+ int event_read_out_length = read(fd, event_readout, INOTIFY_MAX_EVENT_SIZE);
+
+ if(event_read_out_length == -1) {
+ ALOGE("%s: Couldn't read out inotify event due to error: '%s' (%d)",
+ __FUNCTION__, strerror(errno), errno);
+ return std::string();
+ }
+
+ // Create event didn't show up for some reason or no file name was present
+ if(event_read_out_length == sizeof(struct inotify_event)) {
+ ALOGE("%s: inotify event didn't contain filename",__FUNCTION__);
+ return std::string();
+ }
+
+ if(!(i->mask & IN_CREATE)) {
+ ALOGE("%s: inotify event didn't pertain to file creation",__FUNCTION__);
+ return std::string();
+ }
+
+ std::string ret_value(TOMBSTONE_DIR);
+ return ret_value + i->name;
+}
+
+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);
+
+ if(FLAGS_port == 0) {
+ LOG(FATAL_WITHOUT_ABORT) << "Port flag is required";
+ while(1) {sleep(1);};
+ }
+
+ int file_create_notification_handle = new_tombstone_create_notifier();
+ if (file_create_notification_handle == -1) {return -1;}
+
+ LOG(INFO) << "tombstone watcher successfully initialized";
+
+ while (true) {
+ std::string ts_path = get_next_tombstone_path_blocking(
+ file_create_notification_handle);
+
+ if(ts_path.empty()) {continue;}
+
+ auto log_fd = cvd::SharedFD::VsockClient(FLAGS_cid, FLAGS_port,
+ SOCK_STREAM);
+
+ std::ifstream ifs(ts_path);
+ 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) {
+ ifs.read(buffer, sizeof(buffer));
+ num_bytes_read += ifs.gcount();
+ log_fd->Write(buffer, ifs.gcount());
+ num_transfers++;
+ }
+
+ if (!log_fd->IsOpen()) {
+ ALOGE("Unable to connect to vsock:%u:%u: %s", FLAGS_cid, FLAGS_port,
+ log_fd->StrError());
+ } else if (!ifs.is_open()) {
+ ALOGE("%s closed in the middle of readout.", ts_path.c_str());
+ } else {
+ LOG(INFO) << num_bytes_read << " chars transferred from " <<
+ ts_path.c_str() << " over " << num_transfers << " "
+ << TOMBSTONE_BUFFER_SIZE << " byte sized transfers";
+ }
+ }
+
+ return 0;
+}
diff --git a/guest/vsoc/lib/Android.bp b/guest/vsoc/lib/Android.bp
new file mode 100644
index 0000000..d534a5d
--- /dev/null
+++ b/guest/vsoc/lib/Android.bp
@@ -0,0 +1,77 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_binary {
+ name: "vsoc_driver_test",
+ srcs: [
+ "vsoc_driver_test.cpp",
+ ],
+ shared_libs: [
+ "vsoc_lib",
+ "cuttlefish_auto_resources",
+ "libcuttlefish_fs",
+ "libbase",
+ ],
+ static_libs: [
+ "libgtest",
+ ],
+ cflags: [
+ "-DGTEST_OS_LINUX_ANDROID",
+ "-DGTEST_HAS_STD_STRING",
+ ],
+ defaults: ["cuttlefish_guest_only"]
+}
+
+cc_binary {
+ name: "vsoc_guest_region_e2e_test",
+ srcs: [
+ "guest_region_e2e_test.cpp",
+ ],
+ shared_libs: [
+ "vsoc_lib",
+ "cuttlefish_auto_resources",
+ "libcuttlefish_fs",
+ "libbase",
+ ],
+ static_libs: [
+ "libgtest",
+ ],
+ cflags: [
+ "-DGTEST_OS_LINUX_ANDROID",
+ "-DGTEST_HAS_STD_STRING",
+ ],
+ defaults: ["cuttlefish_guest_only"]
+}
+
+cc_binary {
+ name: "vsoc_managed_region_e2e_test",
+ srcs: [
+ "managed_region_e2e_test.cpp",
+ ],
+ shared_libs: [
+ "vsoc_lib",
+ "cuttlefish_auto_resources",
+ "libcuttlefish_fs",
+ "libbase",
+ ],
+ static_libs: [
+ "libgtest",
+ ],
+ cflags: [
+ "-DGTEST_OS_LINUX_ANDROID",
+ "-DGTEST_HAS_STD_STRING",
+ ],
+ defaults: ["cuttlefish_guest_only"]
+}
diff --git a/guest/vsoc/lib/Android.mk b/guest/vsoc/lib/Android.mk
deleted file mode 100644
index 73240f4..0000000
--- a/guest/vsoc/lib/Android.mk
+++ /dev/null
@@ -1,87 +0,0 @@
-# Copyright (C) 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := vsoc_driver_test
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := vsoc_driver_test.cpp
-
-LOCAL_C_INCLUDES := \
- device/google/cuttlefish_common \
- device/google/cuttlefish_kernel
-
-LOCAL_CFLAGS += -DGTEST_OS_LINUX_ANDROID -DGTEST_HAS_STD_STRING -Werror -Wall
-
-LOCAL_STATIC_LIBRARIES := \
- libgtest
-
-LOCAL_SHARED_LIBRARIES := \
- vsoc_lib \
- cuttlefish_auto_resources \
- libcuttlefish_fs \
- libbase
-
-LOCAL_MULTILIB := first
-LOCAL_VENDOR_MODULE := true
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := vsoc_guest_region_e2e_test
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := guest_region_e2e_test.cpp
-
-LOCAL_C_INCLUDES := \
- device/google/cuttlefish_common \
- device/google/cuttlefish_kernel
-
-LOCAL_CFLAGS += -DGTEST_OS_LINUX_ANDROID -DGTEST_HAS_STD_STRING -Werror -Wall
-
-LOCAL_STATIC_LIBRARIES := \
- libgtest
-
-LOCAL_SHARED_LIBRARIES := \
- vsoc_lib \
- cuttlefish_auto_resources \
- libcuttlefish_fs \
- libbase
-
-LOCAL_MULTILIB := first
-LOCAL_VENDOR_MODULE := true
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := vsoc_managed_region_e2e_test
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := managed_region_e2e_test.cpp
-
-LOCAL_C_INCLUDES := \
- device/google/cuttlefish_common \
- device/google/cuttlefish_kernel
-
-LOCAL_CFLAGS += -DGTEST_OS_LINUX_ANDROID -DGTEST_HAS_STD_STRING -Werror -Wall
-
-LOCAL_STATIC_LIBRARIES := \
- libgtest
-
-LOCAL_SHARED_LIBRARIES := \
- vsoc_lib \
- cuttlefish_auto_resources \
- libcuttlefish_fs \
- libbase
-
-LOCAL_MULTILIB := first
-LOCAL_VENDOR_MODULE := true
-include $(BUILD_EXECUTABLE)
diff --git a/host/commands/launch/flags.cc b/host/commands/launch/flags.cc
index 9ced63f..510d235 100644
--- a/host/commands/launch/flags.cc
+++ b/host/commands/launch/flags.cc
@@ -199,6 +199,13 @@
"The (vsock) port for the configuration server");
DEFINE_int32(frames_vsock_port, vsoc::GetPerInstanceDefault(5580),
"The vsock port to receive frames from the guest on");
+DEFINE_bool(enable_tombstone_receiver, false, "Enables the tombstone logger on "
+ "both the guest and the host");
+DEFINE_string(tombstone_receiver_binary,
+ vsoc::DefaultHostArtifactsPath("bin/tombstone_receiver"),
+ "Binary for the tombstone server");
+DEFINE_int32(tombstone_receiver_port, vsoc::GetPerInstanceDefault(5630),
+ "The vsock port for tombstones");
namespace {
template<typename S, typename T>
@@ -460,6 +467,19 @@
FLAGS_frames_vsock_port));
}
+ tmp_config_obj.set_enable_tombstone_receiver(FLAGS_enable_tombstone_receiver);
+ tmp_config_obj.set_tombstone_receiver_port(FLAGS_tombstone_receiver_port);
+ tmp_config_obj.set_tombstone_receiver_binary(FLAGS_tombstone_receiver_binary);
+ if (FLAGS_enable_tombstone_receiver) {
+ tmp_config_obj.add_kernel_cmdline("androidboot.tombstone_transmit=1");
+ tmp_config_obj.add_kernel_cmdline(concat("androidboot.vsock_tombstone_port="
+ ,FLAGS_tombstone_receiver_port));
+ // TODO (b/128842613) populate a cid flag to read the host CID during
+ // runtime
+ } else {
+ tmp_config_obj.add_kernel_cmdline("androidboot.tombstone_transmit=0");
+ }
+
tmp_config_obj.set_cuttlefish_env_path(GetCuttlefishEnvPath());
auto config_file = GetConfigFilePath(tmp_config_obj);
diff --git a/host/commands/launch/launch.cc b/host/commands/launch/launch.cc
index 81cd215..02aff9f 100644
--- a/host/commands/launch/launch.cc
+++ b/host/commands/launch/launch.cc
@@ -3,6 +3,7 @@
#include <glog/logging.h>
#include "common/libs/fs/shared_fd.h"
+#include "common/libs/utils/files.h"
#include "common/libs/utils/size_utils.h"
#include "common/vsoc/shm/screen_layout.h"
#include "host/commands/launch/launcher_defs.h"
@@ -185,6 +186,38 @@
GetOnSubprocessExitCallback(config));
}
+void LaunchTombstoneReceiverIfEnabled(const vsoc::CuttlefishConfig& config,
+ cvd::ProcessMonitor* process_monitor) {
+ if (!config.enable_tombstone_receiver()) {
+ return;
+ }
+
+ std::string tombstoneDir = config.PerInstancePath("tombstones");
+ if (!cvd::DirectoryExists(tombstoneDir.c_str())) {
+ LOG(INFO) << "Setting up " << tombstoneDir;
+ if (mkdir(tombstoneDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) <
+ 0) {
+ LOG(ERROR) << "Failed to create tombstone directory: " << tombstoneDir
+ << ". Error: " << errno;
+ exit(LauncherExitCodes::kTombstoneDirCreationError);
+ }
+ }
+
+ auto port = config.tombstone_receiver_port();
+ auto socket = cvd::SharedFD::VsockServer(port, SOCK_STREAM);
+ if (!socket->IsOpen()) {
+ LOG(ERROR) << "Unable to create tombstone server socket: "
+ << socket->StrError();
+ std::exit(LauncherExitCodes::kTombstoneServerError);
+ }
+ cvd::Command cmd(config.tombstone_receiver_binary());
+ cmd.AddParameter("-server_fd=", socket);
+ cmd.AddParameter("-tombstone_dir=", tombstoneDir);
+
+ process_monitor->StartSubprocess(std::move(cmd),
+ GetOnSubprocessExitCallback(config));
+}
+
void LaunchUsbServerIfEnabled(const vsoc::CuttlefishConfig& config,
cvd::ProcessMonitor* process_monitor) {
if (!AdbUsbEnabled(config)) {
diff --git a/host/commands/launch/launch.h b/host/commands/launch/launch.h
index 43b4197..2e23c6f 100644
--- a/host/commands/launch/launch.h
+++ b/host/commands/launch/launch.h
@@ -33,3 +33,5 @@
const vsoc::CuttlefishConfig& config);
void LaunchIvServerIfEnabled(cvd::ProcessMonitor* process_monitor,
const vsoc::CuttlefishConfig& config);
+void LaunchTombstoneReceiverIfEnabled(const vsoc::CuttlefishConfig& config,
+ cvd::ProcessMonitor* process_monitor);
\ No newline at end of file
diff --git a/host/commands/launch/launcher_defs.h b/host/commands/launch/launcher_defs.h
index 26f4145..2bca212 100644
--- a/host/commands/launch/launcher_defs.h
+++ b/host/commands/launch/launcher_defs.h
@@ -41,6 +41,8 @@
kKernelDecompressError = 17,
kLogcatServerError = 18,
kConfigServerError = 19,
+ kTombstoneServerError = 20,
+ kTombstoneDirCreationError = 21,
};
// Actions supported by the launcher server
diff --git a/host/commands/launch/main.cc b/host/commands/launch/main.cc
index 85a8c17..ebede83 100644
--- a/host/commands/launch/main.cc
+++ b/host/commands/launch/main.cc
@@ -428,6 +428,8 @@
LaunchConfigServer(*config, &process_monitor);
+ LaunchTombstoneReceiverIfEnabled(*config, &process_monitor);
+
LaunchUsbServerIfEnabled(*config, &process_monitor);
LaunchIvServerIfEnabled(&process_monitor, *config);
diff --git a/host/commands/tombstone_receiver/Android.bp b/host/commands/tombstone_receiver/Android.bp
new file mode 100644
index 0000000..5f5a5a5
--- /dev/null
+++ b/host/commands/tombstone_receiver/Android.bp
@@ -0,0 +1,37 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_binary_host {
+ name: "tombstone_receiver",
+ srcs: [
+ "main.cpp",
+ ],
+ header_libs: [
+ "cuttlefish_glog",
+ ],
+ shared_libs: [
+ "libbase",
+ "libcuttlefish_fs",
+ "liblog",
+ "libcuttlefish_utils",
+ "cuttlefish_auto_resources",
+ ],
+ static_libs: [
+ "libcuttlefish_host_config",
+ "libgflags",
+ "libjsoncpp",
+ ],
+ defaults: ["cuttlefish_host_only"],
+}
diff --git a/host/commands/tombstone_receiver/main.cpp b/host/commands/tombstone_receiver/main.cpp
new file mode 100644
index 0000000..7bea670
--- /dev/null
+++ b/host/commands/tombstone_receiver/main.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gflags/gflags.h>
+#include <glog/logging.h>
+
+#include <chrono>
+#include <fstream>
+#include <iomanip>
+#include <sstream>
+
+#include "common/libs/fs/shared_fd.h"
+#include "host/libs/config/cuttlefish_config.h"
+
+DEFINE_int32(
+ server_fd, -1,
+ "File descriptor to an already created vsock server. If negative a new "
+ "server will be created at the port specified on the config file");
+DEFINE_string(tombstone_dir, "", "directory to write out tombstones in");
+
+static uint num_tombstones_in_last_second = 0;
+static std::string last_tombstone_name = "";
+
+static std::string next_tombstone_path() {
+ auto in_time_t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
+ std::stringstream ss;
+ ss << FLAGS_tombstone_dir << "/tombstone_" <<
+ std::put_time(std::gmtime(&in_time_t), "%Y-%m-%d-%H%M%S");
+ auto retval = ss.str();
+
+ // Gives tombstones unique names
+ if(retval == last_tombstone_name) {
+ num_tombstones_in_last_second++;
+ retval += "_" + std::to_string(num_tombstones_in_last_second);
+ } else {
+ last_tombstone_name = retval;
+ num_tombstones_in_last_second = 0;
+ }
+
+ LOG(INFO) << "Creating " << retval;
+ return retval;
+}
+
+#define CHUNK_RECV_MAX_LEN (1024)
+int main(int argc, char** argv) {
+ ::android::base::InitLogging(argv, android::base::StderrLogger);
+ google::ParseCommandLineFlags(&argc, &argv, true);
+
+ auto config = vsoc::CuttlefishConfig::Get();
+ cvd::SharedFD server_fd;
+
+ if (FLAGS_server_fd < 0) {
+ unsigned int port = config->tombstone_receiver_port();
+ server_fd = cvd::SharedFD::VsockServer(port, SOCK_STREAM);
+ } else {
+ server_fd = cvd::SharedFD::Dup(FLAGS_server_fd);
+ close(FLAGS_server_fd);
+ }
+
+ CHECK(server_fd->IsOpen()) << "Error creating/inheriting tombstone server: "
+ << server_fd->StrError();
+ LOG(INFO) << "Host is starting server on port "
+ << config->tombstone_receiver_port();
+
+ // Server loop
+ while (true) {
+ auto conn = cvd::SharedFD::Accept(*server_fd);
+ std::ofstream file(next_tombstone_path(),
+ std::ofstream::out | std::ofstream::binary);
+
+ while (file.is_open()) {
+ char buff[CHUNK_RECV_MAX_LEN];
+ auto bytes_read = conn->Read(buff, sizeof(buff));
+ if (bytes_read <= 0) {
+ // reset the other side if it's still connected
+ break;
+ } else {
+ file.write(buff, bytes_read);
+ }
+ }
+ }
+
+ return 0;
+}
diff --git a/host/libs/config/cuttlefish_config.cpp b/host/libs/config/cuttlefish_config.cpp
index 8644972..1f4852b 100644
--- a/host/libs/config/cuttlefish_config.cpp
+++ b/host/libs/config/cuttlefish_config.cpp
@@ -162,6 +162,10 @@
const char* kFramesVsockPort = "frames_vsock_port";
const char* kLogcatReceiverBinary = "logcat_receiver_binary";
const char* kConfigServerBinary = "config_server_binary";
+
+const char* kRunTombstoneReceiver = "enable_tombstone_logger";
+const char* kTombstoneReceiverPort = "tombstone_logger_port";
+const char* kTombstoneReceiverBinary = "tombstone_receiver_binary";
} // namespace
namespace vsoc {
@@ -864,6 +868,30 @@
return (*dictionary_)[kConfigServerBinary].asString();
}
+bool CuttlefishConfig::enable_tombstone_receiver() const {
+ return (*dictionary_)[kRunTombstoneReceiver].asBool();
+}
+
+void CuttlefishConfig::set_enable_tombstone_receiver(bool enable_tombstone_receiver) {
+ (*dictionary_)[kRunTombstoneReceiver] = enable_tombstone_receiver;
+}
+
+std::string CuttlefishConfig::tombstone_receiver_binary() const {
+ return (*dictionary_)[kTombstoneReceiverBinary].asString();
+}
+
+void CuttlefishConfig::set_tombstone_receiver_binary(const std::string& e2e_test_binary) {
+ (*dictionary_)[kTombstoneReceiverBinary] = e2e_test_binary;
+}
+
+void CuttlefishConfig::set_tombstone_receiver_port(int port) {
+ (*dictionary_)[kTombstoneReceiverPort] = port;
+}
+
+int CuttlefishConfig::tombstone_receiver_port() const {
+ return (*dictionary_)[kTombstoneReceiverPort].asInt();
+}
+
bool CuttlefishConfig::enable_ivserver() const {
return hardware_name() == "cutf_ivsh";
}
diff --git a/host/libs/config/cuttlefish_config.h b/host/libs/config/cuttlefish_config.h
index 1dfd112..c52eb94 100644
--- a/host/libs/config/cuttlefish_config.h
+++ b/host/libs/config/cuttlefish_config.h
@@ -320,6 +320,15 @@
void set_frames_vsock_port(int port);
int frames_vsock_port() const;
+ void set_enable_tombstone_receiver(bool enable_tombstone_receiver);
+ bool enable_tombstone_receiver() const;
+
+ void set_tombstone_receiver_binary(const std::string& binary);
+ std::string tombstone_receiver_binary() const;
+
+ void set_tombstone_receiver_port(int port);
+ int tombstone_receiver_port() const;
+
bool enable_ivserver() const;
std::string touch_socket_path() const;
diff --git a/host/libs/vm_manager/cf_qemu.sh b/host/libs/vm_manager/cf_qemu.sh
index e037c3c..a5abd84 100755
--- a/host/libs/vm_manager/cf_qemu.sh
+++ b/host/libs/vm_manager/cf_qemu.sh
@@ -105,9 +105,9 @@
-device "virtio-blk-pci,scsi=off,drive=drive-virtio-disk1,id=virtio-disk1"
-drive "file=${cache_image_path:-${HOME}/cache.img},format=raw,if=none,id=drive-virtio-disk2,aio=threads"
-device "virtio-blk-pci,scsi=off,drive=drive-virtio-disk2,id=virtio-disk2"
- -drive "file=${vendor_image_path:-${HOME}/vendor.img},format=raw,if=none,id=drive-virtio-disk3,aio=threads"
+ -drive "file=${metadata_image_path:-${HOME}/metadata.img},format=raw,if=none,id=drive-virtio-disk3,aio=threads"
-device "virtio-blk-pci,scsi=off,drive=drive-virtio-disk3,id=virtio-disk3"
- -drive "file=${metadata_image_path:-${HOME}/metadata.img},format=raw,if=none,id=drive-virtio-disk4,aio=threads"
+ -drive "file=${vendor_image_path:-${HOME}/vendor.img},format=raw,if=none,id=drive-virtio-disk4,aio=threads"
-device "virtio-blk-pci,scsi=off,drive=drive-virtio-disk4,id=virtio-disk4"
-drive "file=${product_image_path:-${HOME}/product.img},format=raw,if=none,id=drive-virtio-disk5,aio=threads"
-device "virtio-blk-pci,scsi=off,drive=drive-virtio-disk5,id=virtio-disk5"
diff --git a/host/libs/vm_manager/crosvm_manager.cpp b/host/libs/vm_manager/crosvm_manager.cpp
index 5f83f9e..157f7d1 100644
--- a/host/libs/vm_manager/crosvm_manager.cpp
+++ b/host/libs/vm_manager/crosvm_manager.cpp
@@ -102,11 +102,13 @@
command.AddParameter("--rwdisk=", config_->system_image_path());
command.AddParameter("--rwdisk=", config_->data_image_path());
command.AddParameter("--rwdisk=", config_->cache_image_path());
- command.AddParameter("--rwdisk=", config_->vendor_image_path());
command.AddParameter("--rwdisk=", config_->metadata_image_path());
+ command.AddParameter("--rwdisk=", config_->vendor_image_path());
command.AddParameter("--rwdisk=", config_->product_image_path());
command.AddParameter("--socket=", GetControlSocketPath(config_));
- command.AddParameter("--android-fstab=", config_->gsi_fstab_path());
+ 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());