0.3.1: load vmm/nmdm at runtime and persist vmm_load/nmdm_load in loader.conf.local
This commit is contained in:
1 parent
3eb5e6d013
commit
29365ce649
5 files changed
+51
-8
No files matched your search
@@ -90,13 +90,45 @@ preflight() {
|
||||
log "WARNING: neither /usr/local/sbin/vm nor a bundled vm-bhyve was found"
|
||||
fi
|
||||
|
||||
if ! kldstat -q -n vmm; then
|
||||
log "vmm.ko not loaded, trying kldload"
|
||||
kldload vmm 2>/dev/null || log "WARNING: could not load vmm.ko (needed for bhyve)"
|
||||
ensure_kmods
|
||||
ensure_loader_conf
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- kernel modules
|
||||
ensure_kmods() {
|
||||
for mod in vmm nmdm; do
|
||||
if kldstat -q -n "${mod}"; then
|
||||
continue
|
||||
fi
|
||||
if kldload "${mod}" 2>/dev/null; then
|
||||
log "kldload ${mod}: loaded"
|
||||
elif kldstat -q -n "${mod}"; then
|
||||
log "${mod} already present"
|
||||
else
|
||||
log "WARNING: could not load ${mod}.ko - bhyve will not work until it is loaded"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
ensure_loader_conf() {
|
||||
conf="/boot/loader.conf.local"
|
||||
changed=0
|
||||
if [ ! -f "${conf}" ]; then
|
||||
touch "${conf}" || { log "WARNING: cannot create ${conf}"; return 0; }
|
||||
fi
|
||||
if ! kldstat -q -n nmdm; then
|
||||
log "nmdm.ko not loaded, trying kldload"
|
||||
kldload nmdm 2>/dev/null || log "WARNING: could not load nmdm.ko (needed for serial console)"
|
||||
for entry in 'vmm_load="YES"' 'nmdm_load="YES"'; do
|
||||
key=${entry%%=*}
|
||||
if ! grep -q "^${key}=" "${conf}" 2>/dev/null; then
|
||||
if [ "${changed}" -eq 0 ]; then
|
||||
cp -p "${conf}" "${conf}.vmmngr.bak" 2>/dev/null || true
|
||||
fi
|
||||
printf '%s\n' "${entry}" >> "${conf}"
|
||||
log "added ${entry} to ${conf}"
|
||||
changed=1
|
||||
fi
|
||||
done
|
||||
if [ "${changed}" -eq 1 ]; then
|
||||
log "NOTE: ${conf} changed - modules are loaded at next boot; kldload covers the current session"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -235,6 +267,7 @@ cmd_postinit() {
|
||||
# Runs at boot (rc postinit) on embedded systems. Must be quiet and fast,
|
||||
# and must not touch the config when nothing is missing.
|
||||
rotate_log
|
||||
ensure_kmods
|
||||
do_symlinks
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user