|
46 | 46 | #include "cuttlefish/host/commands/assemble_cvd/flags/initramfs_path.h" |
47 | 47 | #include "cuttlefish/host/commands/assemble_cvd/flags/kernel_path.h" |
48 | 48 | #include "cuttlefish/host/commands/assemble_cvd/flags/system_image_dir.h" |
| 49 | +#include "cuttlefish/host/commands/assemble_cvd/flags/vm_manager.h" |
49 | 50 | #include "cuttlefish/host/commands/assemble_cvd/flags_defaults.h" |
| 51 | +#include "cuttlefish/host/commands/assemble_cvd/resolve_instance_files.h" |
50 | 52 | #include "cuttlefish/host/commands/assemble_cvd/touchpad.h" |
51 | 53 | #include "cuttlefish/host/libs/command_util/snapshot_utils.h" |
52 | 54 | #include "cuttlefish/host/libs/config/adb/adb.h" |
@@ -315,17 +317,18 @@ Result<const CuttlefishConfig*> InitFilesystemAndCreateConfig( |
315 | 317 | FetcherConfig fetcher_config, const std::vector<GuestConfig>& guest_configs, |
316 | 318 | fruit::Injector<>& injector, SharedFD log, const BootImageFlag& boot_image, |
317 | 319 | const InitramfsPathFlag& initramfs_path, const KernelPathFlag& kernel_path, |
318 | | - const SystemImageDirFlag& system_image_dir) { |
| 320 | + const SystemImageDirFlag& system_image_dir, |
| 321 | + const VmManagerFlag& vm_manager_flag) { |
319 | 322 | { |
320 | 323 | // The config object is created here, but only exists in memory until the |
321 | 324 | // SaveConfig line below. Don't launch cuttlefish subprocesses between these |
322 | 325 | // two operations, as those will assume they can read the config object from |
323 | 326 | // disk. |
324 | | - auto config = CF_EXPECT( |
325 | | - InitializeCuttlefishConfiguration( |
326 | | - FLAGS_instance_dir, guest_configs, injector, fetcher_config, |
327 | | - boot_image, initramfs_path, kernel_path, system_image_dir), |
328 | | - "cuttlefish configuration initialization failed"); |
| 327 | + auto config = CF_EXPECT(InitializeCuttlefishConfiguration( |
| 328 | + FLAGS_instance_dir, guest_configs, injector, |
| 329 | + fetcher_config, boot_image, initramfs_path, |
| 330 | + kernel_path, system_image_dir, vm_manager_flag), |
| 331 | + "cuttlefish configuration initialization failed"); |
329 | 332 |
|
330 | 333 | const std::string snapshot_path = FLAGS_snapshot_path; |
331 | 334 | if (!snapshot_path.empty()) { |
@@ -646,16 +649,24 @@ Result<int> AssembleCvdMain(int argc, char** argv) { |
646 | 649 | // gflags either consumes all arguments that start with - or leaves all of |
647 | 650 | // them in place, and either errors out on unknown flags or accepts any flags. |
648 | 651 |
|
649 | | - auto guest_configs = |
650 | | - CF_EXPECT(GetGuestConfigAndSetDefaults(boot_image, initramfs_path, |
651 | | - kernel_path, system_image_dir), |
652 | | - "Failed to parse arguments"); |
| 652 | + CF_EXPECT(ResolveInstanceFiles(boot_image, initramfs_path, kernel_path, |
| 653 | + system_image_dir), |
| 654 | + "Failed to resolve instance files"); |
| 655 | + // Depends on ResolveInstanceFiles to set flag globals |
| 656 | + std::vector<GuestConfig> guest_configs = |
| 657 | + CF_EXPECT(ReadGuestConfig(boot_image, kernel_path, system_image_dir)); |
653 | 658 |
|
654 | | - auto config = |
655 | | - CF_EXPECT(InitFilesystemAndCreateConfig( |
656 | | - std::move(fetcher_config), guest_configs, injector, log, |
657 | | - boot_image, initramfs_path, kernel_path, system_image_dir), |
658 | | - "Failed to create config"); |
| 659 | + VmManagerFlag vm_manager_flag = |
| 660 | + CF_EXPECT(VmManagerFlag::FromGlobalGflags(guest_configs)); |
| 661 | + |
| 662 | + CF_EXPECT( |
| 663 | + SetFlagDefaultsForVmm(guest_configs, system_image_dir, vm_manager_flag)); |
| 664 | + |
| 665 | + auto config = CF_EXPECT( |
| 666 | + InitFilesystemAndCreateConfig( |
| 667 | + std::move(fetcher_config), guest_configs, injector, log, boot_image, |
| 668 | + initramfs_path, kernel_path, system_image_dir, vm_manager_flag), |
| 669 | + "Failed to create config"); |
659 | 670 |
|
660 | 671 | std::cout << GetConfigFilePath(*config) << "\n"; |
661 | 672 | std::cout << std::flush; |
|
0 commit comments