• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 ApplyProcessRestarter(const std::string& crosvm_binary, int exit_code);
31   void AddControlSocket(const std::string&, const std::string&);
32 
33   void AddHvcSink();
34   void AddHvcReadOnly(const std::string& output, bool console = false);
35   void AddHvcReadWrite(const std::string& output, const std::string& input);
36 
37   void AddReadOnlyDisk(const std::string& path);
38   void AddReadWriteDisk(const std::string& path);
39 
40   void AddSerialSink();
41   void AddSerialConsoleReadOnly(const std::string& output);
42   void AddSerialConsoleReadWrite(const std::string& output,
43                                  const std::string& input, bool earlycon);
44   // [[deprecated("do not add any more users")]]
45   void AddSerial(const std::string& output, const std::string& input);
46 
47   SharedFD AddTap(const std::string& tap_name);
48   SharedFD AddTap(const std::string& tap_name, const std::string& mac);
49 
50   int HvcNum();
51 
52   Command& Cmd();
53 
54  private:
55   Command command_;
56   int hvc_num_;
57   int serial_num_;
58 };
59 
60 }  // namespace cuttlefish
61