From b778d01cbf7098a1233a6f52654504814908cb4e Mon Sep 17 00:00:00 2001 From: Bailey Kuo Date: Mon, 13 Jul 2026 20:50:12 -0700 Subject: [PATCH] cuttlefish: Wire up Netsim UDS socket (--grpc_uds_path) Inject GrpcSocketCreator into NetsimServerComponent (NetsimServer) and pass --grpc_uds_path=/grpc_socket/NetsimControlServer.sock when launching netsimd. This establishes the Unix Domain Socket communication path required for local gRPC service discovery and control (such as CasimirControlService and ServerReflection) while keeping --netsim_nfc disabled by default (#define CF_DEFAULTS_NETSIM_NFC false). Objective: Verify that adding GrpcSocketCreator and --grpc_uds_path introduces zero regressions to default Cuttlefish behavior and cleanly establishes the Unix Domain Socket when explicitly opted into via --netsim_nfc=true. Phase 1.1: Local Build & Unit/Host Presubmits * Host Compilation: source build/envsetup.sh && lunch aosp_cf_x86_64_phone-trunk_staging-userdebug m run_cvd netsimd Expected Result: Clean build with zero compilation errors or missing component dependencies in fruit. * Cuttlefish Host Test Suite: atest -c cvd_host_tests Expected Result: All host unit tests pass. Test: m run_cvd Bug: 526689247 --- .../host/commands/run_cvd/launch/BUILD.bazel | 1 + .../commands/run_cvd/launch/netsim_server.cpp | 15 ++++++++++++--- .../host/commands/run_cvd/launch/netsim_server.h | 4 +++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/base/cvd/cuttlefish/host/commands/run_cvd/launch/BUILD.bazel b/base/cvd/cuttlefish/host/commands/run_cvd/launch/BUILD.bazel index 2ebc3beceba..5488bd63368 100644 --- a/base/cvd/cuttlefish/host/commands/run_cvd/launch/BUILD.bazel +++ b/base/cvd/cuttlefish/host/commands/run_cvd/launch/BUILD.bazel @@ -299,6 +299,7 @@ cf_cc_library( deps = [ "//cuttlefish/common/libs/fs", "//cuttlefish/common/libs/utils:files", + "//cuttlefish/host/commands/run_cvd/launch:grpc_socket_creator", "//cuttlefish/host/libs/config:config_utils", "//cuttlefish/host/libs/config:cuttlefish_config", "//cuttlefish/host/libs/config:known_paths", diff --git a/base/cvd/cuttlefish/host/commands/run_cvd/launch/netsim_server.cpp b/base/cvd/cuttlefish/host/commands/run_cvd/launch/netsim_server.cpp index 2c538f230b0..b896d9432d8 100644 --- a/base/cvd/cuttlefish/host/commands/run_cvd/launch/netsim_server.cpp +++ b/base/cvd/cuttlefish/host/commands/run_cvd/launch/netsim_server.cpp @@ -26,6 +26,7 @@ #include "cuttlefish/common/libs/fs/shared_fd.h" #include "cuttlefish/common/libs/utils/files.h" +#include "cuttlefish/host/commands/run_cvd/launch/grpc_socket_creator.h" #include "cuttlefish/host/libs/config/config_utils.h" #include "cuttlefish/host/libs/config/cuttlefish_config.h" #include "cuttlefish/host/libs/config/known_paths.h" @@ -94,8 +95,9 @@ class Device { class NetsimServer : public CommandSource { public: INJECT(NetsimServer(const CuttlefishConfig& config, - const CuttlefishConfig::InstanceSpecific& instance)) - : config_(config), instance_(instance) {} + const CuttlefishConfig::InstanceSpecific& instance, + GrpcSocketCreator& grpc_socket)) + : config_(config), instance_(instance), grpc_socket_(grpc_socket) {} // CommandSource Result> Commands() override { @@ -107,6 +109,11 @@ class NetsimServer : public CommandSource { // Port configuration. netsimd.AddParameter("--hci_port=", config_.rootcanal_hci_port()); + if (config_.netsim_radio_enabled(CuttlefishConfig::NetsimRadio::Nfc)) { + netsimd.AddParameter("--grpc_uds_path=", grpc_socket_.CreateGrpcSocket( + "NetsimControlServer")); + } + // When no connector is requested, add the instance number if (config_.netsim_connector_instance_num() == config_.netsim_instance_num()) { @@ -229,12 +236,14 @@ class NetsimServer : public CommandSource { std::vector devices_; const CuttlefishConfig& config_; const CuttlefishConfig::InstanceSpecific instance_; + GrpcSocketCreator& grpc_socket_; }; } // namespace fruit::Component> + const CuttlefishConfig::InstanceSpecific, + GrpcSocketCreator>> NetsimServerComponent() { return fruit::createComponent() .addMultibinding() diff --git a/base/cvd/cuttlefish/host/commands/run_cvd/launch/netsim_server.h b/base/cvd/cuttlefish/host/commands/run_cvd/launch/netsim_server.h index 65c0640ffcd..9dcf3e4a54b 100644 --- a/base/cvd/cuttlefish/host/commands/run_cvd/launch/netsim_server.h +++ b/base/cvd/cuttlefish/host/commands/run_cvd/launch/netsim_server.h @@ -17,12 +17,14 @@ #include "fruit/fruit.h" +#include "cuttlefish/host/commands/run_cvd/launch/grpc_socket_creator.h" #include "cuttlefish/host/libs/config/cuttlefish_config.h" namespace cuttlefish { fruit::Component> + const CuttlefishConfig::InstanceSpecific, + GrpcSocketCreator>> NetsimServerComponent(); } // namespace cuttlefish