[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 12/12] grub-shell: Add flexibility in QEMU firmware handling
From: |
Glenn Washburn |
Subject: |
[PATCH v2 12/12] grub-shell: Add flexibility in QEMU firmware handling |
Date: |
Sat, 1 Jan 2022 22:07:22 -0600 |
The current qemu firmware paths for arm-efi and arm64-efi are not available
on Ubuntu/Debian but are hardcoded. Switch to first looking for firmware
files in the source directory and if not found, look for them in locations
where Debian installs them. Prefer to use the firmware file usable with the
QEMU '-bios' option and if not found use the newer pflash firmware files.
This allows supporting older systems more easily. By looking for files in
the source directory first, system firmware files can be overridden and it
can be ensured that the tests can be run regardless of the distro and where
it stores firmware files. If no firmware files are found, print an error
message telling the user that those files must exist and exit with error.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
tests/util/grub-shell.in | 95 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 91 insertions(+), 4 deletions(-)
diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in
index e56506444..5d7926c94 100644
--- a/tests/util/grub-shell.in
+++ b/tests/util/grub-shell.in
@@ -180,21 +180,86 @@ case
"${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
boot=cd
console=console
trim=1
- qemuopts="-bios OVMF-ia32.fd $qemuopts"
+ bios=${srcdir}/OVMF32.fd
+ pflash_code=${srcdir}/OVMF32_CODE.fd
+ pflash_vars=${srcdir}/OVMF32_VARS.fd
+ if [ -f "$bios" ]; then
+ qemuopts="-bios $bios $qemuopts"
+ elif [ -f "$pflash_code" ]; then
+ qemuopts="-drive if=pflash,format=raw,readonly=on,file=$pflash_code
$qemuopts"
+ qemuopts="-drive if=pflash,format=raw,readonly=on,file=$pflash_vars
$qemuopts"
+ else
+ bios=/usr/share/qemu/OVMF32.fd
+ pflash_code=/usr/share/OVMF/OVMF32_CODE_4M.secboot.fd
+ pflash_vars=/usr/share/OVMF/OVMF32_VARS_4M.fd
+ if [ -f "$bios" ]; then
+ qemuopts="-bios $bios $qemuopts"
+ elif [ -f "$pflash_code" ]; then
+ qemuopts="-drive
if=pflash,format=raw,readonly=on,file=$pflash_code $qemuopts"
+ qemuopts="-drive
if=pflash,format=raw,readonly=on,file=$pflash_vars $qemuopts"
+ else
+ echo "Firmware not found, please make sure $bios or both
$pflash_code and $pflash_vars exist." >&2
+ exit 1
+ fi
+ fi
+ qemuopts="-machine q35,accel=tcg $qemuopts"
;;
x86_64-efi)
qemu=qemu-system-x86_64
boot=cd
console=console
trim=1
- qemuopts="-bios OVMF.fd $qemuopts"
+ bios=${srcdir}/OVMF.fd
+ pflash_code=${srcdir}/OVMF_CODE.fd
+ pflash_vars=${srcdir}/OVMF_VARS.fd
+ if [ -f "$bios" ]; then
+ qemuopts="-bios $bios $qemuopts"
+ elif [ -f "$pflash_code" ]; then
+ qemuopts="-drive if=pflash,format=raw,readonly=on,file=$pflash_code
$qemuopts"
+ qemuopts="-drive if=pflash,format=raw,readonly=on,file=$pflash_vars
$qemuopts"
+ else
+ bios=/usr/share/qemu/OVMF.fd
+ pflash_code=/usr/share/OVMF/OVMF_CODE.fd
+ pflash_vars=/usr/share/OVMF/OVMF_VARS.fd
+ if [ -f "$bios" ]; then
+ qemuopts="-bios $bios $qemuopts"
+ elif [ -f "$pflash_code" ]; then
+ qemuopts="-drive
if=pflash,format=raw,readonly=on,file=$pflash_code $qemuopts"
+ qemuopts="-drive
if=pflash,format=raw,readonly=on,file=$pflash_vars $qemuopts"
+ else
+ echo "Firmware not found, please make sure $bios or both
$pflash_code and $pflash_vars exist." >&2
+ exit 1
+ fi
+ fi
;;
arm64-efi)
qemu=qemu-system-aarch64
boot=hd
console=console
trim=1
- qemuopts="-machine virt -cpu cortex-a57 -bios
/usr/share/qemu-efi/QEMU_EFI.fd $qemuopts"
+ bios=${srcdir}/AAVMF.fd
+ pflash_code=${srcdir}/AAVMF_CODE.fd
+ pflash_vars=${srcdir}/AAVMF_VARS.fd
+ if [ -f "$bios" ]; then
+ qemuopts="-bios $bios $qemuopts"
+ elif [ -f "$pflash_code" ]; then
+ qemuopts="-drive if=pflash,format=raw,readonly=on,file=$pflash_code
$qemuopts"
+ qemuopts="-drive if=pflash,format=raw,readonly=on,file=$pflash_vars
$qemuopts"
+ else
+ bios=/usr/share/qemu-efi-aarch64/QEMU_EFI.fd
+ pflash_code=/usr/share/AAVMF/AAVMF_CODE.fd
+ pflash_vars=/usr/share/AAVMF/AAVMF_VARS.fd
+ if [ -f "$bios" ]; then
+ qemuopts="-bios $bios $qemuopts"
+ elif [ -f "$pflash_code" ]; then
+ qemuopts="-drive
if=pflash,format=raw,readonly=on,file=$pflash_code $qemuopts"
+ qemuopts="-drive
if=pflash,format=raw,readonly=on,file=$pflash_vars $qemuopts"
+ else
+ echo "Firmware not found, please make sure $bios or both
$pflash_code and $pflash_vars exist." >&2
+ exit 1
+ fi
+ fi
+ qemuopts="-machine virt -cpu cortex-a57 $qemuopts"
disk="device virtio-blk-device,drive=hd1 -drive if=none,id=hd1,file="
serial_port=
;;
@@ -203,7 +268,29 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}"
in
boot=hd
console=console
trim=1
- qemuopts="-machine virt -bios /usr/share/ovmf-arm/QEMU_EFI.fd $qemuopts"
+ bios=${srcdir}/AAVMF32.fd
+ pflash_code=${srcdir}/AAVMF32_CODE.fd
+ pflash_vars=${srcdir}/AAVMF32_VARS.fd
+ if [ -f "$bios" ]; then
+ qemuopts="-bios $bios $qemuopts"
+ elif [ -f "$pflash_code" ]; then
+ qemuopts="-drive if=pflash,format=raw,readonly=on,file=$pflash_code
$qemuopts"
+ qemuopts="-drive if=pflash,format=raw,readonly=on,file=$pflash_vars
$qemuopts"
+ else
+ bios=/usr/share/AAVMF/AAVMF32.fd
+ pflash_code=/usr/share/AAVMF/AAVMF32_CODE.fd
+ pflash_vars=/usr/share/AAVMF/AAVMF32_VARS.fd
+ if [ -f "$bios" ]; then
+ qemuopts="-bios $bios $qemuopts"
+ elif [ -f "$pflash_code" ]; then
+ qemuopts="-drive
if=pflash,format=raw,readonly=on,file=$pflash_code $qemuopts"
+ qemuopts="-drive
if=pflash,format=raw,readonly=on,file=$pflash_vars $qemuopts"
+ else
+ echo "Firmware not found, please make sure $bios or both
$pflash_code and $pflash_vars exist." >&2
+ exit 1
+ fi
+ fi
+ qemuopts="-machine virt $qemuopts"
disk="device virtio-blk-device,drive=hd1 -drive if=none,id=hd1,file="
serial_port=efi0
;;
--
2.27.0
- [PATCH v2 02/12] grub-shell: Trim line should always be matched from the beginning of the line, (continued)
- [PATCH v2 02/12] grub-shell: Trim line should always be matched from the beginning of the line, Glenn Washburn, 2022/01/01
- [PATCH v2 03/12] grub-shell: Only show grub-mkrescue output if it returns an error, Glenn Washburn, 2022/01/01
- [PATCH v2 04/12] grub-shell: Allow setting default timeout via GRUB_SHELL_DEFAULT_TIMEOUT envvar, Glenn Washburn, 2022/01/01
- [PATCH v2 06/12] grub-shell: Add grub output logfile with grub-shell --debug, Glenn Washburn, 2022/01/01
- [PATCH v2 07/12] grub-shell: Set exit status to qemu exit status, Glenn Washburn, 2022/01/01
- [PATCH v2 05/12] grub-shell: Put all generated files into working dir and use better file names, Glenn Washburn, 2022/01/01
- [PATCH v2 09/12] grub-shell: Add --verbose to mkrescue when $debug is greater than 2, Glenn Washburn, 2022/01/01
- [PATCH v2 08/12] tests: Allow turning on shell tracing from environment variables, Glenn Washburn, 2022/01/01
- [PATCH v2 10/12] grub-shell: Only turn on qemu head when large debug value is specified, Glenn Washburn, 2022/01/01
- [PATCH v2 11/12] grub-shell: Use malta qemu-mips machine type instead off non-existant indy, Glenn Washburn, 2022/01/01
- [PATCH v2 12/12] grub-shell: Add flexibility in QEMU firmware handling,
Glenn Washburn <=