Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 <memory> |
| 19 | #include <string> |
Cody Schuffelen | efadb8d | 2018-08-10 16:10:35 -0700 | [diff] [blame] | 20 | #include <set> |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 21 | |
| 22 | namespace Json { |
| 23 | class Value; |
| 24 | } |
| 25 | |
| 26 | namespace vsoc { |
| 27 | |
Jorge E. Moreira | b8dfb99 | 2018-07-22 20:53:56 -0700 | [diff] [blame] | 28 | constexpr char kDefaultUuidPrefix[] = "699acfc4-c8c4-11e7-882b-5065f31dc1"; |
Cody Schuffelen | f219a16 | 2018-10-11 19:01:57 -0700 | [diff] [blame] | 29 | constexpr char kCuttlefishConfigEnvVarName[] = "CUTTLEFISH_CONFIG_FILE"; |
Ryan Haining | 7338d35 | 2018-10-24 17:41:52 -0700 | [diff] [blame] | 30 | constexpr char kVsocUserPrefix[] = "vsoc-"; |
Jorge E. Moreira | 8dad504 | 2019-10-01 16:04:52 -0700 | [diff] [blame] | 31 | constexpr char kBootStartedMessage[] ="VIRTUAL_DEVICE_BOOT_STARTED"; |
| 32 | constexpr char kBootCompletedMessage[] = "VIRTUAL_DEVICE_BOOT_COMPLETED"; |
| 33 | constexpr char kBootFailedMessage[] = "VIRTUAL_DEVICE_BOOT_FAILED"; |
| 34 | constexpr char kMobileNetworkConnectedMessage[] = |
| 35 | "VIRTUAL_DEVICE_NETWORK_MOBILE_CONNECTED"; |
| 36 | constexpr char kWifiConnectedMessage[] = |
| 37 | "VIRTUAL_DEVICE_NETWORK_WIFI_CONNECTED"; |
Jorge E. Moreira | 1e8e2f1 | 2019-10-07 18:09:49 -0700 | [diff] [blame] | 38 | constexpr char kInternalDirName[] = "internal"; |
| 39 | |
Jorge E. Moreira | b8dfb99 | 2018-07-22 20:53:56 -0700 | [diff] [blame] | 40 | |
Cody Schuffelen | b6fa736 | 2019-05-08 11:58:14 -0700 | [diff] [blame] | 41 | enum class AdbMode { |
Cody Schuffelen | 134ff03 | 2019-11-22 00:25:32 -0800 | [diff] [blame^] | 42 | Tunnel, |
Cody Schuffelen | b6fa736 | 2019-05-08 11:58:14 -0700 | [diff] [blame] | 43 | VsockTunnel, |
| 44 | VsockHalfTunnel, |
| 45 | NativeVsock, |
| 46 | Usb, |
| 47 | Unknown, |
| 48 | }; |
| 49 | |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 50 | // Holds the configuration of the cuttlefish instances. |
| 51 | class CuttlefishConfig { |
| 52 | public: |
Cody Schuffelen | 1fcdbc0 | 2019-10-04 14:02:23 -0700 | [diff] [blame] | 53 | static const CuttlefishConfig* Get(); |
Jorge E. Moreira | 077d300 | 2018-07-20 11:43:05 -0700 | [diff] [blame] | 54 | |
| 55 | CuttlefishConfig(); |
| 56 | ~CuttlefishConfig(); |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 57 | |
| 58 | // Saves the configuration object in a file, it can then be read in other |
| 59 | // processes by passing the --config_file option. |
Jorge E. Moreira | a8142f9 | 2018-06-13 17:33:55 -0700 | [diff] [blame] | 60 | bool SaveToFile(const std::string& file) const; |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 61 | |
| 62 | // Returns the path to a file with the given name in the instance directory.. |
| 63 | std::string PerInstancePath(const char* file_name) const; |
Jorge E. Moreira | 1e8e2f1 | 2019-10-07 18:09:49 -0700 | [diff] [blame] | 64 | std::string PerInstanceInternalPath(const char* file_name) const; |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 65 | |
| 66 | std::string instance_name() const; |
| 67 | |
| 68 | void disable_usb_adb() { |
| 69 | // This seems to be the way usb is being disbled in the launcher |
| 70 | set_usb_v1_socket_name(""); |
| 71 | } |
| 72 | |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 73 | std::string instance_dir() const; |
| 74 | void set_instance_dir(const std::string& instance_dir); |
| 75 | |
Jorge E. Moreira | 1e8e2f1 | 2019-10-07 18:09:49 -0700 | [diff] [blame] | 76 | std::string instance_internal_dir() const; |
| 77 | |
Jorge E. Moreira | 8832283 | 2018-07-22 16:41:01 -0700 | [diff] [blame] | 78 | std::string vm_manager() const; |
| 79 | void set_vm_manager(const std::string& name); |
| 80 | |
Greg Hartman | a3c552d | 2019-03-28 18:20:48 -0700 | [diff] [blame] | 81 | std::string gpu_mode() const; |
| 82 | void set_gpu_mode(const std::string& name); |
| 83 | |
| 84 | std::string wayland_socket() const; |
| 85 | void set_wayland_socket(const std::string& path); |
| 86 | |
Greg Hartman | eb04ac5 | 2019-07-16 16:44:18 -0700 | [diff] [blame] | 87 | std::string x_display() const; |
| 88 | void set_x_display(const std::string& address); |
| 89 | |
Jorge E. Moreira | ba62662 | 2019-01-28 17:47:50 -0800 | [diff] [blame] | 90 | std::string hardware_name() const; |
| 91 | void set_hardware_name(const std::string& name); |
| 92 | |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 93 | std::string serial_number() const; |
| 94 | void set_serial_number(const std::string& serial_number); |
| 95 | |
| 96 | int cpus() const; |
| 97 | void set_cpus(int cpus); |
| 98 | |
| 99 | int memory_mb() const; |
| 100 | void set_memory_mb(int memory_mb); |
| 101 | |
| 102 | int dpi() const; |
| 103 | void set_dpi(int dpi); |
| 104 | |
| 105 | int x_res() const; |
| 106 | void set_x_res(int x_res); |
| 107 | |
| 108 | int y_res() const; |
| 109 | void set_y_res(int y_res); |
| 110 | |
Cody Schuffelen | 5bc697c | 2019-01-28 21:05:29 -0800 | [diff] [blame] | 111 | int num_screen_buffers() const; |
| 112 | void set_num_screen_buffers(int num_screen_buffers); |
| 113 | |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 114 | int refresh_rate_hz() const; |
| 115 | void set_refresh_rate_hz(int refresh_rate_hz); |
| 116 | |
Jorge E. Moreira | 80ddd7f | 2019-02-04 16:30:13 -0800 | [diff] [blame] | 117 | // Returns kernel image extracted from the boot image or the user-provided one |
| 118 | // if given by command line to the launcher. This function should not be used |
| 119 | // to get the kernel image the vmm should boot, GetKernelImageToUse() should |
| 120 | // be used instead. |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 121 | std::string kernel_image_path() const; |
| 122 | void set_kernel_image_path(const std::string& kernel_image_path); |
| 123 | |
Jorge E. Moreira | 80ddd7f | 2019-02-04 16:30:13 -0800 | [diff] [blame] | 124 | bool decompress_kernel() const; |
| 125 | void set_decompress_kernel(bool decompress_kernel); |
| 126 | |
| 127 | // Returns the path to the kernel image that should be given to the vm manager |
| 128 | // to boot, takes into account whether the original image was decompressed or |
| 129 | // not. |
| 130 | std::string GetKernelImageToUse() const { |
| 131 | return decompress_kernel() ? decompressed_kernel_image_path() |
| 132 | : kernel_image_path(); |
| 133 | } |
| 134 | |
| 135 | std::string decompressed_kernel_image_path() const; |
| 136 | void set_decompressed_kernel_image_path(const std::string& path); |
| 137 | |
Cody Schuffelen | e13a78a | 2019-01-29 14:51:26 -0800 | [diff] [blame] | 138 | bool use_unpacked_kernel() const; |
| 139 | void set_use_unpacked_kernel(bool use_unpacked_kernel); |
| 140 | |
Jorge E. Moreira | b2427ba | 2018-08-23 17:11:55 -0700 | [diff] [blame] | 141 | std::set<std::string> kernel_cmdline() const; |
| 142 | void set_kernel_cmdline(const std::set<std::string>& kernel_cmdline); |
| 143 | void add_kernel_cmdline(const std::string& arg); |
| 144 | void add_kernel_cmdline(const std::set<std::string>& kernel_cmdline); |
| 145 | std::string kernel_cmdline_as_string() const; |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 146 | |
Greg Hartman | 91f8142 | 2018-07-09 16:04:49 -0700 | [diff] [blame] | 147 | std::string gdb_flag() const; |
| 148 | void set_gdb_flag(const std::string& gdb); |
| 149 | |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 150 | std::string ramdisk_image_path() const; |
| 151 | void set_ramdisk_image_path(const std::string& ramdisk_image_path); |
| 152 | |
Cody Schuffelen | 9fd9547 | 2019-10-04 13:49:57 -0700 | [diff] [blame] | 153 | std::string initramfs_path() const; |
| 154 | void set_initramfs_path(const std::string& initramfs_path); |
| 155 | |
| 156 | std::string final_ramdisk_path() const; |
| 157 | void set_final_ramdisk_path(const std::string& final_ramdisk_path); |
| 158 | |
Ram Muthiah | 1aa02f8 | 2019-10-22 20:26:28 +0000 | [diff] [blame] | 159 | std::string vendor_ramdisk_image_path() const; |
| 160 | void set_vendor_ramdisk_image_path(const std::string& |
| 161 | vendor_ramdisk_image_path); |
| 162 | |
Cody Schuffelen | 3c99f5b | 2019-06-14 17:26:01 -0700 | [diff] [blame] | 163 | std::vector<std::string> virtual_disk_paths() const; |
| 164 | void set_virtual_disk_paths(const std::vector<std::string>& disk_paths); |
Cody Schuffelen | 88b82d5 | 2019-05-29 14:16:03 -0700 | [diff] [blame] | 165 | |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 166 | std::string mempath() const; |
| 167 | void set_mempath(const std::string& mempath); |
| 168 | |
| 169 | std::string ivshmem_qemu_socket_path() const; |
| 170 | void set_ivshmem_qemu_socket_path( |
| 171 | const std::string& ivshmem_qemu_socket_path); |
| 172 | |
| 173 | std::string ivshmem_client_socket_path() const; |
| 174 | void set_ivshmem_client_socket_path( |
| 175 | const std::string& ivshmem_client_socket_path); |
| 176 | |
| 177 | int ivshmem_vector_count() const; |
| 178 | void set_ivshmem_vector_count(int ivshmem_vector_count); |
| 179 | |
| 180 | // The name of the socket that will be used to forward access to USB gadget. |
| 181 | // This is for V1 of the USB bus. |
| 182 | std::string usb_v1_socket_name() const; |
| 183 | void set_usb_v1_socket_name(const std::string& usb_v1_socket_name); |
| 184 | |
| 185 | int vhci_port() const; |
| 186 | void set_vhci_port(int vhci_port); |
| 187 | |
| 188 | std::string usb_ip_socket_name() const; |
| 189 | void set_usb_ip_socket_name(const std::string& usb_ip_socket_name); |
| 190 | |
Jorge E. Moreira | b1ec435 | 2019-06-04 11:43:08 -0700 | [diff] [blame] | 191 | std::string kernel_log_pipe_name() const; |
| 192 | void set_kernel_log_pipe_name(const std::string& kernel_log_pipe_name); |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 193 | |
Jorge E. Moreira | 7207f4b | 2019-09-25 10:30:29 -0700 | [diff] [blame] | 194 | std::string console_pipe_name() const; |
| 195 | void set_console_pipe_name(const std::string& console_pipe_name); |
| 196 | |
Jorge E. Moreira | 81afca1 | 2018-07-26 16:48:49 -0700 | [diff] [blame] | 197 | bool deprecated_boot_completed() const; |
| 198 | void set_deprecated_boot_completed(bool deprecated_boot_completed); |
| 199 | |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 200 | std::string console_path() const; |
| 201 | void set_console_path(const std::string& console_path); |
| 202 | |
| 203 | std::string logcat_path() const; |
| 204 | void set_logcat_path(const std::string& logcat_path); |
| 205 | |
Cody Schuffelen | 5de4865 | 2019-09-16 19:49:52 +0000 | [diff] [blame] | 206 | std::string logcat_receiver_binary() const; |
| 207 | void set_logcat_receiver_binary(const std::string& binary); |
| 208 | |
Jorge E. Moreira | f1f7cb3 | 2019-04-15 18:44:41 -0700 | [diff] [blame] | 209 | std::string config_server_binary() const; |
| 210 | void set_config_server_binary(const std::string& binary); |
| 211 | |
Jorge E. Moreira | 66f6ec8 | 2018-07-16 16:43:15 -0700 | [diff] [blame] | 212 | std::string launcher_log_path() const; |
| 213 | void set_launcher_log_path(const std::string& launcher_log_path); |
| 214 | |
Jorge E. Moreira | 50a0775 | 2018-07-18 18:49:04 -0700 | [diff] [blame] | 215 | std::string launcher_monitor_socket_path() const; |
| 216 | void set_launcher_monitor_socket_path( |
| 217 | const std::string& launhcer_monitor_path); |
| 218 | |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 219 | std::string mobile_bridge_name() const; |
| 220 | void set_mobile_bridge_name(const std::string& mobile_bridge_name); |
| 221 | |
| 222 | std::string mobile_tap_name() const; |
| 223 | void set_mobile_tap_name(const std::string& mobile_tap_name); |
| 224 | |
Cody Schuffelen | 975175a | 2018-06-14 18:20:02 -0700 | [diff] [blame] | 225 | std::string wifi_tap_name() const; |
| 226 | void set_wifi_tap_name(const std::string& wifi_tap_name); |
| 227 | |
Cody Schuffelen | d946b5f | 2018-12-12 11:54:48 -0800 | [diff] [blame] | 228 | void set_vsock_guest_cid(int vsock_guest_cid); |
| 229 | int vsock_guest_cid() const; |
| 230 | |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 231 | std::string uuid() const; |
| 232 | void set_uuid(const std::string& uuid); |
| 233 | |
Greg Hartman | 6abdbb9 | 2018-05-24 09:49:00 -0700 | [diff] [blame] | 234 | void set_cuttlefish_env_path(const std::string& path); |
| 235 | std::string cuttlefish_env_path() const; |
| 236 | |
Cody Schuffelen | 90b2fb2 | 2019-02-28 18:55:21 -0800 | [diff] [blame] | 237 | void set_adb_mode(const std::set<std::string>& modes); |
Cody Schuffelen | b6fa736 | 2019-05-08 11:58:14 -0700 | [diff] [blame] | 238 | std::set<AdbMode> adb_mode() const; |
Ryan Haining | 4a1abea | 2018-07-10 16:20:19 -0700 | [diff] [blame] | 239 | |
Cody Schuffelen | e0d0c46 | 2019-09-09 14:13:01 -0700 | [diff] [blame] | 240 | void set_host_port(int host_port); |
| 241 | int host_port() const; |
| 242 | |
Ryan Haining | 7338d35 | 2018-10-24 17:41:52 -0700 | [diff] [blame] | 243 | void set_adb_ip_and_port(const std::string& ip_port); |
| 244 | std::string adb_ip_and_port() const; |
| 245 | |
| 246 | std::string adb_device_name() const; |
| 247 | |
Ryan Haining | 6d821ec | 2018-07-27 11:39:09 -0700 | [diff] [blame] | 248 | void set_device_title(const std::string& title); |
| 249 | std::string device_title() const; |
| 250 | |
Greg Hartman | f1f28c5 | 2018-09-20 17:19:19 -0700 | [diff] [blame] | 251 | void set_setupwizard_mode(const std::string& title); |
| 252 | std::string setupwizard_mode() const; |
| 253 | |
Cody Schuffelen | 5898003 | 2018-10-11 17:11:13 -0700 | [diff] [blame] | 254 | void set_qemu_binary(const std::string& qemu_binary); |
| 255 | std::string qemu_binary() const; |
| 256 | |
Jorge E. Moreira | ba62662 | 2019-01-28 17:47:50 -0800 | [diff] [blame] | 257 | void set_crosvm_binary(const std::string& crosvm_binary); |
| 258 | std::string crosvm_binary() const; |
| 259 | |
Jorge E. Moreira | 13cbd98 | 2019-06-06 16:06:34 -0700 | [diff] [blame] | 260 | void set_console_forwarder_binary(const std::string& crosvm_binary); |
| 261 | std::string console_forwarder_binary() const; |
| 262 | |
Cody Schuffelen | 5bc697c | 2019-01-28 21:05:29 -0800 | [diff] [blame] | 263 | void set_ivserver_binary(const std::string& ivserver_binary); |
| 264 | std::string ivserver_binary() const; |
| 265 | |
Cody Schuffelen | 55676ca | 2019-01-28 22:00:05 -0800 | [diff] [blame] | 266 | void set_kernel_log_monitor_binary( |
| 267 | const std::string& kernel_log_monitor_binary); |
| 268 | std::string kernel_log_monitor_binary() const; |
| 269 | |
Cody Schuffelen | 17b3472 | 2019-01-28 22:57:14 -0800 | [diff] [blame] | 270 | void set_enable_vnc_server(bool enable_vnc_server); |
| 271 | bool enable_vnc_server() const; |
| 272 | |
| 273 | void set_vnc_server_port(int vnc_server_port); |
| 274 | int vnc_server_port() const; |
| 275 | |
| 276 | void set_vnc_server_binary(const std::string& vnc_server_binary); |
| 277 | std::string vnc_server_binary() const; |
| 278 | |
Cody Schuffelen | 134ff03 | 2019-11-22 00:25:32 -0800 | [diff] [blame^] | 279 | void set_enable_stream_audio(bool enable_stream_audio); |
| 280 | bool enable_stream_audio() const; |
| 281 | |
| 282 | void set_stream_audio_port(int stream_audio_port); |
| 283 | int stream_audio_port() const; |
| 284 | |
| 285 | void set_stream_audio_binary(const std::string& stream_audio_binary); |
| 286 | std::string stream_audio_binary() const; |
| 287 | |
Cody Schuffelen | d12e0c9 | 2019-01-29 15:44:45 -0800 | [diff] [blame] | 288 | void set_restart_subprocesses(bool restart_subprocesses); |
| 289 | bool restart_subprocesses() const; |
| 290 | |
Cody Schuffelen | 1f08d97 | 2019-01-29 16:21:12 -0800 | [diff] [blame] | 291 | void set_run_adb_connector(bool run_adb_connector); |
| 292 | bool run_adb_connector() const; |
| 293 | |
| 294 | void set_adb_connector_binary(const std::string& adb_connector_binary); |
| 295 | std::string adb_connector_binary() const; |
| 296 | |
| 297 | void set_virtual_usb_manager_binary(const std::string& binary); |
| 298 | std::string virtual_usb_manager_binary() const; |
| 299 | |
| 300 | void set_socket_forward_proxy_binary(const std::string& binary); |
| 301 | std::string socket_forward_proxy_binary() const; |
| 302 | |
| 303 | void set_socket_vsock_proxy_binary(const std::string& binary); |
| 304 | std::string socket_vsock_proxy_binary() const; |
| 305 | |
Cody Schuffelen | 5024973 | 2019-01-29 16:42:55 -0800 | [diff] [blame] | 306 | void set_run_as_daemon(bool run_as_daemon); |
| 307 | bool run_as_daemon() const; |
| 308 | |
Cody Schuffelen | 3a64095 | 2019-01-29 17:14:41 -0800 | [diff] [blame] | 309 | void set_run_e2e_test(bool run_e2e_test); |
| 310 | bool run_e2e_test() const; |
| 311 | |
| 312 | void set_e2e_test_binary(const std::string& e2e_test_binary); |
| 313 | std::string e2e_test_binary() const; |
| 314 | |
Cody Schuffelen | 2b51bab | 2019-01-29 18:14:48 -0800 | [diff] [blame] | 315 | void set_data_policy(const std::string& data_policy); |
| 316 | std::string data_policy() const; |
| 317 | |
| 318 | void set_blank_data_image_mb(int blank_data_image_mb); |
| 319 | int blank_data_image_mb() const; |
| 320 | |
| 321 | void set_blank_data_image_fmt(const std::string& blank_data_image_fmt); |
| 322 | std::string blank_data_image_fmt() const; |
| 323 | |
Cody Schuffelen | 5de4865 | 2019-09-16 19:49:52 +0000 | [diff] [blame] | 324 | void set_logcat_mode(const std::string& mode); |
| 325 | std::string logcat_mode() const; |
| 326 | |
| 327 | void set_logcat_vsock_port(int port); |
| 328 | int logcat_vsock_port() const; |
Jorge E. Moreira | fd10cae | 2019-02-19 15:35:42 -0800 | [diff] [blame] | 329 | |
Jorge E. Moreira | f1f7cb3 | 2019-04-15 18:44:41 -0700 | [diff] [blame] | 330 | void set_config_server_port(int port); |
| 331 | int config_server_port() const; |
| 332 | |
Jorge E. Moreira | c87c2c7 | 2019-03-06 16:12:23 -0800 | [diff] [blame] | 333 | void set_frames_vsock_port(int port); |
| 334 | int frames_vsock_port() const; |
| 335 | |
Ram Muthiah | 792e2ad | 2019-04-19 11:19:46 -0700 | [diff] [blame] | 336 | void set_enable_tombstone_receiver(bool enable_tombstone_receiver); |
| 337 | bool enable_tombstone_receiver() const; |
| 338 | |
| 339 | void set_tombstone_receiver_binary(const std::string& binary); |
| 340 | std::string tombstone_receiver_binary() const; |
| 341 | |
| 342 | void set_tombstone_receiver_port(int port); |
| 343 | int tombstone_receiver_port() const; |
| 344 | |
Cody Schuffelen | 1300f12 | 2019-05-28 18:24:34 -0700 | [diff] [blame] | 345 | void set_use_bootloader(bool use_bootloader); |
| 346 | bool use_bootloader() const; |
| 347 | |
| 348 | void set_bootloader(const std::string& bootloader_path); |
| 349 | std::string bootloader() const; |
| 350 | |
David Anderson | 637bfd6 | 2019-09-26 13:23:21 -0700 | [diff] [blame] | 351 | void set_boot_slot(const std::string& boot_slot); |
| 352 | std::string boot_slot() const; |
| 353 | |
Jorge E. Moreira | f4b202b | 2019-02-05 17:51:06 -0800 | [diff] [blame] | 354 | bool enable_ivserver() const; |
| 355 | |
Jorge E. Moreira | c87c2c7 | 2019-03-06 16:12:23 -0800 | [diff] [blame] | 356 | std::string touch_socket_path() const; |
| 357 | std::string keyboard_socket_path() const; |
| 358 | |
Cody Schuffelen | 038d4d9 | 2019-11-04 15:09:03 -0800 | [diff] [blame] | 359 | void set_touch_socket_port(int touch_socket_port); |
| 360 | int touch_socket_port() const; |
| 361 | |
| 362 | void set_keyboard_socket_port(int keyboard_socket_port); |
| 363 | int keyboard_socket_port() const; |
| 364 | |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 365 | private: |
| 366 | std::unique_ptr<Json::Value> dictionary_; |
| 367 | |
Ryan Haining | d3f185d | 2018-07-19 12:11:47 -0700 | [diff] [blame] | 368 | void SetPath(const std::string& key, const std::string& path); |
Jorge E. Moreira | 077d300 | 2018-07-20 11:43:05 -0700 | [diff] [blame] | 369 | bool LoadFromFile(const char* file); |
| 370 | static CuttlefishConfig* BuildConfigImpl(); |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 371 | |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 372 | CuttlefishConfig(const CuttlefishConfig&) = delete; |
| 373 | CuttlefishConfig& operator=(const CuttlefishConfig&) = delete; |
| 374 | }; |
| 375 | |
| 376 | // Returns the instance number as obtained from the CUTTLEFISH_INSTANCE |
| 377 | // environment variable or the username. |
| 378 | int GetInstance(); |
Jorge E. Moreira | 015c000 | 2018-07-19 11:01:16 -0700 | [diff] [blame] | 379 | // Returns a path where the launhcer puts a link to the config file which makes |
| 380 | // it easily discoverable regardless of what vm manager is in use |
| 381 | std::string GetGlobalConfigFileLink(); |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 382 | |
| 383 | // Returns the path to the ivserver's client socket. |
| 384 | std::string GetDomain(); |
| 385 | |
| 386 | // These functions modify a given base value to make it different accross |
| 387 | // different instances by appending the instance id in case of strings or adding |
| 388 | // it in case of integers. |
| 389 | std::string GetPerInstanceDefault(const char* prefix); |
| 390 | int GetPerInstanceDefault(int base); |
| 391 | |
| 392 | std::string GetDefaultPerInstanceDir(); |
Jorge E. Moreira | 077d300 | 2018-07-20 11:43:05 -0700 | [diff] [blame] | 393 | std::string GetDefaultMempath(); |
Cody Schuffelen | d946b5f | 2018-12-12 11:54:48 -0800 | [diff] [blame] | 394 | int GetDefaultPerInstanceVsockCid(); |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 395 | |
Jorge E. Moreira | a8142f9 | 2018-06-13 17:33:55 -0700 | [diff] [blame] | 396 | std::string DefaultHostArtifactsPath(const std::string& file); |
| 397 | std::string DefaultGuestImagePath(const std::string& file); |
Greg Hartman | a3c552d | 2019-03-28 18:20:48 -0700 | [diff] [blame] | 398 | std::string DefaultEnvironmentPath(const char* environment_key, |
| 399 | const char* default_value, |
| 400 | const char* path); |
Jorge E. Moreira | a8142f9 | 2018-06-13 17:33:55 -0700 | [diff] [blame] | 401 | |
Jorge E. Moreira | d966837 | 2019-01-28 22:40:42 -0800 | [diff] [blame] | 402 | // Whether the host supports qemu |
Jorge E. Moreira | a8142f9 | 2018-06-13 17:33:55 -0700 | [diff] [blame] | 403 | bool HostSupportsQemuCli(); |
Cody Schuffelen | d946b5f | 2018-12-12 11:54:48 -0800 | [diff] [blame] | 404 | bool HostSupportsVsock(); |
Greg Hartman | a3c552d | 2019-03-28 18:20:48 -0700 | [diff] [blame] | 405 | |
| 406 | // GPU modes |
Greg Hartman | bc1bed4 | 2019-04-05 20:02:00 -0700 | [diff] [blame] | 407 | extern const char* const kGpuModeGuestSwiftshader; |
| 408 | extern const char* const kGpuModeDrmVirgl; |
Jorge E. Moreira | 577383b | 2018-05-24 14:17:51 -0700 | [diff] [blame] | 409 | } // namespace vsoc |