[Midnightbsd-cvs] [MidnightBSD/mports] 806639: sysutils/vm-bhyve: fix UEFI and other version chec...

Lucas Holt noreply at github.com
Tue Sep 15 11:56:32 EDT 2026


  Branch: refs/heads/master
  Home:   https://github.com/MidnightBSD/mports
  Commit: 806639a9ce6cb15739c371f4bb7f71ea721caf03
      https://github.com/MidnightBSD/mports/commit/806639a9ce6cb15739c371f4bb7f71ea721caf03
  Author: Lucas Holt <luke at foolishgames.com>
  Date:   2026-09-15 (Tue, 15 Sep 2026)

  Changed paths:
    M sysutils/vm-bhyve/Makefile
    A sysutils/vm-bhyve/files/patch-lib_vm-base

  Log Message:
  -----------
  sysutils/vm-bhyve: fix UEFI and other version checks on MidnightBSD (#1266)

Fixes UEFI guests being refused on MidnightBSD with:

```
fatal; uefi guests can only be run on FreeBSD 10.3 or newer
```

## Cause

`lib/vm-base` sets `VERSION_BSD=$(uname -K)` and compares it against
`__FreeBSD_version`
values throughout. On MidnightBSD, `uname -K` reports
`__MidnightBSD_version` instead:

```
$ uname -K
400004        # MidnightBSD 4.0.6
```

`400004` is smaller than every FreeBSD threshold in the code, so the
UEFI gate
(`[ ${VERSION_BSD} -lt 1002509 ]`, `lib/vm-run:280`) always fires.

This is not UEFI-specific — all nine `VERSION_BSD` gates took the wrong
branch, silently
disabling features that MidnightBSD 4.0 (FreeBSD 13-stable base) fully
supports:

| Site | Gate | Feature |
|---|---|---|
| `vm-run:280` | `< 1002509` | **UEFI boot (fatal)** |
| `vm-run:145` | `>= 1002000` | UTC time (`-u`) |
| `vm-run:457` | `>= 1004000` | AHCI device limit |
| `vm-run:604` | `< 1100000` | UEFI graphics |
| `vm-run:668` | `< 1100000` | xhci mouse/tablet |
| `vm-run:701` | `< 1102000` | virtio console |
| `vm-run:764` | `>= 1003000` | wired memory (`-S`) |
| `vm-util:364` | `>= 1300000` | VM name limit 229 vs 30 |
| `vm-rctl:67` | `< 1100000` | rctl limits |

## Fix

MidnightBSD exposes no `__FreeBSD_version` at runtime — `kern.osreldate`
and `uname -K`
both return the MidnightBSD value, and `__FreeBSD_version` is only in
`sys/param.h` at
build time. So `lib/vm-base` maps to the FreeBSD base each release
derives from
(4.0+ → 13-stable, 3.2 → 12.4), leaving other platforms untouched.

## Verification

On 4.0.6, before and after:

```
BEFORE: VERSION_BSD=400004
  -> fatal; uefi guests can only be run on FreeBSD 10.3 or newer

AFTER:  VERSION_BSD=1300000
  uefi: PASS   utctime -u: PASS   ahci limit: PASS
  uefi graphics: PASS   xhci mouse: PASS   virtio console: PASS
  wired mem -S: PASS    name len 229: PASS   rctl: PASS
```

Branch coverage:

```
uname -K 302000  -> VERSION_BSD 1204000  uefi:ok  namelen:30    (3.2 / FreeBSD 12.4)
uname -K 400004  -> VERSION_BSD 1300000  uefi:ok  namelen:229   (4.0 / FreeBSD 13)
FreeBSD  1400097 -> VERSION_BSD 1400097  unchanged
```

- `sh -n` clean on all 19 installed scripts
- `bmake patch` / `fake` / `package` clean; `PORTREVISION` bumped
- 1.6.0 is still the latest upstream release (Nov 2024) and has no
MidnightBSD handling,
  so this has to be a local patch

## Pre-existing, not addressed

`portlint` reports 8 `use a tab (not space) after a variable name`
fatals on the
`OPTIONS_*` block (`Makefile:22-30`). Identical count on pristine
`master`; left alone to
keep this diff focused on the bug.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01NSsgED5s7GPYJNb1HxuaU9

## Summary by Sourcery

Fix vm-bhyve feature gating on MidnightBSD by mapping its release
version to the corresponding FreeBSD base version.

Bug Fixes:
- Correct version detection for MidnightBSD so vm-bhyve enables UEFI and
other features supported by its corresponding FreeBSD base.

Build:
- Bump the port revision for the local compatibility fix.

Signed-off-by: Lucas Holt <luke at foolishgames.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply at anthropic.com>



To unsubscribe from these emails, change your notification settings at https://github.com/MidnightBSD/mports/settings/notifications



More information about the Midnightbsd-cvs mailing list