diff --git a/scripts/package_release.sh b/scripts/package_release.sh index d8b5468..70a2420 100755 --- a/scripts/package_release.sh +++ b/scripts/package_release.sh @@ -177,6 +177,16 @@ if [ -f "$ESP_STAGING/grub/grub.cfg" ]; then -e 's/HLNK 文件不存在/VLNK 文件不存在/g' \ -e 's/HLNK/VLNK/g' \ "$ESP_STAGING/grub/grub.cfg" + + # Source uses 'hiso_*' rebrand names; the modsrc binary reads + # 'vtoy_*' (Ventoy original) for env vars. Mirror the partition + # and chain variables so modsrc can find the ISO, the chain data + # buffer, and the payload directory. Two patterns per name: one + # for the bare $var form, one for the ${var} brace form. + sed -i \ + -e 's/{hiso_/{vtoy_/g' \ + -e 's/\$hiso_/\$vtoy_/g' \ + "$ESP_STAGING/grub/grub.cfg" fi # Copy chain-boot EFI binaries + helpers to the ESP at /hiperiso/ # (grub.cfg looks for them at \$hiso_path which is the data partition; diff --git a/src/grub2/grub/grub.cfg b/src/grub2/grub/grub.cfg index 0c50569..d7b1dc7 100644 --- a/src/grub2/grub/grub.cfg +++ b/src/grub2/grub/grub.cfg @@ -2668,6 +2668,24 @@ fi #Load Partition Table vt_load_part_table $hisodev +# Detect hypervisor boot path. The deployed binary (built from +# vendor/grub2-modsrc.tar.xz) supports this when the ESP contains +# vmlinuz + initramfs.cpio.gz, regardless of which modsrc version is +# running — the trick is the modsrc partition-variable mapping (see +# scripts/package_release.sh). When the user picks an ISO with +# hiso_hv_mode=1 set, the menuentry handlers divert to hiperiso_boot() +# (line 2529) which runs the host kernel + QEMU initramfs instead of +# the Ventoy chainloader path. Auto-enable when the payloads are +# present on the ESP and /dev/kvm is exposed (the initramfs falls +# back to TCG if KVM is missing). Disable with a sentinel file +# /hiperiso/no_hv_mode on the data partition. +if [ -f $hiso_efi_part/EFI/hiperiso/vmlinuz ] \ + && [ -f $hiso_efi_part/EFI/hiperiso/initramfs.cpio.gz ]; then + if [ ! -f $hiso_iso_part/hiperiso/no_hv_mode ]; then + set hiso_hv_mode=1 + fi +fi + #Load menu lang file hiperiso_load_menu_lang_file