1.8: fix(ohcldiag-dev): treat GUID-shaped VM args as names, not IDs (#4042) - #4061
Merged
moor-coding merged 1 commit intoJul 30, 2026
Conversation
Commit b4ad915 made `VmId::from_str` try to parse bare and `hyperv:`-prefixed arguments as a GUID first, treating a successful parse as a VM ID. In the fleet, Hyper-V VM names are themselves GUID-shaped, so a name was misinterpreted as a VM ID and used directly as the AF_HYPERV connect address instead of being resolved via `hvc.exe id <name>`. The bogus address produced `WSAEADDRNOTAVAIL` (os error 10049), breaking all ohcldiag-dev interactions on TiP. Make ID-vs-name resolution deterministic instead of shape-based: - `hyperv-id:GUID` -> VM ID (new, explicit; the only way to look up by ID) - `hyperv:NAME` -> name (even if GUID-shaped) - bare value -> name (unless it is a unix socket path -> vsock) Also change `FromStr::Err` from `Infallible` to `ParseVmIdError` so an explicit `hyperv-id:` with an invalid GUID reports a clear parse error rather than silently falling through to a name lookup. Behavior change: callers relying on a bare GUID being interpreted as a VM ID (introduced in microsoft#3753) must now use the `hyperv-id:` prefix.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR backports the ohcldiag-dev VM-argument parsing fix to release/1.8.2607, making Hyper-V VM lookup deterministic so GUID-shaped fleet VM names are no longer misinterpreted as VM IDs (the regression introduced by attempting GUID parsing first).
Changes:
- Introduces an explicit
hyperv-id:GUIDprefix to opt into direct Hyper-V VM-ID addressing;hyperv:and bare values are treated as VM names (even if GUID-shaped). - Updates
VmId::FromStrto emit a concrete parse error (ParseVmIdError) for invalidhyperv-id:GUIDs. - Adds Windows-gated unit tests covering the intended parse behaviors.
Comments suppressed due to low confidence (1)
openhcl/ohcldiag-dev/src/main.rs:390
ParseVmIdErrorcurrently has all variants gated with#[cfg(windows)], so on non-Windows it becomes an empty enum while still derivingthiserror::Error. Gating the whole type to Windows (and removing the per-variant cfg) avoids the empty-enum edge case and makes the cfg intent explicit.
/// Error parsing a [`VmId`].
#[derive(Debug, Error)]
enum ParseVmIdError {
#[cfg(windows)]
#[error("invalid VM ID GUID '{0}' (expected a GUID, with or without braces)")]
|
|
||
| impl FromStr for VmId { | ||
| type Err = Infallible; | ||
| type Err = ParseVmIdError; |
Comment on lines
+1171
to
+1174
| #[test] | ||
| fn hyperv_id_prefix_with_invalid_guid_errors() { | ||
| assert!("hyperv-id:not-a-guid".parse::<VmId>().is_err()); | ||
| } |
Brian-Perkins
approved these changes
Jul 28, 2026
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.
Backport of #4042 to
release/1.8.2607.Why this is needed for 1.8
This regression (introduced by #3753, which is present on
release/1.8.2607) breaks allohcldiag-devinteractions against fleet VMs — it is currently blocking Underhill 1.8 memory validation on TiP.Problem
#3753 changed
VmId::from_strto tryparse::<guid::Guid>()first for bare andhyperv:-prefixed arguments, treating any successful parse as a VM ID. In the fleet, Hyper-V VM names are themselves GUID-shaped, so a name is misinterpreted as a VM ID and used directly as the AF_HYPERV connect address — instead of being resolved to the real VM ID viahvc.exe id <name>. The bogus address produces:Fix
Make ID-vs-name resolution deterministic instead of inferring intent from the string's shape:
hyperv-id:GUID→ VM ID (new, explicit prefix — the only way to look up by ID)hyperv:NAME→ name (even if GUID-shaped)vsock:PATH→ hybrid vsock (unchanged)Also change
FromStr::ErrfromInfallibletoParseVmIdErrorso an explicithyperv-id:with an invalid GUID reports a clear parse error.Behavior change
Callers relying on a bare GUID being interpreted as a VM ID (introduced in #3753) must now use the
hyperv-id:prefix.Testing
mainfix (no conflicts).VmId::from_strcovering each parse path.cargo check(Linux) +cargo clippy --all-targets/cargo doc --no-deps(x86_64-pc-windows-msvc) clean against the 1.8 toolchain (1.95.0).Depends on #4042 (original merge to
main).