0.3.1: load vmm/nmdm at runtime and persist vmm_load/nmdm_load in loader.conf.local

This commit is contained in:
Claw committed 2026-11-17 20:16:17 +01:00
1 parent 3eb5e6d013
commit 29365ce649
5 files changed
+51 -8

No files matched your search

+5
View File
@@ -449,6 +449,11 @@ function vmm_selfcheck(): array
'vmm' => trim((string)@shell_exec('kldstat -q -n vmm && echo loaded || echo missing')), 'vmm' => trim((string)@shell_exec('kldstat -q -n vmm && echo loaded || echo missing')),
'nmdm' => trim((string)@shell_exec('kldstat -q -n nmdm && echo loaded || echo missing')), 'nmdm' => trim((string)@shell_exec('kldstat -q -n nmdm && echo loaded || echo missing')),
], ],
'loader_conf' => [
'file' => '/boot/loader.conf.local',
'vmm' => (bool)preg_match('/^vmm_load=/m', (string)@file_get_contents('/boot/loader.conf.local')),
'nmdm' => (bool)preg_match('/^nmdm_load=/m', (string)@file_get_contents('/boot/loader.conf.local')),
],
]; ];
$out['vm']['version'] = $vm['available'] ? vmm_vm_version() : []; $out['vm']['version'] = $vm['available'] ? vmm_vm_version() : [];
$out['datastores'] = $vm['available'] ? vmm_datastores() : []; $out['datastores'] = $vm['available'] ? vmm_datastores() : [];
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"appname": "VM Manager", "appname": "VM Manager",
"version": "0.3.0", "version": "0.3.1",
"rootfolder": "/mnt/Daten/extensions/vmmngr", "rootfolder": "/mnt/Daten/extensions/vmmngr",
"vm_source": "auto", "vm_source": "auto",
"bridges": ["ix0bridge"], "bridges": ["ix0bridge"],
+5
View File
@@ -33,6 +33,11 @@ vmm_nav('config'); ?>
vmm: <span class="<?=$sc['kld']['vmm'] === 'loaded' ? 'vmm-ok' : 'vmm-miss';?>"><?=vmm_h($sc['kld']['vmm']);?></span> · vmm: <span class="<?=$sc['kld']['vmm'] === 'loaded' ? 'vmm-ok' : 'vmm-miss';?>"><?=vmm_h($sc['kld']['vmm']);?></span> ·
nmdm: <span class="<?=$sc['kld']['nmdm'] === 'loaded' ? 'vmm-ok' : 'vmm-miss';?>"><?=vmm_h($sc['kld']['nmdm']);?></span> nmdm: <span class="<?=$sc['kld']['nmdm'] === 'loaded' ? 'vmm-ok' : 'vmm-miss';?>"><?=vmm_h($sc['kld']['nmdm']);?></span>
</td></tr> </td></tr>
<tr><td class="celltag"><?=gettext('Boot-time modules');?></td><td class="celldata vmm-mono">
<?=$sc['loader_conf']['file'];?>:
vmm_load=<?=$sc['loader_conf']['vmm'] ? 'YES' : 'no';?> ·
nmdm_load=<?=$sc['loader_conf']['nmdm'] ? 'YES' : 'no';?>
</td></tr>
<tr><td class="celltag"><?=gettext('Virtual machines');?></td><td class="celldata"><?=$sc['vm_count'];?> <?=gettext('total');?>, <?=$sc['vm_running'];?> <?=gettext('running');?></td></tr> <tr><td class="celltag"><?=gettext('Virtual machines');?></td><td class="celldata"><?=$sc['vm_count'];?> <?=gettext('total');?>, <?=$sc['vm_running'];?> <?=gettext('running');?></td></tr>
<?php $b = vmm_ram_budget(); ?> <?php $b = vmm_ram_budget(); ?>
<tr><td class="celltag"><?=gettext('RAM budget');?></td><td class="celldata"><?=vmm_human_bytes(vmm_ram_used());?> <?=gettext('in use');?> · <?=gettext('limit');?> <?=vmm_human_bytes($b['limit']);?> (<?=$b['pct'];?>% <?=gettext('of');?> <?=vmm_human_bytes($b['total']);?>)</td></tr> <tr><td class="celltag"><?=gettext('RAM budget');?></td><td class="celldata"><?=vmm_human_bytes(vmm_ram_used());?> <?=gettext('in use');?> · <?=gettext('limit');?> <?=vmm_human_bytes($b['limit']);?> (<?=$b['pct'];?>% <?=gettext('of');?> <?=vmm_human_bytes($b['total']);?>)</td></tr>
+1 -1
View File
@@ -1 +1 @@
0.3.0 0.3.1
+39 -6
View File
@@ -90,13 +90,45 @@ preflight() {
log "WARNING: neither /usr/local/sbin/vm nor a bundled vm-bhyve was found" log "WARNING: neither /usr/local/sbin/vm nor a bundled vm-bhyve was found"
fi fi
if ! kldstat -q -n vmm; then ensure_kmods
log "vmm.ko not loaded, trying kldload" ensure_loader_conf
kldload vmm 2>/dev/null || log "WARNING: could not load vmm.ko (needed for bhyve)" }
# ---------------------------------------------------------------- kernel modules
ensure_kmods() {
for mod in vmm nmdm; do
if kldstat -q -n "${mod}"; then
continue
fi fi
if ! kldstat -q -n nmdm; then if kldload "${mod}" 2>/dev/null; then
log "nmdm.ko not loaded, trying kldload" log "kldload ${mod}: loaded"
kldload nmdm 2>/dev/null || log "WARNING: could not load nmdm.ko (needed for serial console)" 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
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 fi
} }
@@ -235,6 +267,7 @@ cmd_postinit() {
# Runs at boot (rc postinit) on embedded systems. Must be quiet and fast, # Runs at boot (rc postinit) on embedded systems. Must be quiet and fast,
# and must not touch the config when nothing is missing. # and must not touch the config when nothing is missing.
rotate_log rotate_log
ensure_kmods
do_symlinks do_symlinks
} }