Add support for arch and fedora qemu and new boot option

This commit is contained in:
isa 2024-07-03 14:08:40 -04:00
parent 5a94898101
commit 4be661e88c

View File

@ -4,13 +4,8 @@ EXTRA_KERNEL_CMDLINE=""
SCRIPT=$(realpath ${BASH_SOURCE})
BUILD_ROOT=$(realpath $(dirname ${SCRIPT})/../build)
SYSROOT=${BUILD_ROOT}/tmp-glibc/work/x86_64-linux/qemu-helper-native/1.0-r1/recipe-sysroot-native
QEMU=${SYSROOT}/usr/bin/qemu-system-x86_64
if [[ ! -f ${QEMU} ]]; then
>&2 printf "Qemu binary not found at: ${QEMU}\n"
exit 1
fi
SYSROOT=${BUILD_ROOT}/tmp-glibc/work/x86_64-linux/qemu-helper-native/1.0/recipe-sysroot-native
QEMU=qemu-system-x86_64
ENABLE_KVM="--enable-kvm -cpu host"
@ -19,9 +14,14 @@ if [[ ! -c "/dev/kvm" ]]; then
ENABLE_KVM=""
fi
EFI_BIOS="-bios /usr/share/qemu/OVMF.fd"
if [[ ! -f "/usr/share/qemu/OVMF.fd" ]]; then
printf "Disabling EFI boot because OVMF.fd not found in /usr/share/qemu\n"
if [[ -f "/usr/share/qemu/OVMF.fd" ]]; then
printf "Using EFI boot because OVMF.fd found in /usr/share/qemu/\n"
EFI_BIOS="-bios /usr/share/qemu/OVMF.fd"
elif [[ -f "/usr/share/edk2-ovmf/x64/OVMF.fd" ]]; then # fedora and arch
printf "Using EFI boot because OVMF.fd found in /usr/share/edk2-ovmf/x64/\n"
EFI_BIOS="-bios /usr/share/edk2-ovmf/x64/OVMF.fd"
else
printf "Disabling EFI boot because OVMF.fd not found\n"
EFI_BIOS=""
fi
@ -70,6 +70,14 @@ while [[ $# -gt 0 ]]; do
BOOT_TARGET="installer"
shift
;;
boot-to-install)
BOOT_TARGET="boot-to-install"
shift
;;
boot-installed)
BOOT_TARGET="boot-installed"
shift
;;
--help)
usage
;;
@ -101,6 +109,27 @@ boot_installer() {
fi
}
# qemu-img create -f qcow2 qemu_disk/citadel_disk.qcow2 -o size=50G,preallocation=metadata
# mount -t 9p -o trans=virtio,version=9p2000.L shared /mnt/my9p
boot_to_install() {
if [ ! -f qemu_disk/citadel_disk.qcow2 ]; then
mkdir qemu_disk
qemu-img create -f qcow2 qemu_disk/citadel_disk.qcow2 -o size=50G,preallocation=metadata
fi
CITADEL_QEMU_ARGS+=" -drive format=raw,file=${BUILD_ROOT}/images/citadel-installer.img -drive format=qcow2,file=${BUILD_ROOT}/../qemu_disk/citadel_disk.qcow2"
echo "${QEMU} ${CITADEL_QEMU_ARGS}"
${QEMU} ${CITADEL_QEMU_ARGS}
}
boot_installed() {
CITADEL_QEMU_ARGS+=" -drive format=qcow2,file=${BUILD_ROOT}/../qemu_disk/citadel_disk.qcow2"
echo "${QEMU} ${CITADEL_QEMU_ARGS}"
${QEMU} ${CITADEL_QEMU_ARGS}
}
boot_kernel() {
EXTRA_OPTIONS=""
KERNEL_IMAGE="bzImage"
@ -124,6 +153,10 @@ if [[ ${BOOT_TARGET} = "kernel" ]]; then
boot_kernel
elif [[ ${BOOT_TARGET} = "installer" ]]; then
boot_installer
elif [[ ${BOOT_TARGET} = "boot-to-install" ]]; then
boot_to_install
elif [[ ${BOOT_TARGET} = "boot-installed" ]]; then
boot_installed
else
usage
fi