Skip to content

Pad vbmeta images during cvd fetch - #3192

Open
3405691582 wants to merge 1 commit into
google:mainfrom
3405691582:vbmeta_fetch
Open

3405691582 wants to merge 1 commit into
google:mainfrom
3405691582:vbmeta_fetch

Conversation

@3405691582

Copy link
Copy Markdown
Collaborator

The guest reads the vbmeta images with libavb, which expects to be able to read the maximum vbmeta size, so we pad the images in place to match this or the read will fail.

This implies that the image location must be writable, which is problematic for particular use-cases. It is worthwhile noting that images are also modified during cvd fetch to de-sparse images before the images are quiescent on disk. While this change does not alleviate the need for in-place image modification, it does ensure that the images need not be modifiable after the cvd fetch occurs.

assemble_cvd behavior is unchanged -- indeed it must not change, since it will need to operate correctly on images not sourced from cvd fetch.

The guest reads the vbmeta images with libavb, which expects to be able
to read the maximum vbmeta size, so we pad the images in place to match
this or the read will fail.

This implies that the image location must be writable, which is
problematic for particular use-cases. It is worthwhile noting that
images are also modified during cvd fetch to de-sparse images before the
images are quiescent on disk. While this change does not alleviate the
need for in-place image modification, it does ensure that the images need
not be modifiable after the cvd fetch occurs.

assemble_cvd behavior is unchanged -- indeed it must not change, since it
will need to operate correctly on images not sourced from cvd fetch.
Comment on lines +60 to +65
bool IsVbmetaImage(std::string_view path) {
return absl::EndsWith(path, "/vbmeta.img") ||
absl::EndsWith(path, "/vbmeta_system.img") ||
absl::EndsWith(path, "/vbmeta_system_dlkm.img") ||
absl::EndsWith(path, "/vbmeta_vendor_dlkm.img");
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge fan of extra behavior for specific filenames, but this does look like the simplest change.

The vbmeta_system call at least is made explicitly

static constexpr std::string_view kSystemImageFiles[] = {
"init_boot", "product", "pvmfw", "system_ext", "vbmeta_system",
};
for (std::string_view system_image : kSystemImageFiles) {
std::string member = fmt::format("IMAGES/{}.img", system_image);
std::string rename_to = fmt::format("{}.img", system_image);
if (!target_files.ExtractOneTo(member, rename_to).has_value()) {
VLOG(0) << "Failed to extract " << member;
}
}

but the other case is buried inside ExtractAll.

What do you think of changing ExtractAll to return the paths of extracted files, so that fetch_cvd.cc can do postprocessing like padding?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants