Repository navigation
fix(block/darwin): don't fail on ambiguous ioreg node matches - #475
Merged
Merged
Conversation
getIoregPlist matches ioreg nodes by base name only, not full device tree path, and errored whenever more than one node shared a name. This is reachable on real hardware (e.g. two identically-named Thunderbolt NVMe enclosures) and observed reliably under macOS virtualization, where storage shows up as multiple AppleVirtIOStorageDevice nodes. Fix by walking the IODeviceTree registry plane by the known full path to find the target node's IORegistryEntryID -- a property of the underlying kernel object, so it's the same no matter which plane it's viewed through -- then using that ID to pick the correct candidate out of the (possibly ambiguous) name-based match, instead of guessing. Signed-off-by: Marat Dulin <github-commit@maratd.com>
mdevils
force-pushed
the
fix/darwin-ioreg-ambiguous-match
branch
from
September 23, 2026 08:43
2aac5c2 to
69ce5aa
Compare
joshuar
pushed a commit
to joshuar/go-hass-agent
that referenced
this pull request
Sep 26, 2026
Picks up jaypipes/ghw#475, which #960 was waiting on. Without it test-macos fails on GitHub's runners with an ambiguous ioreg match.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getIoregPlistlooks up anioregnode by base name (ioreg -n <name>) and errored if that returned anything other than exactly one match. Node names aren't guaranteed unique across the device tree, so this failed whenever two devices shared a name.Observed reliably in a macOS virtualization environment (GitHub Actions' macOS runners), where block storage shows up as multiple
AppleVirtIOStorageDevicenodes:The same failure mode is reachable on real hardware too (e.g. two identically-named Thunderbolt NVMe enclosures), just less commonly hit.
Fix
Rather than guessing (e.g. taking the first match), this resolves the ambiguity properly:
IODeviceTreeregistry plane, following the known full path (DeviceTreePath, e.g.arm-io@10F00000/ans@77400000/...), to find the exact target node and itsIORegistryEntryID.IORegistryEntryIDis a property of the underlying kernel object, so it's identical no matter which registry plane the object is viewed through (verified against real hardware: the same ID shows up whether queried via-p IODeviceTreeor the default plane).Device tree path segments are reconstructed as
IORegistryEntryName+@+IORegistryEntryLocation(Open Firmware "name@unit-address" convention), which matchesDeviceTreePath's format exactly.Also handles disks with no real device tree entry (synthesized/virtual volumes reporting
DeviceTreePath: "IODeviceTree:/") by skipping them, matching the original behavior for that case.Test plan
TestFindEntryID, which builds a tree with two identically-named nodes at different paths and confirms each resolves to its own distinct, correctIORegistryEntryID-- directly reproducing the ambiguity that broke CI.go build ./...,go vet ./pkg/block/..., existingTestStorageControllerFromPliststill passes.ghw.Block()against real hardware (M-series MacBook Pro): all fields (includingVendor, previously always empty due to a decode-target mismatch) come back identical to before this change.