diff --git a/build_library/build_image_util.sh b/build_library/build_image_util.sh index c2863b7bd1e..ec095006eee 100755 --- a/build_library/build_image_util.sh +++ b/build_library/build_image_util.sh @@ -857,7 +857,7 @@ EOF # This script must mount the ESP partition differently, so run it after unmount if [[ "${install_grub}" -eq 1 ]]; then local target - local target_list="i386-pc x86_64-efi x86_64-xen" + local target_list="i386-pc x86_64-efi i386-xen_pvh" if [[ ${BOARD} == "arm64-usr" ]]; then target_list="arm64-efi" fi @@ -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 db83d614a1a..28cdeb95e40 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 @@ -64,7 +66,7 @@ case "${FLAGS_target}" in CORE_NAME="core.efi" SBAT_ARG=( --sbat "${BOARD_ROOT}/usr/share/grub/sbat.csv" ) ;; - x86_64-xen) + i386-xen_pvh) CORE_NAME="core.elf" ;; arm64-efi) @@ -234,13 +236,18 @@ case "${FLAGS_target}" in "${FLAGS_copy_shim}" fi ;; - x86_64-xen) + i386-xen_pvh) info "Installing default x86_64 Xen bootloader." sudo mkdir -p "${ESP_DIR}/xen" "${ESP_DIR}/boot/grub" + # keep the pvboot name for chainloading? sudo cp "${ESP_DIR}/${GRUB_DIR}/${CORE_NAME}" \ "${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 48f98188866..58d1aebbc96 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -133,6 +133,7 @@ IMG_qemu_uefi_OEM_SYSEXT=oem-qemu ## xen IMG_xen_CONF_FORMAT=xl +IMG_xen_OEM_PACKAGE=oem-xen ## virtualbox IMG_virtualbox_DISK_FORMAT=vmdk_ide @@ -990,8 +991,10 @@ _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 hvm="${dst_dir}/$(_src_to_dst_name "${src_name}" "_hvm.cfg")" local disk_format=$(_get_vm_opt DISK_FORMAT) # Set up the few differences between pygrub and pvgrub @@ -999,13 +1002,17 @@ _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}" + echo 'type = "hvm"'> "${hvm}" # The rest is the same - tee -a "${pygrub}" >> "${pvgrub}" </dev/null </dev/null < + + + diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-xen/oem-xen-0.0.1.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-xen/oem-xen-0.0.1.ebuild new file mode 100644 index 00000000000..3c33f1a56a7 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-xen/oem-xen-0.0.1.ebuild @@ -0,0 +1,28 @@ +# Copyright (c) 2013 CoreOS, Inc.. All rights reserved. +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +DESCRIPTION="OEM suite for Xen" +HOMEPAGE="" +SRC_URI="" + +LICENSE="Apache-2.0" +SLOT="0" +KEYWORDS="amd64" +IUSE="" + +# no source directory +S="${WORKDIR}" + +src_prepare() { + default + sed -e "s\\@@OEM_VERSION_ID@@\\${PVR}\\g" \ + "${FILESDIR}/oem-release" > "${T}/oem-release" || die +} + +src_install() { + insinto "/oem" + doins "${FILESDIR}/grub.cfg" + doins "${T}/oem-release" +} diff --git a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/amd64/make.defaults b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/amd64/make.defaults index fdf4402a096..2865cf2666f 100644 --- a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/amd64/make.defaults +++ b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/amd64/make.defaults @@ -5,4 +5,4 @@ BOOTSTRAP_USE="${BOOTSTRAP_USE} -pax_kernel -xtpax" USE="-pax_kernel -urandom -xtpax" # Enable our assorted Grub targets -GRUB_PLATFORMS="efi-64 pc xen" +GRUB_PLATFORMS="efi-64 pc xen-pvh"