mirror of
https://github.com/oSoWoSo/DistroHopper.git
synced 2024-08-14 22:46:53 +00:00
Allow overriding some VM arguments via env vars (#519)
* allow overriding MACHINE_TYPE,MAC_DISK_DEV,NET_DEVICE,SMM via env vars * allow overriding EFI_CODE,EFI_EXTRA_VARS
This commit is contained in:
parent
1b1bd84e6a
commit
8e8c65eac6
1 changed files with 57 additions and 67 deletions
124
quickemu
124
quickemu
|
@ -212,7 +212,7 @@ function vm_boot() {
|
|||
local DISK_USED=""
|
||||
local DISPLAY_DEVICE=""
|
||||
local DISPLAY_RENDER=""
|
||||
local EFI_CODE=""
|
||||
local EFI_CODE="${EFI_CODE}"
|
||||
local EFI_VARS=""
|
||||
local GUEST_CPU_CORES=""
|
||||
local GUEST_CPU_LOGICAL_CORES=""
|
||||
|
@ -226,13 +226,13 @@ function vm_boot() {
|
|||
local KERNEL_NODE=""
|
||||
local KERNEL_VER="?"
|
||||
local LSB_DESCRIPTION="Unknown OS"
|
||||
local MACHINE_TYPE="q35"
|
||||
local MACHINE_TYPE="${MACHINE_TYPE:-q35}"
|
||||
local MAC_BOOTLOADER=""
|
||||
local MAC_MISSING=""
|
||||
local MAC_DISK_DEV="ide-hd,bus=ahci.2"
|
||||
local NET_DEVICE="virtio-net"
|
||||
local MAC_DISK_DEV="${MAC_DISK_DEV:-ide-hd,bus=ahci.2}"
|
||||
local NET_DEVICE="${NET_DEVICE:-virtio-net}"
|
||||
local OSK=""
|
||||
local SMM="off"
|
||||
local SMM="${SMM:-off}"
|
||||
local USB_HOST_PASSTHROUGH_CONTROLLER="qemu-xhci"
|
||||
local VIDEO=""
|
||||
|
||||
|
@ -379,69 +379,59 @@ function vm_boot() {
|
|||
# does not support SMM.
|
||||
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1929357#c5
|
||||
case ${secureboot} in
|
||||
on)
|
||||
if [ -e "/usr/share/OVMF/OVMF_CODE_4M.secboot.fd" ]; then
|
||||
EFI_CODE="/usr/share/OVMF/OVMF_CODE_4M.secboot.fd"
|
||||
efi_vars "/usr/share/OVMF/OVMF_VARS_4M.fd" "${EFI_VARS}"
|
||||
elif [ -e "/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd" ]; then
|
||||
EFI_CODE="/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd"
|
||||
efi_vars "/usr/share/edk2/ovmf/OVMF_VARS.fd" "${EFI_VARS}"
|
||||
elif [ -e "/usr/share/OVMF/x64/OVMF_CODE.secboot.fd" ]; then
|
||||
EFI_CODE="/usr/share/OVMF/x64/OVMF_CODE.secboot.fd"
|
||||
efi_vars "/usr/share/OVMF/x64/OVMF_VARS.fd" "${EFI_VARS}"
|
||||
elif [ -e "/usr/share/edk2-ovmf/OVMF_CODE.secboot.fd" ]; then
|
||||
EFI_CODE="/usr/share/edk2-ovmf/OVMF_CODE.secboot.fd"
|
||||
efi_vars "/usr/share/edk2-ovmf/OVMF_VARS.fd" "${EFI_VARS}"
|
||||
elif [ -e "/usr/share/qemu/ovmf-x86_64-smm-ms-code.bin" ]; then
|
||||
EFI_CODE="/usr/share/qemu/ovmf-x86_64-smm-ms-code.bin"
|
||||
efi_vars "/usr/share/qemu/ovmf-x86_64-smm-ms-vars.bin" "${EFI_VARS}"
|
||||
elif [ -e "/usr/share/qemu/edk2-x86_64-secure-code.fd" ]; then
|
||||
EFI_CODE="/usr/share/qemu/edk2-x86_64-secure-code.fd"
|
||||
efi_vars "/usr/share/qemu/edk2-x86_64-code.fd" "${EFI_VARS}"
|
||||
# Solus new place to hide
|
||||
elif [ -e "/usr/share/edk2-ovmf/x64/OVMF_CODE.secboot.fd" ]; then
|
||||
EFI_CODE="/usr/share/edk2-ovmf/x64/OVMF_CODE.secboot.fd"
|
||||
efi_vars "/usr/share/edk2-ovmf/x64/OVMF_VARS.fd" "${EFI_VARS}"
|
||||
else
|
||||
echo "ERROR! SecureBoot was requested but no SecureBoot capable firmware was found."
|
||||
echo " Please install OVMF firmware."
|
||||
exit 1
|
||||
if [ ! -z "${EFI_CODE}" ] || [ ! -e "${EFI_CODE}" ]; then
|
||||
case ${secureboot} in
|
||||
on)
|
||||
ovmfs=("/usr/share/OVMF/OVMF_CODE_4M.secboot.fd","/usr/share/OVMF/OVMF_VARS_4M.fd" \
|
||||
"/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd","/usr/share/edk2/ovmf/OVMF_VARS.fd" \
|
||||
"/usr/share/OVMF/x64/OVMF_CODE.secboot.fd","/usr/share/OVMF/x64/OVMF_VARS.fd" \
|
||||
"/usr/share/edk2-ovmf/OVMF_CODE.secboot.fd","/usr/share/edk2-ovmf/OVMF_VARS.fd" \
|
||||
"/usr/share/qemu/ovmf-x86_64-smm-ms-code.bin","/usr/share/qemu/ovmf-x86_64-smm-ms-vars.bin" \
|
||||
"/usr/share/qemu/edk2-x86_64-secure-code.fd","/usr/share/qemu/edk2-x86_64-code.fd" \
|
||||
"/usr/share/edk2-ovmf/x64/OVMF_CODE.secboot.fd","/usr/share/edk2-ovmf/x64/OVMF_VARS.fd"
|
||||
)
|
||||
;;
|
||||
*)
|
||||
ovmfs=("/usr/share/OVMF/OVMF_CODE_4M.fd","/usr/share/OVMF/OVMF_VARS_4M.fd" \
|
||||
"/usr/share/edk2/ovmf/OVMF_CODE.fd","/usr/share/edk2/ovmf/OVMF_VARS.fd" \
|
||||
"/usr/share/OVMF/OVMF_CODE.fd","/usr/share/OVMF/OVMF_VARS.fd" \
|
||||
"/usr/share/OVMF/x64/OVMF_CODE.fd","/usr/share/OVMF/x64/OVMF_VARS.fd" \
|
||||
"/usr/share/edk2-ovmf/OVMF_CODE.fd","/usr/share/edk2-ovmf/OVMF_VARS.fd" \
|
||||
"/usr/share/qemu/ovmf-x86_64-4m-code.bin","/usr/share/qemu/ovmf-x86_64-4m-vars.bin" \
|
||||
"/usr/share/qemu/edk2-x86_64-code.fd","/usr/share/qemu/edk2-x86_64-code.fd" \
|
||||
"/usr/share/edk2-ovmf/x64/OVMF_CODE.fd","/usr/share/edk2-ovmf/x64/OVMF_VARS.fd"
|
||||
)
|
||||
;;
|
||||
esac
|
||||
# Attempt each EFI_CODE file one by one, selecting the corresponding code and vars
|
||||
# when an existing file is found.
|
||||
_IFS=$IFS
|
||||
IFS=","
|
||||
for f in "${ovmfs[@]}"; do
|
||||
set -- $f;
|
||||
if [ -e "${1}" ]; then
|
||||
EFI_CODE="${1}"
|
||||
EFI_EXTRA_VARS="${2}"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [ -e "/usr/share/OVMF/OVMF_CODE_4M.fd" ]; then
|
||||
EFI_CODE="/usr/share/OVMF/OVMF_CODE_4M.fd"
|
||||
efi_vars "/usr/share/OVMF/OVMF_VARS_4M.fd" "${EFI_VARS}"
|
||||
elif [ -e "/usr/share/edk2/ovmf/OVMF_CODE.fd" ]; then
|
||||
EFI_CODE="/usr/share/edk2/ovmf/OVMF_CODE.fd"
|
||||
efi_vars "/usr/share/edk2/ovmf/OVMF_VARS.fd" "${EFI_VARS}"
|
||||
elif [ -e "/usr/share/OVMF/OVMF_CODE.fd" ]; then
|
||||
EFI_CODE="/usr/share/OVMF/OVMF_CODE.fd"
|
||||
efi_vars "/usr/share/OVMF/OVMF_VARS.fd" "${EFI_VARS}"
|
||||
elif [ -e "/usr/share/OVMF/x64/OVMF_CODE.fd" ]; then
|
||||
EFI_CODE="/usr/share/OVMF/x64/OVMF_CODE.fd"
|
||||
efi_vars "/usr/share/OVMF/x64/OVMF_VARS.fd" "${EFI_VARS}"
|
||||
elif [ -e "/usr/share/edk2-ovmf/OVMF_CODE.fd" ]; then
|
||||
EFI_CODE="/usr/share/edk2-ovmf/OVMF_CODE.fd"
|
||||
efi_vars "/usr/share/edk2-ovmf/OVMF_VARS.fd" "${EFI_VARS}"
|
||||
elif [ -e "/usr/share/qemu/ovmf-x86_64-4m-code.bin" ]; then
|
||||
EFI_CODE="/usr/share/qemu/ovmf-x86_64-4m-code.bin"
|
||||
efi_vars "/usr/share/qemu/ovmf-x86_64-4m-vars.bin" "${EFI_VARS}"
|
||||
elif [ -e "/usr/share/qemu/edk2-x86_64-code.fd" ]; then
|
||||
EFI_CODE="/usr/share/qemu/edk2-x86_64-code.fd"
|
||||
efi_vars "/usr/share/qemu/edk2-x86_64-code.fd" "${EFI_VARS}"
|
||||
# Solus
|
||||
elif [ -e "/usr/share/edk2-ovmf/x64/OVMF_CODE.fd" ]; then
|
||||
EFI_CODE="/usr/share/edk2-ovmf/x64/OVMF_CODE.fd"
|
||||
efi_vars "/usr/share/edk2-ovmf/x64/OVMF_VARS.fd" "${EFI_VARS}"
|
||||
else
|
||||
echo "ERROR! EFI boot requested but no EFI firmware found."
|
||||
echo " Please install OVMF firmware."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
IFS=$_IFS
|
||||
fi
|
||||
if [ -z "${EFI_CODE}" ] || [ ! -e "${EFI_CODE}" ]; then
|
||||
if [ "$secureboot" == "on" ]; then
|
||||
echo "ERROR! SecureBoot was requested but no SecureBoot capable firmware was found."
|
||||
else
|
||||
echo "ERROR! EFI boot requested but no EFI firmware found."
|
||||
fi
|
||||
echo " Please install OVMF firmware."
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -z "${EFI_EXTRA_VARS}" ]; then
|
||||
if [ ! -e "${EFI_EXTRA_VARS}" ]; then
|
||||
echo " - EFI: ERROR! EFI_EXTRA_VARS file ${EFI_EXTRA_VARS} does not exist."
|
||||
exit 1
|
||||
fi
|
||||
efi_vars "${EFI_EXTRA_VARS}" "${EFI_VARS}"
|
||||
fi
|
||||
|
||||
# Make sure EFI_VARS references an actual, writeable, file
|
||||
if [ ! -f "${EFI_VARS}" ] || [ ! -w "${EFI_VARS}" ]; then
|
||||
|
|
Loading…
Reference in a new issue