diff --git a/build_library/build_image_util.sh b/build_library/build_image_util.sh index 9616420e49..ec095006ee 100755 --- a/build_library/build_image_util.sh +++ b/build_library/build_image_util.sh @@ -874,6 +874,9 @@ EOF ) fi for target in ${target_list}; do + if [[ "${target}" = "i386-xen_pvh" ]]; then + grub_args+=(--copy_xen_grub="${BUILD_DIR}/${image_grub%.grub}-grub-xen_pvh.bin") + fi ${BUILD_LIBRARY_DIR}/grub_install.sh \ --board="${BOARD}" \ --target="${target}" \ diff --git a/build_library/grub_install.sh b/build_library/grub_install.sh index 53c3ba129f..28cdeb95e4 100755 --- a/build_library/grub_install.sh +++ b/build_library/grub_install.sh @@ -26,6 +26,8 @@ DEFINE_string copy_efi_grub "" \ "Copy the EFI GRUB image to the specified path." DEFINE_string copy_shim "" \ "Copy the shim image to the specified path." +DEFINE_string copy_xen_grub "" \ + "Copy Xen PVH grub to the specified path." # Parse flags FLAGS "$@" || exit 1 @@ -242,6 +244,10 @@ case "${FLAGS_target}" in "${ESP_DIR}/xen/pvboot-x86_64.elf" sudo cp "${BUILD_LIBRARY_DIR}/menu.lst" \ "${ESP_DIR}/boot/grub/menu.lst" + if [[ -n "${FLAGS_copy_xen_grub}" ]]; then + cp --no-preserve=mode "${ESP_DIR}/xen/pvboot-x86_64.elf" \ + "${FLAGS_copy_xen_grub}" + fi ;; arm64-efi) info "Installing default arm64 UEFI bootloader." diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 7e37c088b5..a00bd8e3a8 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -991,6 +991,7 @@ _write_xl_conf() { local src_name=$(basename "$VM_SRC_IMG") local dst_name=$(basename "$VM_DST_IMG") local dst_dir=$(dirname "$VM_DST_IMG") + local grub_name="flatcar_production_image-grub-xen_pvh.bin" local pygrub="${dst_dir}/$(_src_to_dst_name "${src_name}" "_pygrub.cfg")" local pvgrub="${dst_dir}/$(_src_to_dst_name "${src_name}" "_pvgrub.cfg")" local disk_format=$(_get_vm_opt DISK_FORMAT) @@ -1000,8 +1001,7 @@ _write_xl_conf() { echo 'bootloader = "pygrub"' >> "${pygrub}" echo '# Xen PV config using pvgrub' > "${pvgrub}" - echo 'kernel = "/usr/lib/xen/boot/pv-grub-x86_64.gz"' >> "${pvgrub}" - echo 'extra = "(hd0,0)/boot/grub/menu.lst"' >> "${pvgrub}" + echo "kernel = \"${grub_name}\"" >> "${pvgrub}" # The rest is the same tee -a "${pygrub}" "${pvgrub}" >/dev/null <