Skip to contentSkip to conversation

templates/linux_xen: Fix XSM entries generation

PATCH Superseded Anthony PERARD via Grub-devel 2 participants 3 messages Aug 15, 2023 – Sep 11, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 templates/linux_xen: Fix XSM entries generation

It turns out that setting $xen_version in linux_entry_xsm() override $xen_version in the loop over $xen_list. This means that only one entry per Xen version is going to enable XSM, but all further entries are going to have "(XSM enabled)" in their titles without enabling XSM.

When a "xenpolicy-$xen_version" file was found for the current $xen_version, it would be overwrite $xen_version to add "(XSM enabled)" to the menu entry title. Once change, the next call to linux_entry_xsm() would also have this modified $xen_version and would look for the file "xenpolicy-*(XSM enabled)" and fail.

---
 util/grub.d/20_linux_xen.in | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
util/grub.d/20_linux_xen.in +8 -8
index e46b757da..94dd8be13 100644
@@ -98,7 +98,7 @@ linux_entry_xsm ()
 {
   os="$1"
   version="$2"
-  xen_version="$3"
+  entry_xen_version="$3"
   type="$4"
   args="$5"
   xen_args="$6"
@@ -107,25 +107,25 @@ linux_entry_xsm ()
   # corresponding policy file.
   xenpolicy=
   if ${xsm} ; then
-      xenpolicy="xenpolicy-$xen_version"
+      xenpolicy="xenpolicy-$entry_xen_version"
       if test ! -e "${xen_dirname}/${xenpolicy}" ; then
 	  return
       fi
       xen_args="$xen_args flask=enforcing"
-      xen_version="$(gettext_printf "%s (XSM enabled)" "$xen_version")"
-      # xen_version is used for messages only; actual file is xen_basename
+      entry_xen_version="$(gettext_printf "%s (XSM enabled)" "$entry_xen_version")"
+      # entry_xen_version is used for messages only; actual file is xen_basename
   fi
   if [ -z "$boot_device_id" ]; then
       boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
   fi
   if [ x$type != xsimple ] ; then
       if [ x$type = xrecovery ] ; then
-	  title="$(gettext_printf "%s, with Xen %s and Linux %s (recovery mode)" "${os}" "${xen_version}" "${version}")"
+	  title="$(gettext_printf "%s, with Xen %s and Linux %s (recovery mode)" "${os}" "${entry_xen_version}" "${version}")"
       else
-	  title="$(gettext_printf "%s, with Xen %s and Linux %s" "${os}" "${xen_version}" "${version}")"
+	  title="$(gettext_printf "%s, with Xen %s and Linux %s" "${os}" "${entry_xen_version}" "${version}")"
       fi
       replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
-      if [ x"Xen ${xen_version}>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
+      if [ x"Xen ${entry_xen_version}>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
          quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
          title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; 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 later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
@@ -143,7 +143,7 @@ linux_entry_xsm ()
     prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)"
   fi
   printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
-  xmessage="$(gettext_printf "Loading Xen %s ..." ${xen_version})"
+  xmessage="$(gettext_printf "Loading Xen %s ..." ${entry_xen_version})"
   lmessage="$(gettext_printf "Loading Linux %s ..." ${version})"
   sed "s/^/$submenu_indentation/" << EOF
 	echo	'$(echo "$xmessage" | grub_quote)'
Signature · 7 lines
Anthony PERARD


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#1 lore raw
Quoted 2 lines · Anthony PERARD via Grub-devel

It turns out that setting $xen_version in linux_entry_xsm() override $xen_version in the loop over $xen_list. This means that only one

s/xen_list/reverse_sorted_xen_list/?

I expect you based your patch on earlier version of the GRUB which used $xen_list in fact. Did not you? And this brings another question. Is this patched based on latest GRUB git master branch?

Quoted 6 lines

entry per Xen version is going to enable XSM, but all further entries are going to have "(XSM enabled)" in their titles without enabling XSM.

When a "xenpolicy-$xen_version" file was found for the current $xen_version, it would be overwrite $xen_version to add "(XSM

s/be//

Quoted 1 line

enabled)" to the menu entry title. Once change, the next call to

s/change/updated/?

Quoted 4 lines

linux_entry_xsm() would also have this modified $xen_version and would look for the file "xenpolicy-*(XSM enabled)" and fail.

Otherwise patch LGTM...

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#2 lore raw
Quoted 8 lines · Daniel Kiper
Quoted 2 lines · Anthony PERARD via Grub-devel

It turns out that setting $xen_version in linux_entry_xsm() override $xen_version in the loop over $xen_list. This means that only one

s/xen_list/reverse_sorted_xen_list/?

I expect you based your patch on earlier version of the GRUB which used $xen_list in fact. Did not you? And this brings another question.

Yes, I've developed this patch for the version in Debian Bookworm.

Quoted 1 line

Is this patched based on latest GRUB git master branch?

Yes, I've rebased the patch on the git tree before sending it.

Quoted 4 lines
Quoted 4 lines

entry per Xen version is going to enable XSM, but all further entries are going to have "(XSM enabled)" in their titles without enabling XSM.

Quoted 8 lines
Quoted 2 lines

When a "xenpolicy-$xen_version" file was found for the current $xen_version, it would be overwrite $xen_version to add "(XSM

s/be//

Quoted 1 line

enabled)" to the menu entry title. Once change, the next call to

s/change/updated/?

Sounds good.

Quoted 6 lines
Quoted 4 lines

linux_entry_xsm() would also have this modified $xen_version and would look for the file "xenpolicy-*(XSM enabled)" and fail.

Otherwise patch LGTM...

Thanks,

Signature · 6 lines
Anthony PERARD

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel