From nobody Tue Feb 10 00:00:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=eu.citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1589915432; cv=none; d=zohomail.com; s=zohoarc; b=VPLvH6ozmbUF0xgpDMtZ6q9SKTofUDIWSCLbWAbpdfY5WDh5/SQL0jMnqK1lvn5zW5G//C0f93OaITN8VorGDXzpeNg8qv1appmONvtzfeadpTHrVGUO2dbFdWhhxUZ820HeJClYcNd8hzX7TIJdFEVeheGozAqEsT9eHlSep9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589915432; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yIh+H69gOYoIeW7pxl+56CuMqooBP6ouPYIrvZeuh3Y=; b=fwF8cG9c9ro5/gC8fRtfcXIXsNd4dXGc6FBlS5fJ3yOynxTahPILvzN/opv73GecvM84GjdCRS074KJCXdVge9wNOLr6lx7MjPhnFMEz3pOGDesIa0on7+mqkccIHxniTyyRpj22dnw5JZwbqsGfd+1vii7OkkAdl0M+kpa/gPs= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589915432209676.4116465112104; Tue, 19 May 2020 12:10:32 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jb7d1-0006qf-6s; Tue, 19 May 2020 19:10:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jb7cz-0006p6-IL for xen-devel@lists.xenproject.org; Tue, 19 May 2020 19:10:13 +0000 Received: from chiark.greenend.org.uk (unknown [2001:ba8:1e3::3]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 49889432-9a04-11ea-9887-bc764e2007e4; Tue, 19 May 2020 19:09:39 +0000 (UTC) Received: from [172.18.45.5] (helo=zealot.relativity.greenend.org.uk) by chiark.greenend.org.uk (Debian Exim 4.84_2 #1) with esmtp (return-path ijackson@chiark.greenend.org.uk) id 1jb7Vi-0001da-Gw; Tue, 19 May 2020 20:02:42 +0100 X-Inumbo-ID: 49889432-9a04-11ea-9887-bc764e2007e4 From: Ian Jackson To: xen-devel@lists.xenproject.org Subject: [OSSTEST PATCH 25/38] 20_linux_xen: Copy Debian buster version into our initramfs area Date: Tue, 19 May 2020 20:02:17 +0100 Message-Id: <20200519190230.29519-26-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519190230.29519-1-ian.jackson@eu.citrix.com> References: <20200519190230.29519-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Content-Type: text/plain; charset="utf-8" This is from 41e42571ebc50fa351cd63ce40044946652c5c72 in Debian's grub package. We are going to want to modify this to support XSM/FLASK and cope with upstream build outputs. In this commit we dump the exact file contents across. It's not effective right now because of the ".in" extension. In fact, the file is a template. At the time of writing I am trying to send our substantive changes upstream via Debian's Gitlab: https://salsa.debian.org/grub-team/grub/-/merge_requests/18 Signed-off-by: Ian Jackson --- overlay-buster/etc/grub.d/20_linux_xen.in | 299 ++++++++++++++++++++++ 1 file changed, 299 insertions(+) create mode 100644 overlay-buster/etc/grub.d/20_linux_xen.in diff --git a/overlay-buster/etc/grub.d/20_linux_xen.in b/overlay-buster/etc= /grub.d/20_linux_xen.in new file mode 100644 index 00000000..98ef163c --- /dev/null +++ b/overlay-buster/etc/grub.d/20_linux_xen.in @@ -0,0 +1,299 @@ +#! /bin/sh +set -e + +# grub-mkconfig helper script. +# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see . + +prefix=3D"@prefix@" +exec_prefix=3D"@exec_prefix@" +datarootdir=3D"@datarootdir@" + +. "$pkgdatadir/grub-mkconfig_lib" + +export TEXTDOMAIN=3D@PACKAGE@ +export TEXTDOMAINDIR=3D"@localedir@" + +CLASS=3D"--class gnu-linux --class gnu --class os --class xen" +SUPPORTED_INITS=3D"sysvinit:/lib/sysvinit/init systemd:/lib/systemd/system= d upstart:/sbin/upstart" + +if [ "x${GRUB_DISTRIBUTOR}" =3D "x" ] ; then + OS=3DGNU/Linux +else + OS=3D"${GRUB_DISTRIBUTOR} GNU/Linux" + CLASS=3D"--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' '= -f1|LC_ALL=3DC sed 's,[^[:alnum:]_],_,g') ${CLASS}" +fi + +# loop-AES arranges things so that /dev/loop/X can be our root device, but +# the initrds that Linux uses don't like that. +case ${GRUB_DEVICE} in + /dev/loop/*|/dev/loop[0-9]) + GRUB_DEVICE=3D`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*= /\1/"` + # We can't cope with devices loop-mounted from files here. + case ${GRUB_DEVICE} in + /dev/*) ;; + *) exit 0 ;; + esac + ;; +esac + +# btrfs may reside on multiple devices. We cannot pass them as value of ro= ot=3D parameter +# and mounting btrfs requires user space scanning, so force UUID in this c= ase. +if [ "x${GRUB_DEVICE_UUID}" =3D "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = =3D "xtrue" ] \ + || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ + || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm= ); then + LINUX_ROOT_DEVICE=3D${GRUB_DEVICE} +else + LINUX_ROOT_DEVICE=3DUUID=3D${GRUB_DEVICE_UUID} +fi + +# Allow overriding GRUB_CMDLINE_LINUX and GRUB_CMDLINE_LINUX_DEFAULT. +if [ "${GRUB_CMDLINE_LINUX_XEN_REPLACE}" ]; then + GRUB_CMDLINE_LINUX=3D"${GRUB_CMDLINE_LINUX_XEN_REPLACE}" +fi +if [ "${GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT}" ]; then + GRUB_CMDLINE_LINUX_DEFAULT=3D"${GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT}" +fi + +case x"$GRUB_FS" in + xbtrfs) + rootsubvol=3D"`make_system_path_relative_to_its_root /`" + rootsubvol=3D"${rootsubvol#/}" + if [ "x${rootsubvol}" !=3D x ]; then + GRUB_CMDLINE_LINUX=3D"rootflags=3Dsubvol=3D${rootsubvol} ${GRUB_CMDLI= NE_LINUX}" + fi;; + xzfs) + rpool=3D`${grub_probe} --device ${GRUB_DEVICE} --target=3Dfs_label 2>/dev= /null || true` + bootfs=3D"`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`" + LINUX_ROOT_DEVICE=3D"ZFS=3D${rpool}${bootfs%/}" + ;; +esac + +title_correction_code=3D + +linux_entry () +{ + os=3D"$1" + version=3D"$2" + xen_version=3D"$3" + type=3D"$4" + args=3D"$5" + xen_args=3D"$6" + if [ -z "$boot_device_id" ]; then + boot_device_id=3D"$(grub_get_device_id "${GRUB_DEVICE}")" + fi + if [ x$type !=3D xsimple ] ; then + if [ x$type =3D xrecovery ] ; then + title=3D"$(gettext_printf "%s, with Xen %s and Linux %s (%s)" "${os}" "= ${xen_version}" "${version}" "$(gettext "${GRUB_RECOVERY_TITLE}")")" + elif [ "${type#init-}" !=3D "$type" ] ; then + title=3D"$(gettext_printf "%s, with Xen %s and Linux %s (%s)" "${os}" "= ${xen_version}" "${version}" "${type#init-}")" + else + title=3D"$(gettext_printf "%s, with Xen %s and Linux %s" "${os}" "${xen= _version}" "${version}")" + fi + replacement_title=3D"$(echo "Advanced options for ${OS}" | sed 's,>,= >>,g')>$(echo "$title" | sed 's,>,>>,g')" + if [ x"Xen ${xen_version}>$title" =3D x"$GRUB_ACTUAL_DEFAULT" ]; then + quoted=3D"$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)" + title_correction_code=3D"${title_correction_code}if [ \"x\$defaul= t\" =3D '$quoted' ]; then default=3D'$(echo "$replacement_title" | grub_quo= te)'; fi;" + grub_warn "$(gettext_printf "Please don't use old title \`%s' for= GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or l= ater)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot= _device_id>gnulinux-$version-$type-$boot_device_id")" + fi + echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry= _id_option 'xen-gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$sub= menu_indentation/" + else + title=3D"$(gettext_printf "%s, with Xen hypervisor" "${os}")" + echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry= _id_option 'xen-gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_ind= entation/" + fi + if [ x$type !=3D xrecovery ] ; then + save_default_entry | grub_add_tab | sed "s/^/$submenu_indentation/" + fi + + if [ -z "${prepare_boot_cache}" ]; then + prepare_boot_cache=3D"$(prepare_grub_to_access_device ${GRUB_DEVICE_BO= OT} | grub_add_tab)" + fi + printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" + xmessage=3D"$(gettext_printf "Loading Xen %s ..." ${xen_version})" + lmessage=3D"$(gettext_printf "Loading Linux %s ..." ${version})" + sed "s/^/$submenu_indentation/" << EOF + echo '$(echo "$xmessage" | grub_quote)' + if [ "\$grub_platform" =3D "pc" -o "\$grub_platform" =3D "" ]; then + xen_rm_opts=3D + else + xen_rm_opts=3D"no-real-mode edd=3Doff" + fi + ${xen_loader} ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} = \${xen_rm_opts} + echo '$(echo "$lmessage" | grub_quote)' + ${module_loader} ${rel_dirname}/${basename} placeholder root=3D${linux_ro= ot_device_thisversion} ro ${args} +EOF + if test -n "${initrd}" ; then + # TRANSLATORS: ramdisk isn't identifier. Should be translated. + message=3D"$(gettext_printf "Loading initial ramdisk ...")" + sed "s/^/$submenu_indentation/" << EOF + echo '$(echo "$message" | grub_quote)' + ${module_loader} --nounzip ${rel_dirname}/${initrd} +EOF + fi + sed "s/^/$submenu_indentation/" << EOF +} +EOF +} + +linux_list=3D +for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do + if grub_file_is_not_garbage "$i"; then + basename=3D$(basename $i) + version=3D$(echo $basename | sed -e "s,^[^0-9]*-,,g") + dirname=3D$(dirname $i) + config=3D + for j in "${dirname}/config-${version}" "${dirname}/config-${alt_version}= " "/etc/kernels/kernel-config-${version}" ; do + if test -e "${j}" ; then + config=3D"${j}" + break + fi + done + if (grep -qx "CONFIG_XEN_DOM0=3Dy" "${config}" 2> /dev/null || gre= p -qx "CONFIG_XEN_PRIVILEGED_GUEST=3Dy" "${config}" 2> /dev/null); then lin= ux_list=3D"$linux_list $i" ; fi + fi +done +if [ "x${linux_list}" =3D "x" ] ; then + exit 0 +fi + +file_is_not_sym () { + case "$1" in + */xen-syms-*) + return 1;; + *) + return 0;; + esac +} + +xen_list=3D +for i in /boot/xen*; do + if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then xen_li= st=3D"$xen_list $i" ; fi +done +prepare_boot_cache=3D +boot_device_id=3D + +title_correction_code=3D + +machine=3D`uname -m` + +case "$machine" in + i?86) GENKERNEL_ARCH=3D"x86" ;; + mips|mips64) GENKERNEL_ARCH=3D"mips" ;; + mipsel|mips64el) GENKERNEL_ARCH=3D"mipsel" ;; + arm*) GENKERNEL_ARCH=3D"arm" ;; + *) GENKERNEL_ARCH=3D"$machine" ;; +esac + +# Extra indentation to add to menu entries in a submenu. We're not in a su= bmenu +# yet, so it's empty. In a submenu it will be equal to '\t' (one tab). +submenu_indentation=3D"" + +is_top_level=3Dtrue + +while [ "x${xen_list}" !=3D "x" ] ; do + list=3D"${linux_list}" + current_xen=3D`version_find_latest $xen_list` + xen_basename=3D`basename ${current_xen}` + xen_dirname=3D`dirname ${current_xen}` + rel_xen_dirname=3D`make_system_path_relative_to_its_root $xen_dirname` + xen_version=3D`echo $xen_basename | sed -e "s,.gz$,,g;s,^xen-,,g"` + if [ -z "$boot_device_id" ]; then + boot_device_id=3D"$(grub_get_device_id "${GRUB_DEVICE}")" + fi + if [ "x$is_top_level" !=3D xtrue ]; then + echo " submenu '$(gettext_printf "Xen hypervisor, version %s" "${xen_vers= ion}" | grub_quote)' \$menuentry_id_option 'xen-hypervisor-$xen_version-$bo= ot_device_id' {" + fi + if ($grub_file --is-x86-multiboot2 $current_xen); then + xen_loader=3D"multiboot2" + module_loader=3D"module2" + else + xen_loader=3D"multiboot" + module_loader=3D"module" + fi + while [ "x$list" !=3D "x" ] ; do + linux=3D`version_find_latest $list` + gettext_printf "Found linux image: %s\n" "$linux" >&2 + basename=3D`basename $linux` + dirname=3D`dirname $linux` + rel_dirname=3D`make_system_path_relative_to_its_root $dirname` + version=3D`echo $basename | sed -e "s,^[^0-9]*-,,g"` + alt_version=3D`echo $version | sed -e "s,\.old$,,g"` + linux_root_device_thisversion=3D"${LINUX_ROOT_DEVICE}" + + initrd=3D + for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${versio= n}.gz" \ + "initrd-${version}" "initramfs-${version}.img" \ + "initrd.img-${alt_version}" "initrd-${alt_version}.img" \ + "initrd-${alt_version}" "initramfs-${alt_version}.img" \ + "initramfs-genkernel-${version}" \ + "initramfs-genkernel-${alt_version}" \ + "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \ + "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}" ; do + if test -e "${dirname}/${i}" ; then + initrd=3D"$i" + break + fi + done + if test -n "${initrd}" ; then + gettext_printf "Found initrd image: %s\n" "${dirname}/${initrd}" >&2 + else + # "UUID=3D" magic is parsed by initrds. Since there's no initrd, it c= an't work here. + linux_root_device_thisversion=3D${GRUB_DEVICE} + fi + + if [ "x$is_top_level" =3D xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" !=3D xy= ]; then + linux_entry "${OS}" "${version}" "${xen_version}" simple \ + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XE= N} ${GRUB_CMDLINE_XEN_DEFAULT}" + + submenu_indentation=3D"$grub_tab$grub_tab" + =20 + if [ -z "$boot_device_id" ]; then + boot_device_id=3D"$(grub_get_device_id "${GRUB_DEVICE}")" + fi + # TRANSLATORS: %s is replaced with an OS name + echo "submenu '$(gettext_printf "Advanced options for %s (with Xen hy= pervisor)" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-= $boot_device_id' {" + echo " submenu '$(gettext_printf "Xen hypervisor, version %s" "${xen_vers= ion}" | grub_quote)' \$menuentry_id_option 'xen-hypervisor-$xen_version-$bo= ot_device_id' {" + is_top_level=3Dfalse + fi + + linux_entry "${OS}" "${version}" "${xen_version}" advanced \ + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE= _XEN} ${GRUB_CMDLINE_XEN_DEFAULT}" + for supported_init in ${SUPPORTED_INITS}; do + init_path=3D"${supported_init#*:}" + if [ -x "${init_path}" ] && [ "$(readlink -f /sbin/init)" !=3D "$(rea= dlink -f "${init_path}")" ]; then + linux_entry "${OS}" "${version}" "${xen_version}" "init-${supported_init= %%:*}" \ + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} init=3D${init_p= ath}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}" + + fi + done + if [ "x${GRUB_DISABLE_RECOVERY}" !=3D "xtrue" ]; then + linux_entry "${OS}" "${version}" "${xen_version}" recovery \ + "single ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}" + fi + + list=3D`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '` + done + if [ x"$is_top_level" !=3D xtrue ]; then + echo ' }' + fi + xen_list=3D`echo $xen_list | tr ' ' '\n' | fgrep -vx "$current_xen" | = tr '\n' ' '` +done + +# If at least one kernel was found, then we need to +# add a closing '}' for the submenu command. +if [ x"$is_top_level" !=3D xtrue ]; then + echo '}' +fi + +echo "$title_correction_code" --=20 2.20.1