hcs: add driver interface for HCS system and process operations#2644
Open
shreyanshjain7174 wants to merge 1 commit intomicrosoft:mainfrom
Open
hcs: add driver interface for HCS system and process operations#2644shreyanshjain7174 wants to merge 1 commit intomicrosoft:mainfrom
shreyanshjain7174 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
The HCS layer (internal/hcs/system.go, process.go) calls vmcompute.dll directly, making it impossible to unit test the System/Process logic or swap the underlying DLL for the upcoming V2 migration (computecore.dll). This change introduces an internal hcsDriver interface that wraps all vmcompute system and process API calls. The System struct now holds a driver field (defaulting to the vmcomputeDriver, which delegates to the existing vmcompute package). Process inherits the driver from its parent System. No behavioral change — the vmcomputeDriver methods are one-liner delegations to the same vmcompute functions previously called directly. This enables writing unit tests against the HCS layer without admin privileges or a live HCS service, by injecting a mock driver. 17 tests are included covering: handle guards, error swallowing, async pending paths, system crash and service disconnect during operations, the waitBackground exit classification, multi-goroutine Wait fan-out, and late callback safety after unregistration. Signed-off-by: Shreyansh Sancheti <shsancheti@microsoft.com>
1302dde to
3a910f6
Compare
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.
The HCS layer (
internal/hcs/system.go,process.go) callsvmcompute.dlldirectly today, which means testing the System/Process lifecycle logic requires admin privileges and a running HCS service. It also means there's no seam for swapping the underlying DLL when we move tocomputecore.dllfor Live Migration support.This adds an internal
hcsDriverinterface that wraps all vmcompute system and process API calls. TheSystemstruct now holds a driver field — defaulting tovmcomputeDriver, which delegates to the existing vmcompute package with one-liner methods. Process inherits the driver from its parent System.No behavioral change. The vmcomputeDriver is a passthrough to the exact same vmcompute functions.
17 unit tests are included that exercise: handle guards, error swallowing on shutdown/terminate, async pending completion via notification channels, system crash during Start, HCS service disconnect during Start, Pause interrupted by system exit, waitBackground exit classification (normal vs unexpected), multi-goroutine Wait fan-out, and late callback arrival after unregistration. All tests run without admin or HCS.