Android-cuttlefish cvd tool
config_utils.h
Go to the documentation of this file.
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 <string>
19
20namespace cuttlefish {
21
22// Returns the instance number as obtained from the
23// *kCuttlefishInstanceEnvVarName environment variable or the username.
24int GetInstance();
25
26// Returns default Vsock CID, which is
27// GetInstance() + 2
29
30// Calculates vsock server port number
31// return base + (vsock_guest_cid - 3)
32int GetVsockServerPort(int base, int vsock_guest_cid);
33
34// Returns a path where the launcher puts a link to the config file which makes
35// it easily discoverable regardless of what vm manager is in use
36std::string GetGlobalConfigFileLink();
37
38// This function modifies a given base value to make it different across
39// different instances by appending the instance id in case of strings or adding
40// it in case of integers.
41std::string ForCurrentInstance(const char* prefix);
42
43int InstanceFromString(std::string instance_str);
44
45// Returns a random serial number appended to a given prefix.
46std::string RandomSerialNumber(const std::string& prefix);
47
48std::string DefaultHostArtifactsPath(const std::string& file);
49std::string DefaultQemuBinaryDir();
50std::string HostBinaryPath(const std::string& binary_name);
51std::string HostUsrSharePath(const std::string& file);
52std::string HostQemuBiosPath();
53std::string DefaultGuestImagePath(const std::string& file);
54std::string DefaultEnvironmentPath(const std::string& environment_key,
55 const std::string& default_value,
56 const std::string& subpath);
57bool IsValidAndroidHostOutPath(const std::string& path);
58
59// Whether the host supports qemu
61
62// Whether to use our local QEMU prebuilt
63bool UseQemuPrebuilt();
64
65std::string GetSeccompPolicyDir();
66
67} // namespace cuttlefish
std::string_view prefix
Definition: kernel_log_server.cc:44
Definition: alloc_driver.h:20
std::string HostUsrSharePath(const std::string &file)
Definition: config_utils.cpp:135
std::string DefaultQemuBinaryDir()
Definition: config_utils.cpp:120
std::string GetSeccompPolicyDir()
Definition: config_utils.cpp:179
bool HostSupportsQemuCli()
Definition: config_utils.cpp:167
std::string RandomSerialNumber(const std::string &prefix)
Definition: config_utils.cpp:100
std::string HostQemuBiosPath()
Definition: config_utils.cpp:139
std::string GetGlobalConfigFileLink()
Definition: config_utils.cpp:90
int GetVsockServerPort(const int base, const int vsock_guest_cid)
Definition: config_utils.cpp:85
int GetDefaultVsockCid()
Definition: config_utils.cpp:79
int InstanceFromString(std::string instance_str)
Definition: config_utils.cpp:38
bool IsValidAndroidHostOutPath(const std::string &path)
Definition: config_utils.cpp:158
std::string ForCurrentInstance(const char *prefix)
Definition: config_utils.cpp:94
std::string DefaultHostArtifactsPath(const std::string &file_name)
Definition: config_utils.cpp:105
std::string DefaultGuestImagePath(const std::string &file_name)
Definition: config_utils.cpp:147
std::string DefaultEnvironmentPath(const std::string &environment_key, const std::string &default_value, const std::string &subpath)
Definition: config_utils.cpp:152
std::string HostBinaryPath(const std::string &binary_name)
Definition: config_utils.cpp:127
int GetInstance()
Definition: config_utils.cpp:74
bool UseQemuPrebuilt()
Definition: config_utils.cpp:112