Set up network interfaces when running with crosvm
Bug: 124124441
Test: run locally, verify network interfaces are present
Change-Id: I92faefea13ad36881e7cf910a8b3b7c8dadd8326
diff --git a/host/libs/vm_manager/crosvm_manager.cpp b/host/libs/vm_manager/crosvm_manager.cpp
index ba09257..06d881e 100644
--- a/host/libs/vm_manager/crosvm_manager.cpp
+++ b/host/libs/vm_manager/crosvm_manager.cpp
@@ -21,6 +21,7 @@
#include <glog/logging.h>
+#include "common/libs/utils/network.h"
#include "common/libs/utils/subprocess.h"
#include "host/libs/config/cuttlefish_config.h"
#include "host/libs/vm_manager/qemu_manager.h"
@@ -38,6 +39,16 @@
SOCK_STREAM);
}
+void AddTapFdParameter(cvd::Command* crosvm_cmd, const std::string& tap_name) {
+ auto tap_fd = cvd::OpenTapInterface(tap_name);
+ if (tap_fd->IsOpen()) {
+ crosvm_cmd->AddParameter("--tap-fd=", tap_fd);
+ } else {
+ LOG(ERROR) << "Unable to connect to " << tap_name << ": "
+ << tap_fd->StrError();
+ }
+}
+
} // namespace
const std::string CrosvmManager::name() { return "crosvm"; }
@@ -73,6 +84,9 @@
command.AddParameter("--socket=", GetControlSocketPath(config_));
command.AddParameter("--android-fstab=", config_->gsi_fstab_path());
+ AddTapFdParameter(&command, config_->wifi_tap_name());
+ AddTapFdParameter(&command, config_->mobile_tap_name());
+
// TODO remove this (use crosvm's seccomp files)
command.AddParameter("--disable-sandbox");