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(const int base,
33 const int vsock_guest_cid);
34
35// Returns a path where the launcher puts a link to the config file which makes
36// it easily discoverable regardless of what vm manager is in use
37std::string GetGlobalConfigFileLink();
38
39// This function modifies a given base value to make it different across
40// different instances by appending the instance id in case of strings or adding
41// it in case of integers.
42std::string ForCurrentInstance(const char* prefix);
43
44int InstanceFromString(std::string instance_str);
45
46// Returns a random serial number appended to a given prefix.
47std::string RandomSerialNumber(const std::string& prefix);
48
49std::string DefaultHostArtifactsPath(const std::string& file);
50std::string DefaultQemuBinaryDir();
51std::string HostBinaryPath(const std::string& binary_name);
52std::string HostUsrSharePath(const std::string& file);
53std::string HostQemuBiosPath();
54std::string DefaultGuestImagePath(const std::string& file);
55std::string DefaultEnvironmentPath(const std::string& environment_key,
56 const std::string& default_value,
57 const std::string& subpath);
58bool IsValidAndroidHostOutPath(const std::string& path);
59
60// Whether the host supports qemu
62
63// Whether to use our local QEMU prebuilt
64bool UseQemuPrebuilt();
65
66std::string GetSeccompPolicyDir();
67
68} // namespace cuttlefish
std::string_view prefix
Definition: kernel_log_server.cc:41
Definition: alloc_utils.cpp:23
std::string HostUsrSharePath(const std::string &file)
Definition: config_utils.cpp:144
std::string DefaultQemuBinaryDir()
Definition: config_utils.cpp:129
std::string GetSeccompPolicyDir()
Definition: config_utils.cpp:187
bool HostSupportsQemuCli()
Definition: config_utils.cpp:175
std::string RandomSerialNumber(const std::string &prefix)
Definition: config_utils.cpp:102
std::string HostQemuBiosPath()
Definition: config_utils.cpp:148
std::string GetGlobalConfigFileLink()
Definition: config_utils.cpp:92
int GetVsockServerPort(const int base, const int vsock_guest_cid)
Definition: config_utils.cpp:87
int GetDefaultVsockCid()
Definition: config_utils.cpp:81
int InstanceFromString(std::string instance_str)
Definition: config_utils.cpp:40
bool IsValidAndroidHostOutPath(const std::string &path)
Definition: config_utils.cpp:167
std::string ForCurrentInstance(const char *prefix)
Definition: config_utils.cpp:96
std::string DefaultHostArtifactsPath(const std::string &file_name)
Definition: config_utils.cpp:112
std::string DefaultGuestImagePath(const std::string &file_name)
Definition: config_utils.cpp:156
std::string DefaultEnvironmentPath(const std::string &environment_key, const std::string &default_value, const std::string &subpath)
Definition: config_utils.cpp:161
std::string HostBinaryPath(const std::string &binary_name)
Definition: config_utils.cpp:136
int GetInstance()
Definition: config_utils.cpp:76
bool UseQemuPrebuilt()
Definition: config_utils.cpp:121