Skip to content

Commit 40d7822

Browse files
committed
Enforce clang-format on host/libs/vm_manager
Bug: b/512215781
1 parent 8ab8276 commit 40d7822

17 files changed

Lines changed: 120 additions & 98 deletions

base/cvd/cuttlefish/host/libs/vm_manager/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ cf_cc_library(
3030
"vhost_user.h",
3131
"vm_manager.h",
3232
],
33-
clang_format_enabled = False,
3433
deps = [
3534
"//cuttlefish/common/libs/fs",
3635
"//cuttlefish/common/libs/utils:container",

base/cvd/cuttlefish/host/libs/vm_manager/crosvm_builder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <optional>
1919
#include <string>
2020

21-
#include <json/value.h>
21+
#include "json/value.h"
2222

2323
#include "cuttlefish/common/libs/utils/subprocess.h"
2424
#include "cuttlefish/host/libs/vm_manager/pci.h"

base/cvd/cuttlefish/host/libs/vm_manager/crosvm_cpu.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include <vector>
2020

2121
#include "absl/strings/str_join.h"
22-
#include <fmt/format.h>
23-
#include <json/value.h>
22+
#include "fmt/format.h"
23+
#include "json/value.h"
2424

2525
#include "cuttlefish/common/libs/utils/json.h"
2626
#include "cuttlefish/result/result.h"

base/cvd/cuttlefish/host/libs/vm_manager/crosvm_cpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <string>
1919
#include <vector>
2020

21-
#include <json/value.h>
21+
#include "json/value.h"
2222

2323
#include "cuttlefish/result/result.h"
2424

base/cvd/cuttlefish/host/libs/vm_manager/crosvm_display_controller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include <string>
2121
#include <vector>
2222

23-
#include "absl/strings/str_join.h"
2423
#include "absl/log/log.h"
24+
#include "absl/strings/str_join.h"
2525

2626
#include "cuttlefish/common/libs/utils/subprocess.h"
2727
#include "cuttlefish/common/libs/utils/subprocess_managed_stdio.h"

base/cvd/cuttlefish/host/libs/vm_manager/crosvm_display_controller.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#pragma once
1717

1818
#include <string>
19+
1920
#include "cuttlefish/host/libs/config/cuttlefish_config.h"
2021
#include "cuttlefish/result/result.h"
2122

base/cvd/cuttlefish/host/libs/vm_manager/crosvm_manager.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
#include <utility>
2929
#include <vector>
3030

31-
#include <android-base/file.h>
3231
#include "absl/strings/str_join.h"
33-
#include <json/json.h>
34-
#include <vulkan/vulkan.h>
32+
#include "android-base/file.h"
33+
#include "json/json.h"
34+
#include "vulkan/vulkan.h"
3535

3636
#include "cuttlefish/common/libs/utils/files.h"
37-
#include "cuttlefish/common/libs/utils/in_sandbox.h"
3837
#include "cuttlefish/common/libs/utils/host_info.h"
38+
#include "cuttlefish/common/libs/utils/in_sandbox.h"
3939
#include "cuttlefish/common/libs/utils/json.h"
4040
#include "cuttlefish/common/libs/utils/known_paths.h"
4141
#include "cuttlefish/common/libs/utils/network.h"
@@ -261,7 +261,7 @@ Result<std::string> CrosvmPathForVhostUserGpu(const CuttlefishConfig& config) {
261261
break;
262262
default:
263263
return CF_ERR("Unhandled host arch " << HostArchStr()
264-
<< " for vhost user gpu crosvm");
264+
<< " for vhost user gpu crosvm");
265265
}
266266
if (FileExists(crosvm_path)) {
267267
return crosvm_path;
@@ -278,10 +278,11 @@ Result<std::string> CrosvmPathForVhostUserGpu(const CuttlefishConfig& config) {
278278
break;
279279
default:
280280
return CF_ERR("Unhandled host arch " << HostArchStr()
281-
<< " for vhost user gpu crosvm");
281+
<< " for vhost user gpu crosvm");
282282
}
283283

