Skip to content

Commit 10daca4

Browse files
committed
Use the VmManagerIs[Crosvm,Qemu,Gem5] utilities.
Bug: b/464101323
1 parent 7e60499 commit 10daca4

25 files changed

+58
-111
lines changed

base/cvd/cuttlefish/host/commands/assemble_cvd/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ cf_cc_library(
179179
"//cuttlefish/host/libs/config:fetcher_config",
180180
"//cuttlefish/host/libs/config:file_source",
181181
"//cuttlefish/host/libs/config:instance_nums",
182-
"//cuttlefish/host/libs/config:vmm_mode",
183182
"//cuttlefish/host/libs/feature:inject",
184183
"//libbase",
185184
"@abseil-cpp//absl/strings",
@@ -220,7 +219,6 @@ cf_cc_library(
220219
"//cuttlefish/host/libs/config:cuttlefish_config",
221220
"//cuttlefish/host/libs/config:fetcher_config",
222221
"//cuttlefish/host/libs/config:instance_nums",
223-
"//cuttlefish/host/libs/config:vmm_mode",
224222
"//libbase",
225223
],
226224
)

base/cvd/cuttlefish/host/commands/assemble_cvd/bootconfig_args.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,8 @@ Result<std::unordered_map<std::string, std::string>> BootconfigArgsFromConfig(
115115
std::to_string(instance.openthread_node_id());
116116
}
117117

118-
const auto enable_confui = (config.vm_manager() == VmmMode::kQemu ? 0 : 1);
119118
bootconfig_args["androidboot.enable_confirmationui"] =
120-
std::to_string(enable_confui);
119+
std::to_string(!VmManagerIsQemu(config));
121120

