Set the generated ramdisk's location in the config
The CuttlefishConfig object was being saved to disk and then modified
in-memory afterwards. This worked when launch_cvd carried a lot more
logic, but with the assemble_cvd and run_cvd split exposed this issue as
assemble_cvd has to write the config to disk and run_cvd picks it up.
Test: launch_cvd, touch empty && launch_cvd --initramfs_path=empty
Test: hridya@ validated aosp/1132046 does work with this change
Bug: 142142809
Change-Id: I16b571d8dbe3b24c45f8c43047d4a6424de3f725
diff --git a/host/commands/assemble_cvd/flags.cc b/host/commands/assemble_cvd/flags.cc
index edda7dd..7406a14 100644
--- a/host/commands/assemble_cvd/flags.cc
+++ b/host/commands/assemble_cvd/flags.cc
@@ -206,6 +206,8 @@
namespace {
+std::string kRamdiskConcatExt = ".concat";
+
template<typename S, typename T>
static std::string concat(const S& s, const T& t) {
std::ostringstream os;
@@ -401,6 +403,12 @@
}
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(
@@ -772,13 +780,12 @@
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()) {