Skip to content

[shimV2] refactor SCSI package to unify the interfaces with build tagged files#2666

Merged
rawahars merged 5 commits intomicrosoft:mainfrom
rawahars:scsi_refactor
Apr 9, 2026
Merged

[shimV2] refactor SCSI package to unify the interfaces with build tagged files#2666
rawahars merged 5 commits intomicrosoft:mainfrom
rawahars:scsi_refactor

Conversation

@rawahars
Copy link
Copy Markdown
Contributor

@rawahars rawahars commented Apr 8, 2026

Summary

This pull request refactors the SCSI controller guest interface to use a unified GuestSCSIOps abstraction 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 Config to the specific lcow or wcow implementation so that only the applicable options are available.

Abstraction and Interface Refactoring:

  • The Controller struct and its constructor now use a single GuestSCSIOps interface for guest operations, replacing the previous LinuxGuestSCSIOps and WindowsGuestSCSIOps fields 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 mockGuestOps implementation, 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.go file with LCOW-specific tests for guest mount and unmount error handling, using the new mock guest interface.

CI Workflow Enhancements:

  • Updates .github/workflows/ci.yml to build and test LCOW and WCOW tagged packages for shimV2, ensuring both variants are covered in CI.

rawahars added 2 commits April 8, 2026 05:19
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
@@ -0,0 +1,17 @@
//go:build windows && !wcow && !lcow
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need these? If the entire package is windows && (wcow || lcow) nothing not those could build right? So there is no unsupported tag orientation right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great idea. Let me add tags to the entire package which would eliminate the need for unsupported.

// [StateMounted] state. It does not transition the state; that is handled
// by the caller in [Mount.UnmountFromGuest].
func (m *Mount) unmountLCOW(ctx context.Context, guest LinuxGuestSCSIUnmounter) error {
func (m *Mount) unmountPartition(ctx context.Context, guest GuestSCSIUnmounter) error {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Since this is a mount, I hear you that it's technically a block device partition, but... I think its better to just call it unmount. The term "partition" is overloaded and is immediately confusing on what this is doing to me.

// [StateMounted] state. It does not transition the state; that is handled
// by the caller in [Mount.UnmountFromGuest].
func (m *Mount) unmountWCOW(ctx context.Context, guest WindowsGuestSCSIUnmounter) error {
func (m *Mount) unmountPartition(ctx context.Context, guest GuestSCSIUnmounter) error {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, I'd prefer just unmount.

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
@rawahars rawahars merged commit 7d2ae21 into microsoft:main Apr 9, 2026
32 of 33 checks passed
@rawahars rawahars deleted the scsi_refactor branch April 9, 2026 22:57
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.

4 participants