284-
CF_EXPECT(FileExists(crosvm_path), "Failed to find crosvm prebuilt for vhost user gpu.");
284+
CF_EXPECT(FileExists(crosvm_path),
285+
"Failed to find crosvm prebuilt for vhost user gpu.");
285286
return crosvm_path;
286287
}
287288

@@ -601,7 +602,8 @@ Result<std::vector<MonitorCommand>> CrosvmManager::StartCommands(
601602
}
602603

603604
if (!instance.crosvm_v4l2_proxy().empty()) {
604-
crosvm_cmd.Cmd().AddParameter("--v4l2-proxy=", instance.crosvm_v4l2_proxy());
605+
crosvm_cmd.Cmd().AddParameter("--v4l2-proxy=",
606+
instance.crosvm_v4l2_proxy());
605607
}
606608

607609
if (instance.gdb_port() > 0) {
@@ -957,7 +959,8 @@ Result<std::vector<MonitorCommand>> CrosvmManager::StartCommands(
957959
auto config = instance.media_configs()[index];
958960
if (config.type == CuttlefishConfig::MediaType::kV4l2EmulatedCameraSPlane ||
959961
config.type == CuttlefishConfig::MediaType::kV4l2EmulatedCameraMPlane) {
960-
crosvm_cmd.Cmd().AddParameter("--vhost-user=type=media,socket=", instance.media_socket_path(index));
962+
crosvm_cmd.Cmd().AddParameter("--vhost-user=type=media,socket=",
963+
instance.media_socket_path(index));
961964
} else if (config.type == CuttlefishConfig::MediaType::kV4l2Proxy) {
962965
crosvm_cmd.Cmd().AddParameter("--v4l2-proxy=", "/dev/video0");
963966
}
@@ -1071,4 +1074,3 @@ Result<bool> CrosvmManager::WaitForRestoreComplete(SharedFD stop_fd) const {
10711074

10721075
} // namespace vm_manager
10731076
} // namespace cuttlefish
1074-

base/cvd/cuttlefish/host/libs/vm_manager/crosvm_manager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ class CrosvmManager : public VmManager {
5252
static constexpr int kCrosvmVmResetExitCode = 32;
5353
};
5454

55-
} // namespace vm_manager
56-
} // namespace cuttlefish
55+
} // namespace vm_manager
56+
} // namespace cuttlefish

base/cvd/cuttlefish/host/libs/vm_manager/gem5_manager.cpp

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
#include <utility>
3030
#include <vector>
3131

32-
#include <vulkan/vulkan.h>
3332
#include "absl/log/log.h"
33+
#include "vulkan/vulkan.h"
3434

3535
#include "cuttlefish/common/libs/utils/environment.h"
3636
#include "cuttlefish/common/libs/utils/subprocess.h"
@@ -140,8 +140,10 @@ if __name__ == "__m5_main__":
140140

