Skip to content

Read FreeBSD graphics card IDs from either pciconf format - #3805

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:freebsd-pciconf-graphics
Oct 14, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:freebsd-pciconf-graphics

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

HardwareAbstractionLayer.getGraphicsCards() on FreeBSD parses pciconf -lv, and had two problems on current releases.

Device ID always unknown. The parser read IDs only from chip=0xDDDDVVVV. FreeBSD now prints them separately in the header line:

vgapci0@pci0:0:1:0:	class=0x030000 rev=0x02 hdr=0x00 vendor=0x1234 device=0x1111 subvendor=0x1af4 subdevice=0x1100

DragonFly BSD, which uses the same class, still prints chip=.

Vendor leaked from the previous device. The vendor was never reset at a new header, and the indented vendor = '...' line only appears when the PCI ID database knows the IDs. On cfarm430 the QEMU display has neither name line, so it reported the host bridge's Intel Corporation.

Change

Parsing moves into a package-private parsePciconf(List<String>). Each header line starts a fresh holder for that device, the header is read for either ID format, and the card is built when the next device starts. The output shape is unchanged: vendor Name (0xVVVV) (or just the ID when there is no name line), device ID 0xDDDD, version rev=0xRR. No JNA/FFM changes — both backends, and DragonFly, call this class.

Verification

host before after
cfarm430, FreeBSD 16 (QEMU stdvga) vendor=Intel Corporation, deviceId=unknown vendor=0x1234, deviceId=0x1111
cfarm152, DragonFly 6.4 (Virtio GPU) Red Hat, Inc. (0x1af4), 0x1050 unchanged

FreeBsdGraphicsCardTest uses pciconf -lv output captured on both hosts, including the leak case. The one named FreeBSD card in the fixture (Intel UHD 620) is written in the current format rather than captured — neither host has a GPU the PCI database names. Gate clean on oshi-common including -Perror-prone.

Summary by CodeRabbit

  • Bug Fixes
    • Improved graphics-card detection on current FreeBSD releases by correctly reading vendor and device information from supported system output formats.
    • Fixed cases where a graphics card could appear with an unknown device ID or incorrect vendor information copied from a preceding PCI device.

FreeBSD's pciconf -lv now prints vendor=0xVVVV device=0xDDDD in each
header line rather than the chip=0xDDDDVVVV that the parser looked for, so
every card reported an unknown device ID. The vendor was also never reset
between devices: a card with no vendor name line, such as QEMU's display
whose IDs the PCI database does not know, reported the vendor name of the
device listed before it.

Parsing moves into parsePciconf, which collects each device's fields into
its own holder, reads either ID format (DragonFly BSD still prints chip=),
and keeps the existing output shape. Tested with real output from FreeBSD 16
and DragonFly 6.4, and verified live on both.
@coderabbitai

coderabbitai Bot commented Oct 14, 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: 8f823a91-2031-432c-9f13-fac384ddcb79
📥 Commits

Reviewing files that changed from the base of the PR and between c36f940 and 25fa7bb.

📒 Files selected for processing: 3
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdGraphicsCard.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdGraphicsCardTest.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: 14
  • GitHub Check: Test JDK 25, OpenBSD
  • GitHub Check: Test JDK 25, OpenIndiana
  • GitHub Check: Test JDK 25, NetBSD
  • GitHub Check: Test JDK 25, FreeBSD
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, windows-latest
  • GitHub Check: Test JDK 25, ubuntu-latest
  • GitHub Check: Test JDK 21, ubuntu-latest
  • GitHub Check: Test JDK 25, macos-latest
  • GitHub Check: Error Prone
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Lint (Spotless, Checkstyle)
  • GitHub Check: Lint (ForbiddenAPIs, Javadoc, SLF4J)
  • GitHub Check: Analyze (java)
🧰 Additional context used
📚 Code guidelines: 2
AGENTS.md — auto-discovered
CONTRIBUTING.md — auto-discovered
📓 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/hardware/common/platform/unix/freebsd/FreeBsdGraphicsCardTest.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdGraphicsCard.java
Source excerpt: The Changelog lets users know what's changed.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • CHANGELOG.md
🔇 Additional comments: 3
oshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdGraphicsCard.java: 1

11-11: LGTM!

Also applies to: 47-47, 59-59, 63-63, 66-66, 78-78, 101-101, 108-108, 112-112, 128-128

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

20-20: LGTM!

Also applies to: 24-24, 46-46, 65-65, 85-85, 95-95

CHANGELOG.md: 1

17-17: LGTM!

📝 Walkthrough

The FreeBSD graphics-card parser now reads vendor and device IDs from separate or combined pciconf fields. It tracks values per device, returns display-class cards, and includes tests for FreeBSD and DragonFly BSD output.

Changes: Graphics-card parsing

Layer / File(s) Summary
Parse and validate PCI device records
oshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdGraphicsCard.java, oshi-common/src/test/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdGraphicsCardTest.java, CHANGELOG.md
getGraphicsCards passes command output to parsePciconf. The parser supports separate vendor/device IDs and combined chip IDs, and keeps values scoped to each device. Tests cover FreeBSD and DragonFly BSD fixtures, display-card fields, and empty input. The changelog records the parsing fix.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 25fa7

No actionable issue is identified; this change is ready for normal merge checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. (1 skipped: 1… 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 main change: supporting both FreeBSD pciconf graphics-card ID formats.
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 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. (1 skipped: 1 unsupported.)

  • 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

A rabbit checks each PCI line,
And keeps each card’s IDs in line.
A chip field joins the vendor’s name,
Two formats now produce the same.
The cards hop out, their fields all right,
Then rest in lists sealed up tight.

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

@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.76%. Comparing base (c36f940) to head (25fa7bb).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...mon/platform/unix/freebsd/FreeBsdGraphicsCard.java 90.00% 1 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             master    #3805    +/-   ##
==========================================
  Coverage     80.76%   80.76%            
- Complexity       83      663   +580     
==========================================
  Files           725      725            
  Lines         25979    26026    +47     
  Branches       4426     4423     -3     
==========================================
+ Hits          20981    21019    +38     
- Misses         2772     2782    +10     
+ Partials       2226     2225     -1     
Flag Coverage Δ
freebsd 37.03% <90.00%> (+0.05%) ⬆️
linux 41.16% <87.50%> (+0.16%) ⬆️
macos 42.29% <87.50%> (+0.13%) ⬆️
netbsd 36.39% <87.50%> (+0.13%) ⬆️
openbsd 36.99% <87.50%> (+0.16%) ⬆️
solaris 38.30% <87.50%> (+0.17%) ⬆️
windows 48.55% <87.50%> (+0.14%) ⬆️

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 d798725 into oshi:master Oct 14, 2026
20 checks passed
@dbwiddis
dbwiddis deleted the freebsd-pciconf-graphics branch October 14, 2026 02:07
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