diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2019-10-05 00:10:34 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-10-05 00:10:34 +0000 |
commit | 4900985fd81d5e48162e3d5e974b570ea060ba05 (patch) | |
tree | 585f885c97d8518cf8b5f0dfafd4c6434a296072 | |
parent | 64581ce5787256df902ee0927affd916f396db5f (diff) | |
parent | 9fd954795129288322667cec0b757b7ba2ab5b25 (diff) | |
download | cuttlefish_common-4900985fd81d5e48162e3d5e974b570ea060ba05.tar.gz |
Merge "Set the generated ramdisk's location in the config"
-rw-r--r-- | host/commands/assemble_cvd/flags.cc | 15 | ||||
-rw-r--r-- | host/libs/config/cuttlefish_config.cpp | 17 | ||||
-rw-r--r-- | host/libs/config/cuttlefish_config.h | 6 | ||||
-rw-r--r-- | host/libs/vm_manager/crosvm_manager.cpp | 4 | ||||
-rw-r--r-- | host/libs/vm_manager/qemu_manager.cpp | 2 |
5 files changed, 37 insertions, 7 deletions
diff --git a/host/commands/assemble_cvd/flags.cc b/host/commands/assemble_cvd/flags.cc index aea912b8..7c599833 100644 --- a/host/commands/assemble_cvd/flags.cc +++ b/host/commands/assemble_cvd/flags.cc @@ -207,6 +207,8 @@ DEFINE_string(bootloader, "", "Bootloader binary path"); namespace { +std::string kRamdiskConcatExt = ".concat"; + template<typename S, typename T> static std::string concat(const S& s, const T& t) { std::ostringstream os; @@ -397,6 +399,12 @@ bool InitializeCuttlefishConfiguration( } tmp_config_obj.set_ramdisk_image_path(ramdisk_path); + if(FLAGS_initramfs_path.size() > 0) { + tmp_config_obj.set_initramfs_path(FLAGS_initramfs_path); + tmp_config_obj.set_final_ramdisk_path(ramdisk_path + kRamdiskConcatExt); + } else { + tmp_config_obj.set_final_ramdisk_path(ramdisk_path); + } tmp_config_obj.set_mempath(FLAGS_mempath); tmp_config_obj.set_ivshmem_qemu_socket_path( @@ -768,13 +776,12 @@ vsoc::CuttlefishConfig* InitFilesystemAndCreateConfig(int* argc, char*** argv) { exit(LauncherExitCodes::kBootImageUnpackError); } - if(FLAGS_initramfs_path.size()) { - auto concat_ramdisk_path = config->ramdisk_image_path() + ".concat"; - if(!ConcatRamdisks(concat_ramdisk_path, config->ramdisk_image_path(), FLAGS_initramfs_path)) { + if(config->initramfs_path().size() != 0) { + if(!ConcatRamdisks(config->final_ramdisk_path(), config->ramdisk_image_path(), + config->initramfs_path())) { LOG(ERROR) << "Failed to concatenate ramdisk and initramfs"; exit(LauncherExitCodes::kInitRamFsConcatError); } - config->set_ramdisk_image_path(concat_ramdisk_path); } if (config->decompress_kernel()) { diff --git a/host/libs/config/cuttlefish_config.cpp b/host/libs/config/cuttlefish_config.cpp index 2108b63e..de7e95cf 100644 --- a/host/libs/config/cuttlefish_config.cpp +++ b/host/libs/config/cuttlefish_config.cpp @@ -90,6 +90,8 @@ const char* kDecompressKernel = "decompress_kernel"; const char* kGdbFlag = "gdb_flag"; const char* kKernelCmdline = "kernel_cmdline"; const char* kRamdiskImagePath = "ramdisk_image_path"; +const char* kInitramfsPath = "initramfs_path"; +const char* kFinalRamdiskPath = "final_ramdisk_path"; const char* kVirtualDiskPaths = "virtual_disk_paths"; const char* kUsbV1SocketName = "usb_v1_socket_name"; @@ -358,6 +360,21 @@ void CuttlefishConfig::set_ramdisk_image_path( SetPath(kRamdiskImagePath, ramdisk_image_path); } +std::string CuttlefishConfig::initramfs_path() const { + return (*dictionary_)[kInitramfsPath].asString(); +} +void CuttlefishConfig::set_initramfs_path(const std::string& initramfs_path) { + SetPath(kInitramfsPath, initramfs_path); +} + +std::string CuttlefishConfig::final_ramdisk_path() const { + return (*dictionary_)[kFinalRamdiskPath].asString(); +} +void CuttlefishConfig::set_final_ramdisk_path( + const std::string& final_ramdisk_path) { + SetPath(kFinalRamdiskPath, final_ramdisk_path); +} + std::vector<std::string> CuttlefishConfig::virtual_disk_paths() const { std::vector<std::string> virtual_disks; auto virtual_disks_json_obj = (*dictionary_)[kVirtualDiskPaths]; diff --git a/host/libs/config/cuttlefish_config.h b/host/libs/config/cuttlefish_config.h index 4d999479..0a354eaf 100644 --- a/host/libs/config/cuttlefish_config.h +++ b/host/libs/config/cuttlefish_config.h @@ -145,6 +145,12 @@ class CuttlefishConfig { std::string ramdisk_image_path() const; void set_ramdisk_image_path(const std::string& ramdisk_image_path); + std::string initramfs_path() const; + void set_initramfs_path(const std::string& initramfs_path); + + std::string final_ramdisk_path() const; + void set_final_ramdisk_path(const std::string& final_ramdisk_path); + std::vector<std::string> virtual_disk_paths() const; void set_virtual_disk_paths(const std::vector<std::string>& disk_paths); diff --git a/host/libs/vm_manager/crosvm_manager.cpp b/host/libs/vm_manager/crosvm_manager.cpp index 28f36673..a050f70a 100644 --- a/host/libs/vm_manager/crosvm_manager.cpp +++ b/host/libs/vm_manager/crosvm_manager.cpp @@ -113,8 +113,8 @@ std::vector<cvd::Command> CrosvmManager::StartCommands(bool with_frontend) { crosvm_cmd.AddParameter("--x-display=", config_->x_display()); } } - if (!config_->ramdisk_image_path().empty()) { - crosvm_cmd.AddParameter("--initrd=", config_->ramdisk_image_path()); + if (!config_->final_ramdisk_path().empty()) { + crosvm_cmd.AddParameter("--initrd=", config_->final_ramdisk_path()); } crosvm_cmd.AddParameter("--null-audio"); crosvm_cmd.AddParameter("--mem=", config_->memory_mb()); diff --git a/host/libs/vm_manager/qemu_manager.cpp b/host/libs/vm_manager/qemu_manager.cpp index 37ab8151..51280a20 100644 --- a/host/libs/vm_manager/qemu_manager.cpp +++ b/host/libs/vm_manager/qemu_manager.cpp @@ -136,7 +136,7 @@ std::vector<cvd::Command> QemuManager::StartCommands(bool /*with_frontend*/) { LogAndSetEnv("monitor_path", GetMonitorPath(config_)); LogAndSetEnv("kernel_image_path", config_->GetKernelImageToUse()); LogAndSetEnv("gdb_flag", config_->gdb_flag()); - LogAndSetEnv("ramdisk_image_path", config_->ramdisk_image_path()); + LogAndSetEnv("ramdisk_image_path", config_->final_ramdisk_path()); LogAndSetEnv("kernel_cmdline", config_->kernel_cmdline_as_string()); LogAndSetEnv("virtual_disk_paths", JoinString(config_->virtual_disk_paths(), ";")); |