assemble_cvd: Support prebuilt android_esp.img in android_efi_loader - #3006
assemble_cvd: Support prebuilt android_esp.img in android_efi_loader#3006zbw182 wants to merge 5 commits into
Conversation
…flow When --android_efi_loader is not explicitly specified on the command line, check for a prebuilt android_esp.img partition in system_image_dir (including system/etc/android_esp.img) before falling back to android_efi_loader.efi. If android_esp.img is present, copy it directly to the instance ESP image path in BuildOSImage, bypassing host-side ESP generation via esp.cpp. If --android_efi_loader is explicitly passed (e.g. pointing to a standalone GBL .efi binary), preserve the existing dynamic generation behavior. Bug: 401619000 Test: assemble_cvd Flag: EXEMPT host tool change
|
FYI, it looks like there are some build/test errors. It's possible to reproduce these locally by running |
Bug: 401619000 Test: bazel build Flag: EXEMPT build fix
|
FYI we have the project configured to require linear history / rebases instead of merge commits, but GitHub still shows the "Update branch" option which does the wrong thing by default and creates merge commits. |
dimorinny
left a comment
There was a problem hiding this comment.
The direction is correct: a build that ships android_esp.img should boot through the EFI loader flow by default, and --android_efi_loader should still let us generate the ESP from a given binary. I'd like to change the shape of the fix, though.
Limitations of the current patch
--android_efi_loadernow carries two meanings, an EFI binary or a prebuilt ESP image, told apart by an.imgsuffix check inBuildOSImage. Every consumer ofandroid_efi_loader()then depends on a naming convention.- The prebuilt image is copied into the instance dir on every assemble.
esp.imgis not resume-preserved, so each run bumps its mtime and--resumerebuilds the composite disk and wipes the overlay. Every other prebuilt partition is referenced in place, and the ESP should be too. - When both files are present, the fetched
android_efi_loader.efishould win over the tree'sandroid_esp.img: it only exists because someone asked for it via--android_efi_loader_build.DefaultPathscurrently checks the prebuilt image first. - The
system/etc/android_esp.imgprobe has no precedent. Every image lookup is a flat<system_image_dir>/<name>.img, which is wherecvd fetchputs the file.
Proposed direction
--android_efi_loaderkeeps one meaning: an EFI binary to generate the ESP from.- A new instance config field,
android_esp_image, holds the prebuilt image's path.DiskImageFlagsVectorizationsets it only when the VMM is crosvm or qemu,boot_flow()is stillAndroid, and<system_image_dir>/android_esp.imgexists. boot_flow()returnsAndroidEfiLoaderwhen either instance config field is non-empty.EfiLoaderImage::Createreturns the prebuilt path when there is no EFI loader, otherwise the generatedesp.imgas today. The composite-disk code is untouched.BuildOSImagereturns early when there is no binary to generate from. No copy, no suffix check.esp_image_path()becomesgenerated_esp_image_path(): it is always<instance>/esp.img, written by assemble_cvd for the EFI loader, ChromeOS, Linux and Fuchsia flows, whileandroid_esp_image()comes from the Android build. The rename makes clear at each call site whether the code produces an image or consumes one.
Resulting precedence: explicit --android_efi_loader=<binary>, then an on-disk android_efi_loader.efi, then the build's android_esp.img, then the legacy flow.
When --android_efi_loader is not explicitly specified on the command line, check for a prebuilt android_esp.img partition in system_image_dir (including system/etc/android_esp.img) before falling back to android_efi_loader.efi.
If android_esp.img is present, copy it directly to the instance ESP image path in BuildOSImage, bypassing host-side ESP generation via esp.cpp. If --android_efi_loader is explicitly passed (e.g. pointing to a standalone GBL .efi binary), preserve the existing dynamic generation behavior.