[shimV2] refactor SCSI package to unify the interfaces with build tagged files#2666
Open
rawahars wants to merge 3 commits intomicrosoft:mainfrom
Open
[shimV2] refactor SCSI package to unify the interfaces with build tagged files#2666rawahars wants to merge 3 commits intomicrosoft:mainfrom
rawahars wants to merge 3 commits intomicrosoft:mainfrom
Conversation
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
helsaawy
requested changes
Apr 8, 2026
| // GuestSCSIMounter mounts a virtual disk partition inside an LCOW guest. | ||
| type GuestSCSIMounter interface { | ||
| // AddLCOWMappedVirtualDisk maps a virtual disk partition into the LCOW guest. | ||
| AddLCOWMappedVirtualDisk(ctx context.Context, settings guestresource.LCOWMappedVirtualDisk) error |
Contributor
There was a problem hiding this comment.
can we propagate the lcow/wcow build tags to internal\vm\guestmanager\scsi*, internal\protocol\guestresource, and related packages so this just becomes:
//
// internal/controller/device/scsi/mount/mount_lcow.go
//
type GuestSCSIMounter interface {
AddMappedVirtualDisk(ctx context.Context, settings guestresource.MappedVirtualDisk) error
}
//
// internal/controller/device/scsi/mount/mount_wcow.go
//
// GuestSCSIMounter mounts a virtual disk partition inside an WCOW guest.
type GuestSCSIMounter interface {
AddMappedVirtualDisk(ctx context.Context, settings guestresource.MappedVirtualDisk) error
AddMappedVirtualDiskForContainerScratch(ctx context.Context, settings guestresource.MappedVirtualDisk) error
}(though internal\protocol\ LCOW files would need linux || lcow build tags, and the WCOW guest resources should be moved to hcs\schema2)
Contributor
Author
There was a problem hiding this comment.
I have propagated the tags to all files under internal\vm\guestmanager.
Though I am skeptical about changing internal\protocol\guestresources as of now. We can perhaps tackle this part later on as we refactor the old shim.
helsaawy
reviewed
Apr 8, 2026
Comment on lines
+68
to
+72
| slices.EqualFunc( | ||
| slices.SortedFunc(slices.Values(c.Options), cmpFoldCase), | ||
| slices.SortedFunc(slices.Values(other.Options), cmpFoldCase), | ||
| strings.EqualFold, | ||
| ) |
Contributor
There was a problem hiding this comment.
Suggested change
| slices.EqualFunc( | |
| slices.SortedFunc(slices.Values(c.Options), cmpFoldCase), | |
| slices.SortedFunc(slices.Values(other.Options), cmpFoldCase), | |
| strings.EqualFold, | |
| ) | |
| slices.EqualFunc( | |
| slices.SortFunc(c.Options, cmpFoldCase), | |
| slices.SortFunc(other.Options, cmpFoldCase), | |
| strings.EqualFold, | |
| ) |
or
Suggested change
| slices.EqualFunc( | |
| slices.SortedFunc(slices.Values(c.Options), cmpFoldCase), | |
| slices.SortedFunc(slices.Values(other.Options), cmpFoldCase), | |
| strings.EqualFold, | |
| ) | |
| slices.Equal( | |
| slices.Sort(lo.Map(c.Options, strings.ToLower)), | |
| slices.Sort(lo.Map(other.Options, strings.ToLower)), | |
| ) |
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
This pull request refactors the SCSI controller guest interface to use a unified
GuestSCSIOpsabstraction instead of separate Linux and Windows guest operation interfaces. It also updates the related tests to use a single mock guest implementation and adds new LCOW-specific tests. Additionally, the CI workflow is updated to build and test both LCOW and WCOW tagged packages.It also moves the
Configto the specificlcoworwcowimplementation so that only the applicable options are available.Abstraction and Interface Refactoring:
Controllerstruct and its constructor now use a singleGuestSCSIOpsinterface for guest operations, replacing the previousLinuxGuestSCSIOpsandWindowsGuestSCSIOpsfields and parameters. All guest operation calls in the controller are updated to use this unified interface.Test Suite Updates:
The SCSI controller tests are refactored to use a single
mockGuestOpsimplementation, removing the separate mock types for Linux and Windows guest operations. Test helpers and test cases are updated accordingly.Adds a new
controller_lcow_test.gofile with LCOW-specific tests for guest mount and unmount error handling, using the new mock guest interface.CI Workflow Enhancements:
.github/workflows/ci.ymlto build and test LCOW and WCOW tagged packages for shimV2, ensuring both variants are covered in CI.