141141
void GenerateGem5File(const CuttlefishConfig& config,
142142
const CuttlefishConfig::InstanceSpecific& instance) {
143-
// Gem5 specific config, currently users have to change these config locally (without through launch_cvd input flag) to meet their design
144-
// TODO: Add these config into launch_cvd input flag or parse from one json file
143+
// Gem5 specific config, currently users have to change these config locally
144+
// (without through launch_cvd input flag) to meet their design
145+
// TODO: Add these config into launch_cvd input flag or parse from one json
146+
// file
145147
std::string cpu_class = "AtomicSimpleCPU";
146148
std::string l1_icache_class = "None";
147149
std::string l1_dcache_class = "None";
@@ -154,8 +156,8 @@ void GenerateGem5File(const CuttlefishConfig& config,
154156
std::string mem_ranks = "None";
155157

156158
// start generating starter_fs.py
157-
std::string fs_path = instance.gem5_binary_dir() +
158-
"/configs/example/arm/starter_fs.py";
159+
std::string fs_path =
160+
instance.gem5_binary_dir() + "/configs/example/arm/starter_fs.py";
159161
std::ofstream starter_fs_ofstream(fs_path.c_str());
160162
starter_fs_ofstream << kFsHeader << "\n";
161163

@@ -167,33 +169,57 @@ void GenerateGem5File(const CuttlefishConfig& config,
167169

168170
// args
169171
starter_fs_ofstream << " parser = argparse.ArgumentParser(epilog=__doc__)\n";
170-
starter_fs_ofstream << " parser.add_argument(\"--disk-image\", action=\"append\", type=str, default=[])\n";
171-
starter_fs_ofstream << " parser.add_argument(\"--mem-type\", default=\"" << mem_type << "\", choices=ObjectList.mem_list.get_names())\n";
172-
starter_fs_ofstream << " parser.add_argument(\"--mem-channels\", type=int, default=" << mem_channels << ")\n";
173-
starter_fs_ofstream << " parser.add_argument(\"--mem-ranks\", type=int, default=" << mem_ranks << ")\n";
174-
starter_fs_ofstream << " parser.add_argument(\"--mem-size\", action=\"store\", type=str, default=\"" << instance.memory_mb() << "MB\")\n";
175-
starter_fs_ofstream << " parser.add_argument(\"--restore\", type=str, default=None)\n";
172+
starter_fs_ofstream << " parser.add_argument(\"--disk-image\", "
173+
"action=\"append\", type=str, default=[])\n";
174+
starter_fs_ofstream << " parser.add_argument(\"--mem-type\", default=\""
175+
<< mem_type
176+
<< "\", choices=ObjectList.mem_list.get_names())\n";
177+
starter_fs_ofstream
178+
<< " parser.add_argument(\"--mem-channels\", type=int, default="
179+
<< mem_channels << ")\n";
180+
starter_fs_ofstream
181+
<< " parser.add_argument(\"--mem-ranks\", type=int, default="
182+
<< mem_ranks << ")\n";
183+
starter_fs_ofstream << " parser.add_argument(\"--mem-size\", "
184+
"action=\"store\", type=str, default=\""
185+
<< instance.memory_mb() << "MB\")\n";
186+
starter_fs_ofstream
187+
<< " parser.add_argument(\"--restore\", type=str, default=None)\n";
176188
starter_fs_ofstream << " args = parser.parse_args()\n";
177189

178190
// instantiate system
179191
starter_fs_ofstream << " root = Root(full_system=True)\n";
180192
starter_fs_ofstream << " mem_mode = " << cpu_class << ".memory_mode()\n";
181-
starter_fs_ofstream << " has_caches = True if mem_mode == \"timing\" else False\n";
182-
starter_fs_ofstream << " root.system = devices.SimpleSystem(has_caches, args.mem_size, mem_mode=mem_mode, workload=ArmFsLinux(object_file=SysPaths.binary(\"" << config.assembly_dir() << "/kernel\")))\n";
193+
starter_fs_ofstream
194+
<< " has_caches = True if mem_mode == \"timing\" else False\n";
195+
starter_fs_ofstream
196+
<< " root.system = devices.SimpleSystem(has_caches, args.mem_size, "
197+
"mem_mode=mem_mode, workload=ArmFsLinux(object_file=SysPaths.binary(\""
198+
<< config.assembly_dir() << "/kernel\")))\n";
183199

184200
// mem config and pci instantiate
185201
starter_fs_ofstream << kFsMemPci;
186202

187203
// system settings
188-
starter_fs_ofstream << " root.system.cpu_cluster = [devices.CpuCluster(root.system, " << num_cores << ", \"" << cpu_freq << "\", \"1.0V\", " << cpu_class << ", " << l1_icache_class << ", " << l1_dcache_class << ", " << walk_cache_class << ", " << l2_Cache_class << ")]\n";
189-
starter_fs_ofstream << " root.system.addCaches(has_caches, last_cache_level=2)\n";
190-
starter_fs_ofstream << " root.system.realview.setupBootLoader(root.system, SysPaths.binary)\n";
191-
starter_fs_ofstream << " root.system.workload.dtb_filename = os.path.join(m5.options.outdir, 'system.dtb')\n";
192-
starter_fs_ofstream << " root.system.generateDtb(root.system.workload.dtb_filename)\n";
193-
starter_fs_ofstream << " root.system.workload.initrd_filename = \"" << instance.PerInstancePath("initrd.img") << "\"\n";
194-
starter_fs_ofstream << " root_dir = \"" << StringFromEnv("HOME", ".") << "\"\n";
195-
196-
//kernel cmd
204+
starter_fs_ofstream
205+
<< " root.system.cpu_cluster = [devices.CpuCluster(root.system, "
206+
<< num_cores << ", \"" << cpu_freq << "\", \"1.0V\", " << cpu_class
207+
<< ", " << l1_icache_class << ", " << l1_dcache_class << ", "
208+
<< walk_cache_class << ", " << l2_Cache_class << ")]\n";
209+
starter_fs_ofstream
210+
<< " root.system.addCaches(has_caches, last_cache_level=2)\n";
211+
starter_fs_ofstream << " root.system.realview.setupBootLoader(root.system, "
212+
"SysPaths.binary)\n";
213+
starter_fs_ofstream << " root.system.workload.dtb_filename = "
214+
"os.path.join(m5.options.outdir, 'system.dtb')\n";
215+
starter_fs_ofstream
216+
<< " root.system.generateDtb(root.system.workload.dtb_filename)\n";
217+
starter_fs_ofstream << " root.system.workload.initrd_filename = \""
218+
<< instance.PerInstancePath("initrd.img") << "\"\n";
219+
starter_fs_ofstream << " root_dir = \"" << StringFromEnv("HOME", ".")
220+
<< "\"\n";
221+
222+
// kernel cmd
197223
starter_fs_ofstream << kFsKernelCmd << "\n";
198224

199225
// execute main
@@ -204,9 +230,7 @@ void GenerateGem5File(const CuttlefishConfig& config,
204230

205231
Gem5Manager::Gem5Manager(Arch arch) : arch_(arch) {}
206232

207-
bool Gem5Manager::IsSupported() {
208-
return HostSupportsQemuCli();
209-
}
233+
bool Gem5Manager::IsSupported() { return HostSupportsQemuCli(); }
210234

211235
Result<std::unordered_map<std::string, std::string>>
212236
Gem5Manager::ConfigureGraphics(
@@ -308,9 +332,9 @@ Result<std::vector<MonitorCommand>> Gem5Manager::StartCommands(
308332

309333
// Add debug-flags and debug-file before the script (i.e. starter_fs.py).
310334
// We check the flags are not empty first since they are optional
311-
if(!config.gem5_debug_flags().empty()) {
335+
if (!config.gem5_debug_flags().empty()) {
312336
gem5_cmd.AddParameter("--debug-flags=", config.gem5_debug_flags());
313-
if(!instance.gem5_debug_file().empty()) {
337+
if (!instance.gem5_debug_file().empty()) {
314338
gem5_cmd.AddParameter("--debug-file=", instance.gem5_debug_file());
315339
}
316340
}
@@ -320,11 +344,11 @@ Result<std::vector<MonitorCommand>> Gem5Manager::StartCommands(
320344

321345
// restore checkpoint case
322346
if (!instance.gem5_checkpoint_dir().empty()) {
323-
gem5_cmd.AddParameter("--restore=",
324-
instance.gem5_checkpoint_dir());
347+
gem5_cmd.AddParameter("--restore=", instance.gem5_checkpoint_dir());
325348
}
326349

327-
gem5_cmd.AddParameter("--mem-size=", instance.memory_mb() * 1024ULL * 1024ULL);
350+
gem5_cmd.AddParameter("--mem-size=",
351+
instance.memory_mb() * 1024ULL * 1024ULL);
328352
for (const auto& disk : instance.virtual_disk_paths()) {
329353
gem5_cmd.AddParameter("--disk-image=", disk);
330354
}
@@ -336,5 +360,5 @@ Result<std::vector<MonitorCommand>> Gem5Manager::StartCommands(
336360
return commands;
337361
}
338362

339-
} // namespace vm_manager
340-
} // namespace cuttlefish
363+
} // namespace vm_manager
364+
} // namespace cuttlefish

base/cvd/cuttlefish/host/libs/vm_manager/gem5_manager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ class Gem5Manager : public VmManager {
5252
Arch arch_;
5353
};
5454

55-
} // namespace vm_manager
56-
} // namespace cuttlefish
55+
} // namespace vm_manager
56+
} // namespace cuttlefish

0 commit comments

Comments
 (0)