Merge "Set up network interfaces when running with crosvm" into cuttlefish-testing
diff --git a/Android.bp b/Android.bp
index d9cbf16..3a596ff 100644
--- a/Android.bp
+++ b/Android.bp
@@ -89,15 +89,11 @@
"common/vsoc/lib/lock_common.cpp",
"common/vsoc/lib/managed_e2e_test_region_layout.cpp",
"common/vsoc/lib/region_view.cpp",
- "common/vsoc/lib/ril_layout.cpp",
- "common/vsoc/lib/ril_region_view.cpp",
"common/vsoc/lib/screen_layout.cpp",
"common/vsoc/lib/screen_region_view.cpp",
"common/vsoc/lib/socket_forward_layout.cpp",
"common/vsoc/lib/socket_forward_region_view.cpp",
"common/vsoc/lib/vsoc_memory.cpp",
- "common/vsoc/lib/wifi_exchange_layout.cpp",
- "common/vsoc/lib/wifi_exchange_view.cpp",
],
header_libs: ["cuttlefish_glog"],
shared_libs: [
diff --git a/common/frontend/socket_vsock_proxy/main.cpp b/common/frontend/socket_vsock_proxy/main.cpp
index a47915b..7f7248a 100644
--- a/common/frontend/socket_vsock_proxy/main.cpp
+++ b/common/frontend/socket_vsock_proxy/main.cpp
@@ -28,12 +28,9 @@
using vsoc::socket_forward::Packet;
-DEFINE_uint32(guest_port, 0,
- "Port on which to forward TCP connections to the guest.");
-#ifdef CUTTLEFISH_HOST
-DEFINE_uint32(host_port, 0, "Ports on which to run a TCP server on the host.");
+DEFINE_uint32(tcp_port, 0, "TCP port (server on host, client on guest)");
+DEFINE_uint32(vsock_port, 0, "vsock port (client on host, server on guest");
DEFINE_uint32(vsock_guest_cid, 0, "Guest identifier");
-#endif
namespace {
// Sends packets, Shutdown(SHUT_WR) on destruction
@@ -139,17 +136,17 @@
#ifdef CUTTLEFISH_HOST
[[noreturn]] void host() {
- LOG(INFO) << "starting server on " << FLAGS_host_port << " for guest port "
- << FLAGS_guest_port;
- auto server = cvd::SharedFD::SocketLocalServer(FLAGS_host_port, SOCK_STREAM);
- CHECK(server->IsOpen()) << "Could not start server on " << FLAGS_host_port;
+ LOG(INFO) << "starting server on " << FLAGS_tcp_port << " for vsock port "
+ << FLAGS_vsock_port;
+ auto server = cvd::SharedFD::SocketLocalServer(FLAGS_tcp_port, SOCK_STREAM);
+ CHECK(server->IsOpen()) << "Could not start server on " << FLAGS_tcp_port;
while (true) {
LOG(INFO) << "waiting for client connection";
auto client_socket = cvd::SharedFD::Accept(*server);
CHECK(client_socket->IsOpen()) << "error creating client socket";
LOG(INFO) << "client socket accepted";
cvd::SharedFD vsock_socket = cvd::SharedFD::VsockClient(
- FLAGS_vsock_guest_cid, FLAGS_guest_port, SOCK_STREAM);
+ FLAGS_vsock_guest_cid, FLAGS_vsock_port, SOCK_STREAM);
if (!vsock_socket->IsOpen()) {
continue;
}
@@ -162,11 +159,11 @@
#else
cvd::SharedFD OpenSocketConnection() {
while (true) {
- auto sock = cvd::SharedFD::SocketLocalClient(FLAGS_guest_port, SOCK_STREAM);
+ auto sock = cvd::SharedFD::SocketLocalClient(FLAGS_tcp_port, SOCK_STREAM);
if (sock->IsOpen()) {
return sock;
}
- LOG(WARNING) << "could not connect on port " << FLAGS_guest_port
+ LOG(WARNING) << "could not connect on port " << FLAGS_tcp_port
<< ". sleeping for 1 second";
sleep(1);
}
@@ -185,16 +182,16 @@
[[noreturn]] void guest() {
LOG(INFO) << "Starting guest mainloop";
- LOG(INFO) << "starting server on " << FLAGS_guest_port;
+ LOG(INFO) << "starting server on " << FLAGS_vsock_port;
cvd::SharedFD vsock;
do {
- vsock = cvd::SharedFD::VsockServer(FLAGS_guest_port, SOCK_STREAM);
+ vsock = cvd::SharedFD::VsockServer(FLAGS_vsock_port, SOCK_STREAM);
if (!vsock->IsOpen() && !socketErrorIsRecoverable(vsock->GetErrno())) {
LOG(ERROR) << "Could not open vsock socket: " << vsock->StrError();
SleepForever();
}
} while (!vsock->IsOpen());
- CHECK(vsock->IsOpen()) << "Could not start server on " << FLAGS_guest_port;
+ CHECK(vsock->IsOpen()) << "Could not start server on " << FLAGS_vsock_port;
while (true) {
LOG(INFO) << "waiting for vsock connection";
auto vsock_client = cvd::SharedFD::Accept(*vsock);
@@ -214,10 +211,10 @@
int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
- CHECK(FLAGS_guest_port != 0) << "Must specify --guest_port flag";
+ CHECK(FLAGS_tcp_port != 0) << "Must specify -tcp_port flag";
+ CHECK(FLAGS_vsock_port != 0) << "Must specify -vsock_port flag";
#ifdef CUTTLEFISH_HOST
- CHECK(FLAGS_vsock_guest_cid != 0) << "Must specify --vsock_guest_cid flag";
- CHECK(FLAGS_host_port != 0) << "Must specify --host_port flag";
+ CHECK(FLAGS_vsock_guest_cid != 0) << "Must specify -vsock_guest_cid flag";
host();
#else
guest();
diff --git a/common/vsoc/lib/ril_layout.cpp b/common/vsoc/lib/ril_layout.cpp
deleted file mode 100644
index 89f45f1..0000000
--- a/common/vsoc/lib/ril_layout.cpp
+++ /dev/null
@@ -1,25 +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 "common/vsoc/shm/ril_layout.h"
-
-namespace vsoc {
-namespace layout {
-namespace ril {
-
-const char* RilLayout::region_name = "ril";
-}
-} // namespace layout
-} // namespace vsoc
diff --git a/common/vsoc/lib/ril_region_view.cpp b/common/vsoc/lib/ril_region_view.cpp
deleted file mode 100644
index ad19ac3..0000000
--- a/common/vsoc/lib/ril_region_view.cpp
+++ /dev/null
@@ -1,35 +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 <arpa/inet.h>
-
-#include <mutex>
-
-#include "common/vsoc/lib/ril_region_view.h"
-
-namespace vsoc {
-namespace ril {
-
-const char* RilRegionView::address_and_prefix_length() const {
- static char buffer[sizeof(data().ipaddr) + 3]{}; // <ipaddr>/dd
- if (buffer[0] == '\0') {
- snprintf(buffer, sizeof(buffer), "%s/%d", data().ipaddr, data().prefixlen);
- }
- return &buffer[0];
-}
-
-} // namespace ril
-} // namespace vsoc
diff --git a/common/vsoc/lib/ril_region_view.h b/common/vsoc/lib/ril_region_view.h
deleted file mode 100644
index 0f7fe84..0000000
--- a/common/vsoc/lib/ril_region_view.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#pragma once
-/*
- * 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 <memory>
-
-#include "common/vsoc/lib/typed_region_view.h"
-#include "common/vsoc/shm/ril_layout.h"
-
-namespace vsoc {
-namespace ril {
-class RilRegionView
- : public vsoc::TypedRegionView<
- RilRegionView,
- vsoc::layout::ril::RilLayout> {
- public:
- // returns a string with '<ip>/<prefix_len>' like this: 192.168.99.2/30
- const char* address_and_prefix_length() const;
-};
-} // namespace ril
-} // namespace vsoc
diff --git a/common/vsoc/lib/vsoc_memory.cpp b/common/vsoc/lib/vsoc_memory.cpp
index 8ce7b24..017ab13 100644
--- a/common/vsoc/lib/vsoc_memory.cpp
+++ b/common/vsoc/lib/vsoc_memory.cpp
@@ -30,10 +30,8 @@
#include "common/vsoc/shm/gralloc_layout.h"
#include "common/vsoc/shm/input_events_layout.h"
#include "common/vsoc/shm/managed_e2e_test_region_layout.h"
-#include "common/vsoc/shm/ril_layout.h"
#include "common/vsoc/shm/screen_layout.h"
#include "common/vsoc/shm/socket_forward_layout.h"
-#include "common/vsoc/shm/wifi_exchange_layout.h"
#include "uapi/vsoc_shm.h"
@@ -174,8 +172,6 @@
/* managed_by */ layout::gralloc::GrallocManagerLayout::region_name),
ValidateAndBuildLayout<layout::socket_forward::SocketForwardLayout>(7,
7),
- ValidateAndBuildLayout<layout::wifi::WifiExchangeLayout>(2, 2),
- ValidateAndBuildLayout<layout::ril::RilLayout>(2, 2),
ValidateAndBuildLayout<layout::e2e_test::E2EPrimaryTestRegionLayout>(1,
1),
ValidateAndBuildLayout<layout::e2e_test::E2ESecondaryTestRegionLayout>(
diff --git a/common/vsoc/lib/wifi_exchange_layout.cpp b/common/vsoc/lib/wifi_exchange_layout.cpp
deleted file mode 100644
index 12e9577..0000000
--- a/common/vsoc/lib/wifi_exchange_layout.cpp
+++ /dev/null
@@ -1,24 +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 "common/vsoc/shm/wifi_exchange_layout.h"
-
-namespace vsoc {
-namespace layout {
-namespace wifi {
-const char* WifiExchangeLayout::region_name = "wifi_exchange";
-} // namespace wifi
-} // namespace layout
-} // namespace vsoc
diff --git a/common/vsoc/lib/wifi_exchange_view.cpp b/common/vsoc/lib/wifi_exchange_view.cpp
deleted file mode 100644
index 23dcd09..0000000
--- a/common/vsoc/lib/wifi_exchange_view.cpp
+++ /dev/null
@@ -1,118 +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 "common/vsoc/lib/wifi_exchange_view.h"
-
-#include <algorithm>
-#include <string>
-
-#include <linux/if_ether.h>
-#include "common/vsoc/lib/circqueue_impl.h"
-
-namespace vsoc {
-namespace wifi {
-
-intptr_t WifiExchangeView::Send(const void* buffer, intptr_t length) {
-#ifdef CUTTLEFISH_HOST
- return data()->guest_ingress.Write(this, static_cast<const char*>(buffer),
- length);
-#else
- return data()->guest_egress.Write(this, static_cast<const char*>(buffer),
- length);
-#endif
-}
-
-intptr_t WifiExchangeView::Recv(void* buffer, intptr_t max_length) {
-#ifdef CUTTLEFISH_HOST
- return data()->guest_egress.Read(this, static_cast<char*>(buffer),
- max_length);
-#else
- return data()->guest_ingress.Read(this, static_cast<char*>(buffer),
- max_length);
-#endif
-}
-
-void WifiExchangeView::SetGuestMACAddress(
- const WifiExchangeView::MacAddress& mac_address) {
- std::copy(std::begin(mac_address),
- std::end(mac_address),
- std::begin(data()->guest_mac_address));
-}
-
-WifiExchangeView::MacAddress WifiExchangeView::GetGuestMACAddress() {
- WifiExchangeView::MacAddress ret;
- std::copy(std::begin(data()->guest_mac_address),
- std::end(data()->guest_mac_address),
- std::begin(ret));
- return ret;
-}
-
-void WifiExchangeView::SetHostMACAddress(
- const WifiExchangeView::MacAddress& mac_address) {
- std::copy(std::begin(mac_address),
- std::end(mac_address),
- std::begin(data()->host_mac_address));
-}
-
-WifiExchangeView::MacAddress WifiExchangeView::GetHostMACAddress() {
- WifiExchangeView::MacAddress ret;
- std::copy(std::begin(data()->host_mac_address),
- std::end(data()->host_mac_address),
- std::begin(ret));
- return ret;
-}
-
-// static
-bool WifiExchangeView::ParseMACAddress(const std::string& s,
- WifiExchangeView::MacAddress* mac) {
- char dummy;
- // This is likely to always be true, but better safe than sorry
- static_assert(std::tuple_size<WifiExchangeView::MacAddress>::value == 6,
- "Mac address size has changed");
- if (sscanf(s.c_str(),
- "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx%c",
- &(*mac)[0],
- &(*mac)[1],
- &(*mac)[2],
- &(*mac)[3],
- &(*mac)[4],
- &(*mac)[5],
- &dummy) != 6) {
- return false;
- }
- return true;
-}
-
-// static
-std::string WifiExchangeView::MacAddressToString(
- const WifiExchangeView::MacAddress& mac) {
- char buffer[3 * mac.size()];
- // This is likely to always be true, but better safe than sorry
- static_assert(std::tuple_size<WifiExchangeView::MacAddress>::value == 6,
- "Mac address size has changed");
- snprintf(buffer,
- sizeof(buffer),
- "%02x:%02x:%02x:%02x:%02x:%02x",
- mac[0],
- mac[1],
- mac[2],
- mac[3],
- mac[4],
- mac[5]);
- return std::string(buffer);
-}
-
-} // namespace wifi
-} // namespace vsoc
diff --git a/common/vsoc/lib/wifi_exchange_view.h b/common/vsoc/lib/wifi_exchange_view.h
deleted file mode 100644
index 5230a8e..0000000
--- a/common/vsoc/lib/wifi_exchange_view.h
+++ /dev/null
@@ -1,61 +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.
- */
-#pragma once
-
-#include <array>
-#include <memory>
-
-#include "common/vsoc/lib/typed_region_view.h"
-#include "common/vsoc/shm/wifi_exchange_layout.h"
-#include "uapi/vsoc_shm.h"
-
-namespace vsoc {
-namespace wifi {
-
-class WifiExchangeView
- : public vsoc::TypedRegionView<
- WifiExchangeView,
- vsoc::layout::wifi::WifiExchangeLayout> {
- public:
- using MacAddress = std::array<
- uint8_t,
- sizeof(vsoc::layout::wifi::WifiExchangeLayout::guest_mac_address)>;
-
- // Send netlink packet to peer.
- // returns true, if operation was successful.
- intptr_t Send(const void* buffer, intptr_t length);
-
- // Receive netlink packet from peer.
- // Returns number of bytes read, or negative value, if failed.
- intptr_t Recv(void* buffer, intptr_t max_length);
-
- // Set guest MAC address.
- void SetGuestMACAddress(const MacAddress& mac_address);
- MacAddress GetGuestMACAddress();
-
- // Set host MAC address.
- void SetHostMACAddress(const MacAddress& mac_address);
- MacAddress GetHostMACAddress();
-
- void SetConfigReady();
- void WaitConfigReady();
-
- static bool ParseMACAddress(const std::string &s, MacAddress *mac);
- static std::string MacAddressToString(const MacAddress& mac);
-};
-
-} // namespace wifi
-} // namespace vsoc
diff --git a/common/vsoc/shm/ril_layout.h b/common/vsoc/shm/ril_layout.h
deleted file mode 100644
index 33348e2..0000000
--- a/common/vsoc/shm/ril_layout.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#pragma once
-/*
- * 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 "common/vsoc/shm/base.h"
-
-// Memory layout for the ril hal region
-
-namespace vsoc {
-namespace layout {
-namespace ril {
-
-struct RilLayout : public RegionLayout {
- static constexpr size_t layout_size = 4 * 16 + 4;
- static const char* region_name;
-
- char ipaddr[16]; // xxx.xxx.xxx.xxx\0 = 16 bytes
- char gateway[16];
- char dns[16];
- char broadcast[16];
- uint32_t prefixlen;
-};
-ASSERT_SHM_COMPATIBLE(RilLayout);
-} // namespace ril
-} // namespace layout
-} // namespace vsoc
diff --git a/common/vsoc/shm/wifi_exchange_layout.h b/common/vsoc/shm/wifi_exchange_layout.h
deleted file mode 100644
index df4659e..0000000
--- a/common/vsoc/shm/wifi_exchange_layout.h
+++ /dev/null
@@ -1,47 +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.
- */
-#pragma once
-
-#include "common/vsoc/shm/base.h"
-#include "common/vsoc/shm/circqueue.h"
-#include "common/vsoc/shm/lock.h"
-
-// Memory layout for wifi packet exchange region.
-namespace vsoc {
-namespace layout {
-namespace wifi {
-
-struct WifiExchangeLayout : public RegionLayout {
- static constexpr size_t layout_size = 2 * CircularPacketQueue<16, 8192>::layout_size + 12;
-
- // Traffic originating from host that proceeds towards guest.
- CircularPacketQueue<16, 8192> guest_ingress;
- // Traffic originating from guest that proceeds towards host.
- CircularPacketQueue<16, 8192> guest_egress;
-
- // Desired MAC address for guest device.
- uint8_t guest_mac_address[6];
- // MAC address of host device.
- uint8_t host_mac_address[6];
-
- static const char* region_name;
-};
-
-ASSERT_SHM_COMPATIBLE(WifiExchangeLayout);
-
-} // namespace wifi
-} // namespace layout
-} // namespace vsoc
diff --git a/guest/hals/camera/EmulatedCamera3.cpp b/guest/hals/camera/EmulatedCamera3.cpp
index cacb15b..8b8921a 100644
--- a/guest/hals/camera/EmulatedCamera3.cpp
+++ b/guest/hals/camera/EmulatedCamera3.cpp
@@ -245,6 +245,7 @@
EmulatedCamera3::flush,
#ifdef CAMERA_DEVICE_API_VERSION_3_6
/*UNUSED: signal_stream_flush*/nullptr,
+ /*UNUSED: is_reconfiguration_required*/nullptr,
#endif
{0}};
diff --git a/host/commands/launch/Android.bp b/host/commands/launch/Android.bp
index c7c0859..49672b1 100644
--- a/host/commands/launch/Android.bp
+++ b/host/commands/launch/Android.bp
@@ -20,7 +20,6 @@
"screen_region_handler.cc",
"ril_config.cc",
"vsoc_shared_memory.cc",
- "wifi_region_handler.cc",
"boot_image_unpacker.cc",
"process_monitor.cc",
"launch.cc",
diff --git a/host/commands/launch/launch.cc b/host/commands/launch/launch.cc
index b3146e6..4bf3db9 100644
--- a/host/commands/launch/launch.cc
+++ b/host/commands/launch/launch.cc
@@ -16,6 +16,7 @@
namespace {
constexpr char kAdbModeTunnel[] = "tunnel";
+constexpr char kAdbModeNativeVsock[] = "native_vsock";
constexpr char kAdbModeVsockTunnel[] = "vsock_tunnel";
constexpr char kAdbModeUsb[] = "usb";
@@ -33,8 +34,14 @@
return std::string{"--host_ports="} + std::to_string(GetHostPort());
}
-std::string GetAdbConnectorPortArg() {
- return std::string{"--ports="} + std::to_string(GetHostPort());
+std::string GetAdbConnectorTcpArg() {
+ return std::string{"--addresses=127.0.0.1:"} + std::to_string(GetHostPort());
+}
+
+std::string GetAdbConnectorVsockArg(const vsoc::CuttlefishConfig& config) {
+ return std::string{"--addresses=vsock:"}
+ + std::to_string(config.vsock_guest_cid())
+ + std::string{":5555"};
}
bool AdbModeEnabled(const vsoc::CuttlefishConfig& config, const char* mode) {
@@ -51,11 +58,16 @@
&& AdbModeEnabled(config, kAdbModeVsockTunnel);
}
-bool AdbConnectorEnabled(const vsoc::CuttlefishConfig& config) {
+bool AdbTcpConnectorEnabled(const vsoc::CuttlefishConfig& config) {
return config.run_adb_connector()
&& (AdbTunnelEnabled(config) || AdbVsockTunnelEnabled(config));
}
+bool AdbVsockConnectorEnabled(const vsoc::CuttlefishConfig& config) {
+ return config.run_adb_connector()
+ && AdbModeEnabled(config, kAdbModeNativeVsock);
+}
+
cvd::OnSocketReadyCb GetOnSubprocessExitCallback(
const vsoc::CuttlefishConfig& config) {
if (config.restart_subprocesses()) {
@@ -173,9 +185,15 @@
void LaunchAdbConnectorIfEnabled(cvd::ProcessMonitor* process_monitor,
const vsoc::CuttlefishConfig& config) {
- if (AdbConnectorEnabled(config)) {
+ if (AdbTcpConnectorEnabled(config)) {
cvd::Command adb_connector(config.adb_connector_binary());
- adb_connector.AddParameter(GetAdbConnectorPortArg());
+ adb_connector.AddParameter(GetAdbConnectorTcpArg());
+ process_monitor->StartSubprocess(std::move(adb_connector),
+ GetOnSubprocessExitCallback(config));
+ }
+ if (AdbVsockConnectorEnabled(config)) {
+ cvd::Command adb_connector(config.adb_connector_binary());
+ adb_connector.AddParameter(GetAdbConnectorVsockArg(config));
process_monitor->StartSubprocess(std::move(adb_connector),
GetOnSubprocessExitCallback(config));
}
@@ -196,9 +214,9 @@
const vsoc::CuttlefishConfig& config) {
if (AdbVsockTunnelEnabled(config)) {
cvd::Command adb_tunnel(config.socket_vsock_proxy_binary());
- adb_tunnel.AddParameter("--guest_port=5555");
+ adb_tunnel.AddParameter("--vsock_port=6520");
adb_tunnel.AddParameter(
- std::string{"--host_port="} + std::to_string(GetHostPort()));
+ std::string{"--tcp_port="} + std::to_string(GetHostPort()));
adb_tunnel.AddParameter(std::string{"--vsock_guest_cid="} +
std::to_string(config.vsock_guest_cid()));
process_monitor->StartSubprocess(std::move(adb_tunnel),
@@ -215,4 +233,4 @@
// Initialize the regions that require so before the VM starts.
PreLaunchInitializers::Initialize(config);
}
-}
\ No newline at end of file
+}
diff --git a/host/commands/launch/pre_launch_initializers.h b/host/commands/launch/pre_launch_initializers.h
index c4788db..79f6eed 100644
--- a/host/commands/launch/pre_launch_initializers.h
+++ b/host/commands/launch/pre_launch_initializers.h
@@ -25,12 +25,10 @@
// To add initializers for more regions declare here, implement in its own
// source file and call from PreLaunchInitializers::Initialize().
void InitializeScreenRegion(const vsoc::CuttlefishConfig& config);
-void InitializeWifiRegion(const vsoc::CuttlefishConfig& config);
class PreLaunchInitializers {
public:
static void Initialize(const vsoc::CuttlefishConfig& config) {
InitializeScreenRegion(config);
- InitializeWifiRegion(config);
}
};
diff --git a/host/commands/launch/wifi_region_handler.cc b/host/commands/launch/wifi_region_handler.cc
deleted file mode 100644
index 5c001b7..0000000
--- a/host/commands/launch/wifi_region_handler.cc
+++ /dev/null
@@ -1,50 +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 <string>
-
-#include <glog/logging.h>
-
-#include "common/vsoc/lib/wifi_exchange_view.h"
-#include "host/commands/launch/pre_launch_initializers.h"
-#include "host/libs/config/cuttlefish_config.h"
-
-using vsoc::wifi::WifiExchangeView;
-
-void InitializeWifiRegion(const vsoc::CuttlefishConfig& config) {
- auto region = WifiExchangeView::GetInstance(vsoc::GetDomain().c_str());
- if (!region) {
- LOG(FATAL) << "Wifi region not found";
- return;
- }
- WifiExchangeView::MacAddress guest_mac, host_mac;
- if (!WifiExchangeView::ParseMACAddress(config.wifi_guest_mac_addr(),
- &guest_mac)) {
- LOG(FATAL) << "Unable to parse guest mac address: "
- << config.wifi_guest_mac_addr();
- return;
- }
- LOG(INFO) << "Setting guest mac to " << config.wifi_guest_mac_addr();
- region->SetGuestMACAddress(guest_mac);
- if (!WifiExchangeView::ParseMACAddress(config.wifi_host_mac_addr(),
- &host_mac)) {
- LOG(FATAL) << "Unable to parse guest mac address: "
- << config.wifi_guest_mac_addr();
- return;
- }
- LOG(INFO) << "Setting host mac to " << config.wifi_host_mac_addr();
- region->SetHostMACAddress(host_mac);
-}
diff --git a/host/frontend/adb_connector/main.cpp b/host/frontend/adb_connector/main.cpp
index 27574ee..e046b3d 100644
--- a/host/frontend/adb_connector/main.cpp
+++ b/host/frontend/adb_connector/main.cpp
@@ -30,18 +30,18 @@
#include "host/libs/config/cuttlefish_config.h"
#include "host/libs/adb_connection_maintainer/adb_connection_maintainer.h"
-DEFINE_string(ports, "", "Comma-separated list of ports to 'adb connect' to");
+DEFINE_string(addresses, "", "Comma-separated list of addresses to 'adb connect' to");
namespace {
-void LaunchConnectionMaintainerThread(int port) {
- std::thread(cvd::EstablishAndMaintainConnection, port).detach();
+void LaunchConnectionMaintainerThread(const std::string& address) {
+ std::thread(cvd::EstablishAndMaintainConnection, address).detach();
}
-std::vector<int> ParsePortsList(std::string ports) {
+std::vector<std::string> ParseAddressList(std::string ports) {
std::replace(ports.begin(), ports.end(), ',', ' ');
std::istringstream port_stream{ports};
- return {std::istream_iterator<int>{port_stream},
- std::istream_iterator<int>{}};
+ return {std::istream_iterator<std::string>{port_stream},
+ std::istream_iterator<std::string>{}};
}
[[noreturn]] void SleepForever() {
@@ -53,10 +53,10 @@
int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
- CHECK(!FLAGS_ports.empty()) << "Must specify --ports flag";
+ CHECK(!FLAGS_addresses.empty()) << "Must specify --addresses flag";
- for (auto port : ParsePortsList(FLAGS_ports)) {
- LaunchConnectionMaintainerThread(port);
+ for (auto address : ParseAddressList(FLAGS_addresses)) {
+ LaunchConnectionMaintainerThread(address);
}
SleepForever();
diff --git a/host/libs/adb_connection_maintainer/adb_connection_maintainer.cpp b/host/libs/adb_connection_maintainer/adb_connection_maintainer.cpp
index 026622e..1336951 100644
--- a/host/libs/adb_connection_maintainer/adb_connection_maintainer.cpp
+++ b/host/libs/adb_connection_maintainer/adb_connection_maintainer.cpp
@@ -36,27 +36,20 @@
return ss.str();
}
-std::string MakeIPAndPort(int port) {
- static constexpr char kLocalHostPrefix[] = "127.0.0.1:";
- return kLocalHostPrefix + std::to_string(port);
-}
-
std::string MakeShellUptimeMessage() {
return MakeMessage("shell,raw:cut -d. -f1 /proc/uptime");
}
-std::string MakeTransportMessage(int port) {
- return MakeMessage("host:transport:" + MakeIPAndPort(port));
+std::string MakeTransportMessage(const std::string& address) {
+ return MakeMessage("host:transport:" + address);
}
-std::string MakeConnectMessage(int port) {
- static constexpr char kConnectPrefix[] = "host:connect:";
- return MakeMessage(kConnectPrefix + MakeIPAndPort(port));
+std::string MakeConnectMessage(const std::string& address) {
+ return MakeMessage("host:connect:" + address);
}
-std::string MakeDisconnectMessage(int port) {
- static constexpr char kDisonnectPrefix[] = "host:disconnect:";
- return MakeMessage(kDisonnectPrefix + MakeIPAndPort(port));
+std::string MakeDisconnectMessage(const std::string& address) {
+ return MakeMessage("host:connect:" + address);
}
// returns true if successfully sent the whole message
@@ -116,10 +109,12 @@
return AdbSendMessage(sock, message);
}
-bool AdbConnect(int port) { return AdbSendMessage(MakeConnectMessage(port)); }
+bool AdbConnect(const std::string& address) {
+ return AdbSendMessage(MakeConnectMessage(address));
+}
-bool AdbDisconnect(int port) {
- return AdbSendMessage(MakeDisconnectMessage(port));
+bool AdbDisconnect(const std::string& address) {
+ return AdbSendMessage(MakeDisconnectMessage(address));
}
bool IsInteger(const std::string& str) {
@@ -173,22 +168,22 @@
// seconds is much larger than seems necessary so we should be more than okay.
static constexpr int kAdbCommandGapTime = 5;
-void EstablishConnection(int port) {
- LOG(INFO) << "Attempting to connect to device on port " << port;
- while (!AdbConnect(port)) {
+void EstablishConnection(const std::string& address) {
+ LOG(INFO) << "Attempting to connect to device with address " << address;
+ while (!AdbConnect(address)) {
sleep(kAdbCommandGapTime);
}
- LOG(INFO) << "adb connect message for " << port << " successfully sent";
+ LOG(INFO) << "adb connect message for " << address << " successfully sent";
sleep(kAdbCommandGapTime);
}
-void WaitForAdbDisconnection(int port) {
+void WaitForAdbDisconnection(const std::string& address) {
// adb daemon doesn't seem to handle quick, successive messages well. The
// sleeps stabilize the communication.
- LOG(INFO) << "Watching for disconnect on port " << port;
+ LOG(INFO) << "Watching for disconnect on " << address;
while (true) {
auto sock = cvd::SharedFD::SocketLocalClient(kAdbDaemonPort, SOCK_STREAM);
- if (!AdbSendMessage(sock, MakeTransportMessage(port))) {
+ if (!AdbSendMessage(sock, MakeTransportMessage(address))) {
LOG(INFO) << "transport message failed, response body: "
<< RecvAdbResponse(sock);
break;
@@ -203,19 +198,19 @@
LOG(INFO) << "couldn't read uptime result";
break;
}
- LOG(DEBUG) << "device on port " << port << " uptime " << uptime;
+ LOG(DEBUG) << "device on " << address << " uptime " << uptime;
sleep(kAdbCommandGapTime);
}
LOG(INFO) << "Sending adb disconnect";
- AdbDisconnect(port);
+ AdbDisconnect(address);
sleep(kAdbCommandGapTime);
}
} // namespace
-[[noreturn]] void cvd::EstablishAndMaintainConnection(int port) {
+[[noreturn]] void cvd::EstablishAndMaintainConnection(std::string address) {
while (true) {
- EstablishConnection(port);
- WaitForAdbDisconnection(port);
+ EstablishConnection(address);
+ WaitForAdbDisconnection(address);
}
}
diff --git a/host/libs/adb_connection_maintainer/adb_connection_maintainer.h b/host/libs/adb_connection_maintainer/adb_connection_maintainer.h
index d3378ce..ca5584f 100644
--- a/host/libs/adb_connection_maintainer/adb_connection_maintainer.h
+++ b/host/libs/adb_connection_maintainer/adb_connection_maintainer.h
@@ -17,6 +17,6 @@
namespace cvd {
-[[noreturn]] void EstablishAndMaintainConnection(int port);
+[[noreturn]] void EstablishAndMaintainConnection(std::string address);
} // namespace cvd
diff --git a/host/libs/config/cuttlefish_config.cpp b/host/libs/config/cuttlefish_config.cpp
index 3376881..b77e03d 100644
--- a/host/libs/config/cuttlefish_config.cpp
+++ b/host/libs/config/cuttlefish_config.cpp
@@ -744,7 +744,7 @@
}
int CuttlefishConfig::blank_data_image_mb() const {
- return (*dictionary_)[kBlankDataImageMb].asBool();
+ return (*dictionary_)[kBlankDataImageMb].asInt();
}
void CuttlefishConfig::set_blank_data_image_mb(int blank_data_image_mb) {