From 6d9bc1bed862de7773b8578b1c093cd4da2778be Mon Sep 17 00:00:00 2001 From: Jeremi Piotrowski Date: Thu, 11 Apr 2024 13:48:47 +0000 Subject: [PATCH] build_library: Switch pvgrub xen config to use our grub In PVH mode grub can't be chainloaded from grub, so we either need to use pygrub or the host provided grub needs to support Flatcar specifics. Publish our xen-pvh grub along with the image and use it from the pvgrub config. Signed-off-by: Jeremi Piotrowski --- build_library/build_image_util.sh | 3 +++ build_library/grub_install.sh | 6 ++++++ build_library/vm_image_util.sh | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) 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 <