Use the composite disk support in crosvm.
Depends on this:
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1667767
Performance characteristics:
Composite disk assembly on disk: 60 seconds
Composite disk assembly on tmpfs: 20 seconds
Composite disk support in crosvm: 0.3 seconds
bpttool creates "holes" between the partition table and the first disk
and between the last disk and the backup partition table. Android seems
to use these so this change creates separate temporary files for them.
Test: launch_cvd -composite_disk=composite.img
Bug: 135293952
Change-Id: I7b22839b7ea6b1bd85ea89cbc0f82a4838c822ef
diff --git a/host/commands/launch/flags.cc b/host/commands/launch/flags.cc
index a966215..be600db 100644
--- a/host/commands/launch/flags.cc
+++ b/host/commands/launch/flags.cc
@@ -661,6 +661,12 @@
if (FLAGS_composite_disk.empty()) {
return false;
}
+ if (FLAGS_vm_manager == vm_manager::CrosvmManager::name()) {
+ // The crosvm implementation is very fast to rebuild but also more brittle due to being split
+ // into multiple files. The QEMU implementation is slow to build, but completely self-contained
+ // at that point. Therefore, always rebuild on crosvm but check if it is necessary for QEMU.
+ return true;
+ }
auto composite_age = cvd::FileModificationTime(FLAGS_composite_disk);
for (auto& partition : disk_config()) {
auto partition_age = cvd::FileModificationTime(partition.image_file_path);
@@ -688,11 +694,17 @@
return true;
}
-void CreateCompositeDisk() {
+void CreateCompositeDisk(const vsoc::CuttlefishConfig& config) {
if (FLAGS_composite_disk.empty()) {
LOG(FATAL) << "asked to create composite disk, but path was empty";
}
- aggregate_image(disk_config(), FLAGS_composite_disk);
+ if (FLAGS_vm_manager == vm_manager::CrosvmManager::name()) {
+ std::string header_path = config.PerInstancePath("gpt_header.img");
+ std::string footer_path = config.PerInstancePath("gpt_footer.img");
+ create_composite_disk(disk_config(), header_path, footer_path, FLAGS_composite_disk);
+ } else {
+ aggregate_image(disk_config(), FLAGS_composite_disk);
+ }
}
} // namespace
@@ -779,7 +791,7 @@
}
if (ShouldCreateCompositeDisk()) {
- CreateCompositeDisk();
+ CreateCompositeDisk(*config);
}
// Check that the files exist