Skip to content

Commit e6a496d

Browse files
istvannadorjemoreira
authored andcommitted
Add default_vvmtruststore_file_name parameter
Re-applying the change from AOSP: https://android-review.git.corp.google.com/c/device/google/cuttlefish/+/3551899 If- vvmtruststore_path is not specified, but -default_vvmtruststore_file_name is specified then the vvmtruststore_path defaults to the file with the name default_vvmtruststore_file_name within the directory specified by -system_image_dir. This behavior is similer to the existing behavior of other images with the exception that there the default image file names are hard-coded.
1 parent 62e4053 commit e6a496d

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,17 @@ DEFINE_string(
8787
"to "
8888
"be vbmeta_system_dlkm.img in the directory specified by "
8989
"-system_image_dir.");
90+
DEFINE_string(default_vvmtruststore_file_name,
91+
CF_DEFAULTS_DEFAULT_VVMTRUSTSTORE_FILE_NAME,
92+
"If the vvmtruststore_path parameter is empty then the default "
93+
"file name of the vvmtruststore image in the directory specified"
94+
" by -system_image_dir. If empty then there's no vvmtruststore "
95+
"image assumed by default.");
9096
DEFINE_string(vvmtruststore_path, CF_DEFAULTS_VVMTRUSTSTORE_PATH,
91-
"Location of the vvmtruststore image");
97+
"Location of the vvmtruststore image. If empty and the "
98+
"default_vvmtruststore_file_name parameter is not empty then the "
99+
"image file is assumed to be the default_vvmtruststore_file_name "
100+
"file in the directory specified by -system_image_dir.");
92101

93102
DEFINE_string(
94103
default_target_zip, CF_DEFAULTS_DEFAULT_TARGET_ZIP,
@@ -188,11 +197,14 @@ Result<void> ResolveInstanceFiles() {
188197
std::string default_16k_kernel_image = "";
189198
std::string default_16k_ramdisk_image = "";
190199
std::string default_hibernation_image = "";
200+
std::string vvmtruststore_path = "";
191201

192202
std::string cur_system_image_dir;
193203
std::string comma_str = "";
194204
auto instance_nums =
195205
CF_EXPECT(InstanceNumsCalculator().FromGlobalGflags().Calculate());
206+
auto default_vvmtruststore_file_name =
207+
android::base::Split(FLAGS_default_vvmtruststore_file_name, ",");
196208
for (int instance_index = 0; instance_index < instance_nums.size(); instance_index++) {
197209
if (instance_index < system_image_dir.size()) {
198210
cur_system_image_dir = system_image_dir[instance_index];
@@ -231,6 +243,15 @@ Result<void> ResolveInstanceFiles() {
231243
CF_EXPECT(FileExists(ramdisk_16k),
232244
ramdisk_16k + " missing for launching 16k cuttlefish");
233245
}
246+
247+
if (instance_index < default_vvmtruststore_file_name.size()) {
248+
if (default_vvmtruststore_file_name[instance_index].empty()) {
249+
vvmtruststore_path += comma_str;
250+
} else {
251+
vvmtruststore_path += comma_str + cur_system_image_dir + "/" +
252+
default_vvmtruststore_file_name[instance_index];
253+
}
254+
}
234255
}
235256
if (FLAGS_use_16k) {
236257
LOG(INFO) << "Using 16k kernel: " << default_16k_kernel_image;
@@ -271,7 +292,8 @@ Result<void> ResolveInstanceFiles() {
271292
SetCommandLineOptionWithMode("hibernation_image",
272293
default_hibernation_image.c_str(),
273294
google::FlagSettingMode::SET_FLAGS_DEFAULT);
274-
295+
SetCommandLineOptionWithMode("vvmtruststore_path", vvmtruststore_path.c_str(),
296+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
275297
return {};
276298
}
277299

base/cvd/cuttlefish/host/commands/assemble_cvd/flags_defaults.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
#define CF_DEFAULTS_VBMETA_VENDOR_DLKM_IMAGE CF_DEFAULTS_DYNAMIC_STRING
133133
#define CF_DEFAULTS_VBMETA_SYSTEM_DLKM_IMAGE CF_DEFAULTS_DYNAMIC_STRING
134134
#define CF_DEFAULTS_VENDOR_BOOT_IMAGE CF_DEFAULTS_DYNAMIC_STRING
135+
#define CF_DEFAULTS_DEFAULT_VVMTRUSTSTORE_FILE_NAME CF_DEFAULTS_DYNAMIC_STRING
135136
#define CF_DEFAULTS_VVMTRUSTSTORE_PATH CF_DEFAULTS_DYNAMIC_STRING
136137
#define CF_DEFAULTS_DEFAULT_TARGET_ZIP CF_DEFAULTS_DYNAMIC_STRING
137138
#define CF_DEFAULTS_SYSTEM_TARGET_ZIP CF_DEFAULTS_DYNAMIC_STRING

0 commit comments

Comments
 (0)