Skip to content

Read NetBSD system, firmware and baseboard values from machdep.dmi - #3816

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:netbsd-dmi
Oct 17, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:netbsd-dmi

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

NetBSD shares BsdComputerSystem with OpenBSD, and that class reads OpenBSD's hw.vendor, hw.product, hw.version, hw.serialno and hw.uuid sysctls. NetBSD has none of them, so every ComputerSystem and Baseboard value was unknown. Firmware was unknown too: it parsed OpenBSD's bios0: dmesg lines, which NetBSD does not print. With the model unknown, VirtualizationDetector fell back to the network card's MAC address prefix. That is how a QEMU/KVM guest on cfarm428 was reported as Microsoft Hyper-V.

NetBSD publishes the SMBIOS strings under machdep.dmi (sys/dev/smbios_platform.c).

Changes

  • BsdComputerSystem's four hw.* lookups are now protected methods. OpenBSD's behaviour is unchanged, and NetBSD stays on the shared base, which BsdComputerSystemTest requires.
  • NetBsdComputerSystem overrides those lookups and reads a single sysctl machdep.dmi listing. The baseboard uses the board-* values and falls back to the system values when the firmware has no baseboard table, as FreeBSD does.
  • NetBsdFirmware reads bios-vendor, bios-version and bios-date. The date is converted from the kernel's YYYYMMDD by a new ParseUtil.parseYyyyMmDdToIso.
  • The kernel marks system-serial, system-uuid, board-serial and chassis-serial CTLFLAG_PRIVATE, so those values are reported only to root.

Testing

  • cfarm428, a NetBSD 10.1 aarch64 KVM guest. JNA without the native library, JNA with it, and FFM give identical output:
    • System: QEMU, KVM Virtual Machine.
    • Baseboard: the system values.
    • Virtualization: QEMU, where it was Microsoft Hyper-V before.
    • Firmware: unknown, because this VM publishes no BIOS table.
  • x86, the NetBSD CI VM, through a one-off diagnostic workflow on my fork:
    • System: QEMU, Standard PC (i440FX + PIIX, 1996).
    • Firmware: SeaBIOS 1.17.0-debian-1.17.0-1ubuntu1, release date 2014-04-01.
    • Virtualization: QEMU.
    • Run as root, the UUID is reported. Run as an unprivileged user, the serial numbers and UUID are unknown, matching sysctl itself.
  • New unit tests cover the machdep.dmi parsing and the date conversion. The full gate passes, including -Perror-prone.
  • Not tested: a physical NetBSD machine with a baseboard table. The board-* path is covered only by the fixture test.

Summary by CodeRabbit

  • Bug Fixes
    • Improved hardware identification on NetBSD by reading system, baseboard, and firmware details from SMBIOS data. Virtual machine identification now uses system serial numbers and UUIDs rather than network card information.
    • Formatted NetBSD firmware dates as YYYY-MM-DD; unavailable dates remain empty.
    • Serial numbers and UUIDs from SMBIOS data require root access.

NetBSD shared BsdComputerSystem with OpenBSD, which reads OpenBSD's
hw.vendor, hw.product, hw.version, hw.serialno and hw.uuid sysctls.
NetBSD has none of them, so every ComputerSystem and Baseboard value
was unknown, and the firmware parser looked for OpenBSD's bios0 dmesg
lines, which NetBSD does not print. With the model unknown, virtual
machines were identified from the network card's MAC address prefix
instead.

The base's four hw.* lookups are now protected methods. NetBSD
overrides them to read one `sysctl machdep.dmi` listing, and builds the
baseboard from the board-* values, falling back to the system values
where the firmware has no baseboard table, as FreeBSD does. NetBsdFirmware
reads bios-vendor, bios-version and bios-date, the last converted from
the kernel's YYYYMMDD by a new ParseUtil.parseYyyyMmDdToIso.

The serial numbers and UUID are CTLFLAG_PRIVATE in the kernel, so they
are reported only to root.

Verified on a NetBSD 10.1 aarch64 KVM guest (JNA with and without the
native library, and FFM) and on the x86 NetBSD CI VM, as root and as an
unprivileged user.
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a837ff13-704e-4acb-9544-ebe85a691f15
📥 Commits

Reviewing files that changed from the base of the PR and between 34d0794 and 32b4e95.

📒 Files selected for processing: 8
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdFirmware.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/unix/BsdComputerSystemTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdComputerSystemTest.java
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout: 5
  • GitHub Check: Test JDK 25, OpenIndiana
  • GitHub Check: Test JDK 25, OpenBSD
  • GitHub Check: Test JDK 25, NetBSD
  • GitHub Check: Test JDK 25, windows-latest
  • GitHub Check: Analyze (java)
