Skip to content

hcs: add driver interface for HCS system and process operations#2644

Open
shreyanshjain7174 wants to merge 1 commit intomicrosoft:mainfrom
shreyanshjain7174:hcs/system-driver-interface
Open

hcs: add driver interface for HCS system and process operations#2644
shreyanshjain7174 wants to merge 1 commit intomicrosoft:mainfrom
shreyanshjain7174:hcs/system-driver-interface

Conversation

@shreyanshjain7174
Copy link
Contributor

The HCS layer (internal/hcs/system.go, process.go) calls vmcompute.dll directly 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 to computecore.dll for Live Migration support.

This adds an internal hcsDriver interface that wraps all vmcompute system and process API calls. The System struct now holds a driver field — defaulting to vmcomputeDriver, 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.

@shreyanshjain7174 shreyanshjain7174 requested a review from a team as a code owner March 23, 2026 11:06
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>
@shreyanshjain7174 shreyanshjain7174 force-pushed the hcs/system-driver-interface branch from 1302dde to 3a910f6 Compare March 23, 2026 11:14
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