From 97e0cf125e7e08797ccca17d5c2f3b4b9cd70e95 Mon Sep 17 00:00:00 2001 From: Jiaqing Zhao Date: Mon, 29 Jul 2024 03:07:25 +0000 Subject: [PATCH] grub-acrn: check installed acrn binary first grub script should check if any acrn hypervisor is installed on system first before parsing scenario xml. Tracked-On: #8667 Signed-off-by: Jiaqing Zhao Reviewed-by: Junjie Mao --- debian/grub/25_linux_acrn | 76 +++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/debian/grub/25_linux_acrn b/debian/grub/25_linux_acrn index dd167c4c56..6c514cdca9 100755 --- a/debian/grub/25_linux_acrn +++ b/debian/grub/25_linux_acrn @@ -25,6 +25,44 @@ datarootdir="/usr/share" CLASS="--class gnu-linux --class gnu --class os --class acrn" +file_is_not_sym () { + case "$1" in + */acrn-syms-*) + return 1;; + *) + return 0;; + esac +} + +# use ELF *.out files for multiboot +acrn_out_list= +for i in /boot/acrn*.out; do + if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" && grub-file --is-x86-multiboot "$i"; then + acrn_out_list="$acrn_out_list $i" + fi +done +# use raw binary *.bin files for multiboot2 +acrn_bin_list= +for i in /boot/acrn*.bin; do + if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" && grub-file --is-x86-multiboot2 "$i"; then + acrn_bin_list="$acrn_bin_list $i" + fi +done +# we prefer multiboot2 +if [ "x${acrn_bin_list}" != "x" ]; then + acrn_list="${acrn_bin_list}" + acrn_loader="multiboot2" + module_loader="module2" +else + acrn_list="${acrn_out_list}" + acrn_loader="multiboot --quirk-modules-after-kernel" + module_loader="module" +fi +# no ACRN binary found +if [ "x${acrn_list}" = "x" ] ; then + exit 0 +fi + # we obtain any data from scenario config ACRN_SCENARIO_FILE=/usr/share/acrn/scenario.xml if [ ! -f ${ACRN_SCENARIO_FILE} ]; then @@ -253,44 +291,6 @@ for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do fi done -file_is_not_sym () { - case "$1" in - */acrn-syms-*) - return 1;; - *) - return 0;; - esac -} - -# use ELF *.out files for multiboot -acrn_out_list= -for i in /boot/acrn*.out; do - if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" && grub-file --is-x86-multiboot "$i"; then - acrn_out_list="$acrn_out_list $i" - fi -done -# use raw binary *.bin files for multiboot2 -acrn_bin_list= -for i in /boot/acrn*.bin; do - if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" && grub-file --is-x86-multiboot2 "$i"; then - acrn_bin_list="$acrn_bin_list $i" - fi -done -# we prefer multiboot2 -if [ "x${acrn_bin_list}" != "x" ]; then - acrn_list="${acrn_bin_list}" - acrn_loader="multiboot2" - module_loader="module2" -else - acrn_list="${acrn_out_list}" - acrn_loader="multiboot --quirk-modules-after-kernel" - module_loader="module" -fi -# no ACRN binary found -if [ "x${acrn_list}" = "x" ] ; then - exit 0 -fi - prepare_boot_cache= boot_device_id= acrn_first_entry=