Skip to content

Commit ad5f7b3

Browse files
author
olevole
committed
qemu: proper OVMF args for aarch/riscv
1 parent 99e6974 commit ad5f7b3

File tree

5 files changed

+128
-20
lines changed

5 files changed

+128
-20
lines changed

etc/defaults/qemu-default-default.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ jail_profile="default"
66
# default $jail_profile for jconstruct
77
default_profile="default"
88

9+
# extra custom/user's directory with profiles (additional to ~cbsd/etc/defaults/ + ~cbsd/etc/)
10+
# e.g.: cbsd show_profile_list search_profile=vm-other show_bhyve=1 extra_profile_dir="/root/cbsd-profiles"
11+
extra_profile_dir=
12+
913
emulator="qemu"
1014

1115
# suggest for jail1, jail2, jail3 as new jail name.

etc/defaults/vm-freebsd-FreeBSD-aarch64-14.2.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ default_jailname="freebsd"
3232

3333
vm_arch="aarch64"
3434

35+
machine="virt"
36+
37+
# /usr/local/share/qemu/edk2-aarch64-code.fd
38+
bios="qemu-efi-aarch64"
39+
3540
# disable profile?
3641
xen_active=1
3742
bhyve_active=1
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
vm_profile="Debian-aarch64-12"
2+
# don't remove this line:
3+
vm_os_type="linux"
4+
5+
# this is one-string additional info strings in dialogue menu
6+
long_description="Debian: 12.9.0"
7+
8+
# custom settings:
9+
fetch=1
10+
11+
# Official resources to fetch ISO's
12+
iso_site="https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/ \
13+
https://ftp.acc.umu.se/debian-cd/current/arm64/iso-dvd/ \
14+
http://debian-cd.repulsive.eu/12.9.0/arm64/iso-dvd/ \
15+
https://gensho.ftp.acc.umu.se/debian-cd/current/arm64/iso-dvd/ \
16+
http://mirror.23m.com/debian-cd/12.9.0/arm64/iso-dvd/ \
17+
http://cdimage.debian.org/cdimage/release/12.9.0/arm64/iso-dvd/ \
18+
http://debian.mirror.cambrium.nl/debian-cd/12.9.0/arm64/iso-dvd/ \
19+
http://mirror.overthewire.com.au/debian-cd/12.9.0/arm64/iso-dvd/ \
20+
http://ftp.crifo.org/debian-cd/12.9.0/arm64/iso-dvd/ \
21+
http://debian.cse.msu.edu/debian-cd/12.9.0/arm64/iso-dvd/ \
22+
https://cdimage.debian.org/mirror/cdimage/archive/12.9.0/arm64/iso-dvd/ \
23+
"
24+
25+
# Official CBSD project mirrors ( info: https://github.com/cbsd/mirrors )
26+
cbsd_iso_mirrors="https://mirror.convectix.com/iso/ https://raw.githubusercontent.com/cbsd/mirrors/refs/heads/main/cbsd-iso.txt"
27+
28+
iso_img="debian-12.9.0-arm64-netinst.iso"
29+
30+
# register_iso as:
31+
register_iso_name="cbsd-iso-${iso_img}"
32+
register_iso_as="iso-${iso_img}"
33+
34+
default_jailname="debian"
35+
36+
vm_arch="aarch64"
37+
machine="virt"
38+
39+
# /usr/local/share/qemu/edk2-aarch64-code.fd
40+
bios="qemu-efi-aarch64"
41+
42+
imgsize="10g"
43+
imgsize_min="3g"
44+
45+
# on virtio, Debian installer staled/freezed on Detecting HW stage
46+
#virtio_type="ahci-hd"
47+
virtio_type="virtio-blk"
48+
49+
# VNC
50+
vm_vnc_port="0"
51+
vm_efi="uefi"
52+
53+
# disable profile?
54+
xen_active=1
55+
bhyve_active=1
56+
qemu_active=1
57+
58+
# Available in ClonOS?
59+
clonos_active=1
60+
sha256sum="0"
61+
iso_img_dist_size="3981279232"
62+
63+
# enable birtio RNG interface?
64+
virtio_rnd="1"
65+
66+
# firmware settings
67+
cd_boot_firmware="bhyve"
68+
[ ${freebsdhostversion} -lt 1301510 ] && hdd_boot_firmware="refind"

sudoexec/qcreate

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ ${H3_COLOR}Examples${N0_COLOR}:
123123
# cbsd qcreate jname=c1 vm_ram=4g vm_cpus=2 vm_os_type=freebsd vm_os_profile=cloud-FreeBSD-ufs-x64-13.2 imgsize=20g ci_ip4_addr=10.0.1.88 ci_gw4=10.0.1.3
124124
# cbsd qcreate jname=gateway flavor=small1 vm_os_type=linux vm_os_profile=cloud-Debian-x86-12 ci_ip4_addr=10.0.1.88 ci_gw4=10.0.1.3 ci_interface2=bridge2 ci_ip4_addr2=192.168.0.2 ci_gw42=192.168.0.1
125125

126+
# When qemu-system-aarch64/riscv installed
127+
128+
# cbsd qcreate jname=vm1 vm_os_type=linux vm_os_profile=Debian-aarch64-12 vm_ram=4g vm_cpus=1 imgsize=10g runasap=1
129+
# cbsd qcreate jname=vm1 vm_os_type=freebsd vm_os_profile=FreeBSD-aarch64-14.2 vm_ram=8g vm_cpus=8 imgsize=10g runasap=1 qemu_vnc_tcp_bind="0.0.0.0"
130+
131+
126132
${H3_COLOR}See also${N0_COLOR}:
127133

128134
cbsd qconstruct-tui --help

sudoexec/qstart

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ done
133133

134134
start_qemu()
135135
{
136+
local _use_ovmf=1
136137
local QEMUCFG
137138
local xvm_ram _qemu_bin _log
138139
local _ebytes _dsk_ebytes _cloud_truncate
@@ -435,18 +436,24 @@ start_qemu()
435436
# unset console_args
436437
#fi
437438

438-
if [ "${spice_default}" != "1" ]; then
439-
# init vnc_args
440-
if ! compile_vnc_args ; then
441-
unset vnc_args
439+
echo "XXX: ${nographic}"
440+
441+
if [ "${nographic}" != "1" ]; then
442+
if [ "${spice_default}" != "1" ]; then
443+
# init vnc_args
444+
if ! compile_vnc_args ; then
445+
unset vnc_args
446+
fi
447+
else
448+
# init vnc_args
449+
if ! compile_spice_args ; then
450+
unset vnc_spice
451+
fi
442452
fi
443453
else
444-
# init vnc_args
445-
if ! compile_spice_args ; then
446-
unset vnc_spice
447-
fi
454+
unset vnc_args vnc_spice
455+
vga_args="-nographic"
448456
fi
449-
450457
xvm_ram=$(( vm_ram / 1024 / 1024 ))
451458

452459
# Poehali!
@@ -483,21 +490,39 @@ start_qemu()
483490
# UEFI
484491
ovmf_firmware=
485492

486-
local _valid_ovmf_files="OVMF_CODE_4M.fd OVMF.fd OVMF_CODE.fd QEMU_UEFI-x86_64.fd QEMU_UEFI_CODE-x86_64.fd"
487-
local _valid_ovmf_path_dir="/usr/share/OVMF /usr/share/ovmf /usr/share/edk2/x64 /usr/share/edk2-qemu/x64 /usr/local/share/edk2-qemu"
493+
case "${vm_arch}" in
494+
aarch64)
495+
local _valid_ovmf_files="FVP_AARCH64_EFI.fd QEMU_EFI.fd"
496+
local _valid_ovmf_path_dir="/usr/local/share/edk2-fvp /usr/share/edk2-fvp /usr/share/qemu-efi-aarch64 /usr/local/share/qemu-efi-aarch64 ${cbsd_workdir}/share/qemu-efi-aarch64"
497+
_use_ovmf=1
498+
;;
499+
riscv64)
500+
_use_ovmf=0
501+
;;
502+
*)
503+
local _valid_ovmf_files="OVMF_CODE_4M.fd OVMF.fd OVMF_CODE.fd QEMU_UEFI-x86_64.fd QEMU_UEFI_CODE-x86_64.fd"
504+
local _valid_ovmf_path_dir="/usr/share/OVMF /usr/share/ovmf /usr/share/edk2/x64 /usr/share/edk2-qemu/x64 /usr/local/share/edk2-qemu ${cbsd_workdir}/share/qemu-efi-x64"
505+
_use_ovmf=1
506+
;;
507+
esac
488508

489-
for i in ${_valid_ovmf_files}; do
490-
[ -n "${ovmf_firmware}" ] && break
491-
for j in ${_valid_ovmf_path_dir}; do
509+
if [ ${_use_ovmf} -eq 1 ]; then
510+
511+
for i in ${_valid_ovmf_files}; do
492512
[ -n "${ovmf_firmware}" ] && break
493-
[ -r "${j}/${i}" ] && ovmf_firmware="${j}/${i}"
513+
for j in ${_valid_ovmf_path_dir}; do
514+
[ -n "${ovmf_firmware}" ] && break
515+
[ -r "${j}/${i}" ] && ovmf_firmware="${j}/${i}"
516+
done
494517
done
495-
done
496518

497-
if [ -r "${ovmf_firmware}" ]; then
498-
# UEFI BOOT
499-
uefi_args="-drive if=pflash,format=raw,unit=0,readonly=on,file=${ovmf_firmware}"
500-
uefi_args="${uefi_args} -drive if=pflash,format=raw,unit=1,file=${jailsysdir}/${jname}/BHYVE_UEFI_VARS.fd"
519+
if [ -r "${ovmf_firmware}" ]; then
520+
# UEFI BOOT
521+
uefi_args="-drive if=pflash,format=raw,unit=0,readonly=on,file=${ovmf_firmware}"
522+
uefi_args="${uefi_args} -drive if=pflash,format=raw,unit=1,file=${jailsysdir}/${jname}/BHYVE_UEFI_VARS.fd"
523+
else
524+
uefi_args=
525+
fi
501526
else
502527
uefi_args=
503528
fi

0 commit comments

Comments
 (0)