122121
if (instance.audiocontrol_server_port()) {
123122
bootconfig_args["androidboot.vendor.audiocontrol.server.cid"] =

base/cvd/cuttlefish/host/commands/assemble_cvd/create_dynamic_disk_files.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
#include "cuttlefish/host/libs/config/fetched_archive.h"
6060
#include "cuttlefish/host/libs/config/fetcher_config.h"
6161
#include "cuttlefish/host/libs/config/file_source.h"
62-
#include "cuttlefish/host/libs/config/vmm_mode.h"
6362

6463
namespace cuttlefish {
6564
namespace {
@@ -234,7 +233,7 @@ Result<void> CreateDynamicDiskFiles(
234233

235234
// Gem5 Simulate per-instance what the bootloader would usually do
236235
// Since on other devices this runs every time, just do it here every time
237-
if (config.vm_manager() == VmmMode::kGem5) {
236+
if (VmManagerIsGem5(config)) {
238237
RepackGem5BootImage(instance.PerInstancePath("initrd.img"), boot_config,
239238
config.assembly_dir(), instance.initramfs_path());
240239
}

base/cvd/cuttlefish/host/commands/assemble_cvd/disk/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ cf_cc_library(
199199
"//cuttlefish/host/commands/assemble_cvd/disk:generate_persistent_vbmeta",
200200
"//cuttlefish/host/libs/config:ap_boot_flow",
201201
"//cuttlefish/host/libs/config:cuttlefish_config",
202-
"//cuttlefish/host/libs/config:vmm_mode",
203202
"//cuttlefish/host/libs/image_aggregator",
204203
"//cuttlefish/host/libs/vm_manager",
205204
"@gflags",
@@ -315,7 +314,6 @@ cf_cc_library(
315314
"//cuttlefish/common/libs/utils:result",
316315
"//cuttlefish/host/libs/config:cuttlefish_config",
317316
"//cuttlefish/host/libs/config:data_image",
318-
"//cuttlefish/host/libs/config:vmm_mode",
319317
"//cuttlefish/host/libs/image_aggregator:qcow2",
320318
],
321319
)

base/cvd/cuttlefish/host/commands/assemble_cvd/disk/gem5_image_unpacker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
namespace cuttlefish {
2828

2929
Result<void> Gem5ImageUnpacker(const CuttlefishConfig& config) {
30-
if (config.vm_manager() != VmmMode::kGem5) {
30+
if (!VmManagerIsGem5(config)) {
3131
return {};
3232
}
3333
// TODO: b/281130788 - This should accept InstanceSpecific as an argument

base/cvd/cuttlefish/host/commands/assemble_cvd/disk/generate_persistent_bootconfig.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include "cuttlefish/host/commands/assemble_cvd/disk/generate_persistent_bootconfig.h"
1818

19-
#include <memory>
2019
#include <optional>
2120
#include <string>
2221

@@ -74,7 +73,7 @@ Result<std::optional<BootConfigPartition>> BootConfigPartition::CreateIfNeeded(
7473
<< bootconfig_path
7574
<< "` failed:" << bootconfig_fd->StrError());
7675

77-
if (config.vm_manager() == VmmMode::kGem5) {
76+
if (VmManagerIsGem5(config)) {
7877
const off_t bootconfig_size_bytes_gem5 =
7978
AlignToPowerOf2(bytesWritten, PARTITION_SIZE_SHIFT);
8079
CF_EXPECT(bootconfig_fd->Truncate(bootconfig_size_bytes_gem5) == 0);

base/cvd/cuttlefish/host/commands/assemble_cvd/disk/initialize_instance_composite_disk.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "cuttlefish/host/commands/assemble_cvd/disk_builder.h"
2727
#include "cuttlefish/host/libs/config/ap_boot_flow.h"
2828
#include "cuttlefish/host/libs/config/cuttlefish_config.h"
29-
#include "cuttlefish/host/libs/config/vmm_mode.h"
3029
#include "cuttlefish/host/libs/image_aggregator/image_aggregator.h"
3130

3231
namespace cuttlefish {
@@ -71,10 +70,6 @@ std::vector<ImagePartition> PersistentAPCompositeDiskConfig(
7170
return partitions;
7271
}
7372

74-
bool IsVmManagerQemu(const CuttlefishConfig& config) {
75-
return config.vm_manager() == VmmMode::kQemu;
76-
}
77-
7873
} // namespace
7974

8075
Result<InstanceCompositeDisk> InstanceCompositeDisk::Create(
@@ -104,7 +99,7 @@ Result<InstanceCompositeDisk> InstanceCompositeDisk::Create(
10499
std::string overlay_path =
105100
instance.PerInstancePath("persistent_composite_overlay.img");
106101
persistent_disk_builder.OverlayPath(overlay_path);
107-
if (IsVmManagerQemu(config)) {
102+
if (VmManagerIsQemu(config)) {
108103
CF_EXPECT(persistent_disk_builder.BuildOverlayIfNecessary());
109104
}
110105
return InstanceCompositeDisk();
@@ -136,7 +131,7 @@ Result<std::optional<ApCompositeDisk>> ApCompositeDisk::Create(
136131
CF_EXPECT(persistent_ap_disk_builder.BuildCompositeDiskIfNecessary());
137132
persistent_ap_disk_builder.OverlayPath(
138133
instance.PerInstancePath("ap_persistent_composite_overlay.img"));
139-
if (IsVmManagerQemu(config)) {
134+
if (VmManagerIsQemu(config)) {
140135
CF_EXPECT(persistent_ap_disk_builder.BuildOverlayIfNecessary());
141136
}
142137
return ApCompositeDisk();

base/cvd/cuttlefish/host/commands/assemble_cvd/disk/kernel_ramdisk_repacker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Result<void> RepackKernelRamdisk(
109109
// large to be repacked. Skip repack of boot.img on Gem5, as we need to be
110110
// able to extract the ramdisk.img in a later stage and so this step must
111111
// not fail (..and the repacked kernel wouldn't be used anyway).
112-
if (!instance.kernel_path().empty() && config.vm_manager() != VmmMode::kGem5) {
112+
if (!instance.kernel_path().empty() && !VmManagerIsGem5(config)) {
113113
CF_EXPECT(
114114
RepackBootImage(avb, instance.kernel_path(), instance.boot_image(),
115115
instance.new_boot_image(), instance.instance_dir()),

base/cvd/cuttlefish/host/commands/assemble_cvd/disk/sd_card.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "cuttlefish/common/libs/utils/result.h"
2121
#include "cuttlefish/host/libs/config/cuttlefish_config.h"
2222
#include "cuttlefish/host/libs/config/data_image.h"
23-
#include "cuttlefish/host/libs/config/vmm_mode.h"
2423
#include "cuttlefish/host/libs/image_aggregator/qcow2.h"
2524

2625
namespace cuttlefish {
@@ -37,7 +36,7 @@ Result<void> InitializeSdCard(
3736
CF_EXPECT(CreateBlankImage(instance.sdcard_path(),
3837
instance.blank_sdcard_image_mb(), "sdcard"),
3938
"Failed to create \"" << instance.sdcard_path() << "\"");
40-
if (config.vm_manager() == VmmMode::kQemu) {
39+
if (VmManagerIsQemu(config)) {
4140
const std::string crosvm_path = instance.crosvm_binary();
4241
CF_EXPECT(Qcow2Image::Create(crosvm_path, instance.sdcard_path(),
4342
instance.sdcard_overlay_path()));

base/cvd/cuttlefish/host/commands/assemble_cvd/disk_builder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ Result<bool> DiskBuilder::BuildCompositeDiskIfNecessary() {
208208

209209
CF_EXPECT(vm_manager_ != VmmMode::kUnknown);
210210
// TODO: b/346855591 - run with QEMU when crosvm block device is integrated
211-
if (vm_manager_ == VmmMode::kCrosvm) {
211+
if (VmManagerIsCrosvm(vm_manager_)) {
212212
CF_EXPECT(!header_path_.empty(), "No header path");
213213
CF_EXPECT(!footer_path_.empty(), "No footer path");
214214
CF_EXPECT(CreateOrUpdateCompositeDisk(

0 commit comments

Comments
 (0)