🧰 Additional context used
📚 Code guidelines: 2
AGENTS.md — unknown
CONTRIBUTING.md — unknown
📓 Path-based instructions: 2
Source excerpt: **Banned APIs** (`config/forbidden-apis.txt` and friends, enforced by `forbiddenapis:check`): `oshi-common` may not reference `com.sun.jna.**`, `java.lang.foreign.**`, or any `System.load`/`loadLibrary`.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdComputerSystemTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/unix/BsdComputerSystemTest.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdFirmware.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdComputerSystem.java
Applicability reference: AGENTS.md: # AGENTS.md Instructions for AI coding agents working in the OSHI repository.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • CHANGELOG.md
🔇 Additional comments: 8
oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdComputerSystem.java: 1

18-19: LGTM!

Also applies to: 31-31, 33-33, 35-35, 37-37, 71-76, 80-85, 89-94, 98-103

oshi-common/src/test/java/oshi/hardware/common/platform/unix/BsdComputerSystemTest.java: 1

23-24: LGTM!

Also applies to: 57-57

oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdComputerSystem.java: 1

7-12: LGTM!

Also applies to: 15-15, 18-21, 24-26, 31-33, 35-53, 60-73, 75-98

oshi-common/src/main/java/oshi/util/ParseUtil.java: 1

81-81: LGTM!

Also applies to: 1002-1014

oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdFirmware.java: 1

7-9: LGTM!

Also applies to: 13-14, 17-18, 23-28

oshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdComputerSystemTest.java: 1

1-50: LGTM!

oshi-common/src/test/java/oshi/util/ParseUtilTest.java: 1

758-765: LGTM!

CHANGELOG.md: 1

23-23: LGTM!

📝 Walkthrough

NetBSD now reads system, baseboard, and firmware values from machdep.dmi. Shared BSD computer-system queries are overridable, and ParseUtil converts compact dates to ISO format.

Changes: NetBSD DMI hardware data

Layer / File(s) Summary
Make shared BSD queries overridable
oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdComputerSystem.java, oshi-common/src/test/java/oshi/hardware/common/platform/unix/BsdComputerSystemTest.java
The shared computer-system property suppliers now call protected instance query methods. Test comments describe the shared implementation and platform-specific firmware types.
Read NetBSD hardware values from DMI
oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdComputerSystem.java, oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdFirmware.java, oshi-common/src/main/java/oshi/util/ParseUtil.java, oshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdComputerSystemTest.java, oshi-common/src/test/java/oshi/util/ParseUtilTest.java, CHANGELOG.md
NetBSD system and baseboard properties now use parsed machdep.dmi values, with system-value fallbacks for unknown board values. Firmware reads BIOS vendor, version, and date values. ParseUtil converts eight-digit dates to ISO format. Tests cover DMI parsing and date conversion. The changelog records the root requirement for serial numbers and UUIDs and the use of these values for VM identification.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 32b4e

No merge-blocking issue was found in the reviewed NetBSD hardware-data changes.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 36.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 7 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the primary change: reading NetBSD system, firmware, and baseboard values from machdep.dmi.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 36.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 7 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

I’m a rabbit with a curious nose,
I sniff out DMI where the hardware data flows.
Eight neat digits get their hyphens in a row,
Board and firmware values join the show.
I nibble a byte, then hop through the snow.

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.42857% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.87%. Comparing base (34d0794) to head (32b4e95).

Files with missing lines Patch % Lines
...mon/platform/unix/netbsd/NetBsdComputerSystem.java 94.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3816      +/-   ##
============================================
+ Coverage     80.85%   80.87%   +0.01%     
  Complexity      648      648              
============================================
  Files           725      725              
  Lines         26020    26044      +24     
  Branches       4419     4422       +3     
============================================
+ Hits          21038    21062      +24     
- Misses         2764     2767       +3     
+ Partials       2218     2215       -3     
Flag Coverage Δ
freebsd 37.14% <53.57%> (+0.01%) ⬆️
linux 41.16% <53.57%> (+0.01%) ⬆️
macos 42.29% <53.57%> (-0.04%) ⬇️
netbsd 36.47% <96.42%> (+0.05%) ⬆️
openbsd 37.02% <53.57%> (+0.01%) ⬆️
solaris 38.30% <53.57%> (+0.01%) ⬆️
windows 48.56% <53.57%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dbwiddis
dbwiddis merged commit fa905e3 into oshi:master Oct 17, 2026
20 checks passed
@dbwiddis
dbwiddis deleted the netbsd-dmi branch October 17, 2026 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant