@@ -6,7 +6,8 @@ PREFIX=%%PREFIX%%
66LOCALBASE=%%LOCALBASE%%
77VERSION=%%VERSION%%
88GUEST_ROOT=%%GUEST_ROOT%%
9- SCRIPT=${PREFIX} /sbin/wifibox
9+ SCRIPT=" ${PREFIX} " /sbin/wifibox
10+ BOOTROOM=" ${LOCALBASE} " /share/uefi-firmware/BHYVE_UEFI.fd
1011LOGDIR=/var/log
1112RUNDIR=/var/run/wifibox
1213CONFDIR=${PREFIX} /etc/wifibox
@@ -51,10 +52,10 @@ KERNEL_PATH=$(${SYSCTL} -n kern.module_path | ${SED} -E 's/^([^;]*);.*/\1/')
5152: " ${LS:=/ bin/ ls} "
5253: " ${SEQ:=/ usr/ bin/ seq} "
5354
54- : " ${GRUB_BHYVE:= ${LOCALBASE} / sbin/ grub-bhyve} "
5555: " ${SOCAT:= ${LOCALBASE} / bin/ socat} "
5656
57- DISK_IMAGE=" ${GUEST_ROOT} /disk.img"
57+ ESP_IMAGE=" ${GUEST_ROOT} /esp.img"
58+ ROOT_IMAGE=" ${GUEST_ROOT} /root.img"
5859
5960NMDM_DEVICE=/dev/nmdm-wifibox
6061NMDM_A=" ${NMDM_DEVICE} .1A"
@@ -588,7 +589,6 @@ assert_value_yesno() {
588589# shellcheck disable=SC2086
589590vm_manager () {
590591 local _max_vmm_cpus
591- local _nmdm_grub_bhyve
592592 local _nmdm_bhyve
593593 local _passthru_bhyve
594594 local _tap_bhyve
@@ -598,10 +598,6 @@ vm_manager() {
598598 local _app_conf_ptr=" ${CONFDIR} /app_config"
599599 local _app_conf_mode
600600 local _app_conf_bhyve
601- local _grub_bhyve_args
602- local _grub_bhyve_exit_code
603- local _grub_device_map=" ${GUEST_ROOT} /device.map"
604- local _grub_cfg=" ${GUEST_ROOT} /grub.cfg"
605601 local _nice_priority
606602 local _bhyve_args
607603 local _bhyve_devs
@@ -619,7 +615,6 @@ vm_manager() {
619615
620616 if [ " ${console} " = " yes" ]; then
621617 assert_nmdm_loaded
622- _nmdm_grub_bhyve=" -c ${NMDM_A} "
623618 _nmdm_bhyve=" -l com1,${NMDM_A} "
624619 log info " Guest console is configured to use"
625620 else
@@ -661,21 +656,22 @@ vm_manager() {
661656 exit 5
662657 fi
663658
664- log info " Launching guest ${WIFIBOX_VM} from ${GUEST_ROOT} with grub-bhyve "
659+ log info " Launching guest ${WIFIBOX_VM} from ${GUEST_ROOT} via UEFI "
665660
666- if [ ! -f " ${_grub_cfg } " ]; then
667- log error " ${_grub_cfg } could not be found, guest cannot be started"
661+ if [ ! -f " ${ESP_IMAGE } " ]; then
662+ log error " ${ESP_IMAGE } could not be found, guest cannot be started"
668663 quit_daemonization
669664 exit 4
670665 fi
671666
672- if [ ! -f " ${DISK_IMAGE } " ]; then
673- log error " ${DISK_IMAGE } could not be found, guest cannot be started"
667+ if [ ! -f " ${ROOT_IMAGE } " ]; then
668+ log error " ${ROOT_IMAGE } could not be found, guest cannot be started"
674669 quit_daemonization
675670 exit 4
676671 fi
677672
678- _bhyve_devs=" virtio-blk,${DISK_IMAGE} "
673+ _bhyve_devs=" ${_bhyve_devs} virtio-blk,${ESP_IMAGE} "
674+ _bhyve_devs=" ${_bhyve_devs} virtio-blk,${ROOT_IMAGE} "
679675 _bhyve_devs=" ${_bhyve_devs} virtio-9p,config=${CONFDIR} /appliance,ro"
680676 _bhyve_devs=" ${_bhyve_devs} virtio-9p,var=${RUNDIR} /appliance"
681677 _app_conf=$( ${READLINK} -f " %Y" ${_app_conf_ptr} )
@@ -697,28 +693,6 @@ vm_manager() {
697693 fi
698694
699695 log debug " Devices: ${_bhyve_devs} "
700-
701- _grub_bhyve_args=" "
702- _grub_bhyve_args=" ${_grub_bhyve_args} -S -M ${memory} "
703- _grub_bhyve_args=" ${_grub_bhyve_args} -r host ${_nmdm_grub_bhyve} "
704- [ -f " ${_grub_device_map} " ] \
705- && _grub_bhyve_args=" ${_grub_bhyve_args} -m ${_grub_device_map} "
706- _grub_bhyve_args=" ${_grub_bhyve_args} -d ${GUEST_ROOT} ${WIFIBOX_VM} "
707-
708- log debug " Arguments: ${_grub_bhyve_args} "
709- ${GRUB_BHYVE} ${_grub_bhyve_args} 2>&1 | capture_output debug grub-bhyve
710- _grub_bhyve_exit_code=" $? "
711-
712- if [ " ${_grub_bhyve_exit_code} " -ne " 0" ]; then
713- destroy_vm
714-
715- log debug " exit_code=${_grub_bhyve_exit_code} "
716- log info " grub-bhyve failed to start, signaling restart after 5 seconds"
717-
718- ${SLEEP} 5 2>&1 | capture_output debug sleep
719- exit 1
720- fi
721-
722696 log info " Launching guest ${WIFIBOX_VM} from ${GUEST_ROOT} with bhyve"
723697
724698 _bhyve_args=" "
@@ -727,6 +701,7 @@ vm_manager() {
727701 _bhyve_args=" ${_bhyve_args} ${_nmdm_bhyve} "
728702 _bhyve_args=" ${_bhyve_args} -s 0,hostbridge"
729703 _bhyve_args=" ${_bhyve_args} -s 31,lpc"
704+ _bhyve_args=" ${_bhyve_args} -l bootrom,${BOOTROOM} "
730705 _slot=0
731706
732707 for dev in ${_bhyve_devs} ; do
0 commit comments