1 // 2 // Copyright (C) 2021 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 #pragma once 17 18 #include <string> 19 #include <utility> 20 21 #include "common/libs/fs/shared_fd.h" 22 #include "common/libs/utils/subprocess.h" 23 24 namespace cuttlefish { 25 26 class CrosvmBuilder { 27 public: 28 CrosvmBuilder(); 29 30 void SetBinary(const std::string&); 31 void AddControlSocket(const std::string&); 32 33 void AddHvcSink(); 34 void AddHvcConsoleReadOnly(const std::string& output); 35 void AddHvcReadOnly(const std::string& output); 36 void AddHvcReadWrite(const std::string& output, const std::string& input); 37 38 void AddSerialSink(); 39 void AddSerialConsoleReadOnly(const std::string& output); 40 void AddSerialConsoleReadWrite(const std::string& output, 41 const std::string& input); 42 // [[deprecated("do not add any more users")]] 43 void AddSerial(const std::string& output, const std::string& input); 44 45 SharedFD AddTap(const std::string& tap_name); 46 47 int HvcNum(); 48 49 Command& Cmd(); 50 51 private: 52 Command command_; 53 int hvc_num_; 54 int serial_num_; 55 }; 56 57 } // namespace cuttlefish 58