diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e6ae0606d6..756a964558 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -333,7 +333,11 @@ jobs: run: ${{ env.GOTESTSUM_CMD }} -gcflags=all=-d=checkptr -tags wcow -timeout=10m ./... - name: Run non-functional tests - run: ${{ env.GOTESTSUM_CMD }} -mod=mod -gcflags=all=-d=checkptr ./internal/... ./pkg/... ./parity/... + run: ${{ env.GOTESTSUM_CMD }} -mod=mod -gcflags=all=-d=checkptr ./internal/... ./pkg/... + working-directory: test + + - name: Run lcow parity tests + run: ${{ env.GOTESTSUM_CMD }} -mod=mod -gcflags=all=-d=checkptr -tags lcow ./parity/... working-directory: test - name: Build and run containerd-shim-runhcs-v1 tests diff --git a/internal/builder/vm/lcow/boot.go b/internal/builder/vm/lcow/boot.go index 84ca89c957..302bbf6c99 100644 --- a/internal/builder/vm/lcow/boot.go +++ b/internal/builder/vm/lcow/boot.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && lcow package lcow diff --git a/internal/builder/vm/lcow/confidential.go b/internal/builder/vm/lcow/confidential.go index 6837b10327..7192f599c1 100644 --- a/internal/builder/vm/lcow/confidential.go +++ b/internal/builder/vm/lcow/confidential.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && lcow package lcow diff --git a/internal/builder/vm/lcow/devices.go b/internal/builder/vm/lcow/devices.go index 3dbcf5d7ec..3eb4fe5b1b 100644 --- a/internal/builder/vm/lcow/devices.go +++ b/internal/builder/vm/lcow/devices.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && lcow package lcow diff --git a/internal/builder/vm/lcow/doc.go b/internal/builder/vm/lcow/doc.go index aebb1818c2..802573c3a5 100644 --- a/internal/builder/vm/lcow/doc.go +++ b/internal/builder/vm/lcow/doc.go @@ -1,3 +1,5 @@ +//go:build windows && lcow + // Package lcow encapsulates the business logic to parse annotations, devices, // and runhcs options into an hcsschema.ComputeSystem document which will be used // by the shim to create UVMs (Utility VMs) via the Host Compute Service (HCS). diff --git a/internal/builder/vm/lcow/kernel_args.go b/internal/builder/vm/lcow/kernel_args.go index b47a47a7d7..ba3fa243a5 100644 --- a/internal/builder/vm/lcow/kernel_args.go +++ b/internal/builder/vm/lcow/kernel_args.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && lcow package lcow diff --git a/internal/builder/vm/lcow/sandbox_options.go b/internal/builder/vm/lcow/sandbox_options.go index 397b57c069..b0b71e00c7 100644 --- a/internal/builder/vm/lcow/sandbox_options.go +++ b/internal/builder/vm/lcow/sandbox_options.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && lcow package lcow diff --git a/internal/builder/vm/lcow/specs.go b/internal/builder/vm/lcow/specs.go index 71f9b4bb6f..49415d59c3 100644 --- a/internal/builder/vm/lcow/specs.go +++ b/internal/builder/vm/lcow/specs.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && lcow package lcow diff --git a/internal/builder/vm/lcow/specs_test.go b/internal/builder/vm/lcow/specs_test.go index fb5673aad8..b7a6cddd74 100644 --- a/internal/builder/vm/lcow/specs_test.go +++ b/internal/builder/vm/lcow/specs_test.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && lcow package lcow diff --git a/internal/builder/vm/lcow/topology.go b/internal/builder/vm/lcow/topology.go index 7cc8c53dd4..6f8273d609 100644 --- a/internal/builder/vm/lcow/topology.go +++ b/internal/builder/vm/lcow/topology.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && lcow package lcow diff --git a/internal/controller/device/plan9/controller_test.go b/internal/controller/device/plan9/controller_test.go index 1f49d7b908..a77f3c0dd1 100644 --- a/internal/controller/device/plan9/controller_test.go +++ b/internal/controller/device/plan9/controller_test.go @@ -49,12 +49,12 @@ type combinedGuest struct { unmounter *mountmocks.MockGuestPlan9Unmounter } -func (g *combinedGuest) AddLCOWMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error { - return g.mounter.AddLCOWMappedDirectory(ctx, settings) +func (g *combinedGuest) AddMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error { + return g.mounter.AddMappedDirectory(ctx, settings) } -func (g *combinedGuest) RemoveLCOWMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error { - return g.unmounter.RemoveLCOWMappedDirectory(ctx, settings) +func (g *combinedGuest) RemoveMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error { + return g.unmounter.RemoveMappedDirectory(ctx, settings) } type testController struct { @@ -217,7 +217,7 @@ func TestMapToGuest_HappyPath(t *testing.T) { id, _ := tc.c.Reserve(tc.ctx, share.Config{HostPath: "/host/path"}, mount.Config{}) tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil) - tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) guestPath, err := tc.c.MapToGuest(tc.ctx, id) if err != nil { @@ -256,7 +256,7 @@ func TestMapToGuest_GuestMountFails_RetryMapToGuest_Fails(t *testing.T) { // First MapToGuest: VM add succeeds, guest mount fails. tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil) - tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(errMount) + tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(errMount) _, err := tc.c.MapToGuest(tc.ctx, id) if err == nil { @@ -289,7 +289,7 @@ func TestMapToGuest_GuestMountFails_UnmapFromGuest_CleansUp(t *testing.T) { // MapToGuest: VM add succeeds, guest mount fails. tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil) - tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(errMount) + tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(errMount) _, err := tc.c.MapToGuest(tc.ctx, id) if err == nil { @@ -315,7 +315,7 @@ func TestMapToGuest_GuestMountFails_UnmapFromGuest_CleansUp(t *testing.T) { } // TestMapToGuest_SharedPath_VMAddCalledOnce verifies that when two reservations -// share the same host path, AddPlan9 and AddLCOWMappedDirectory are each called +// share the same host path, AddPlan9 and AddMappedDirectory are each called // exactly once — the second MapToGuest is a no-op that returns the existing // guest path. func TestMapToGuest_SharedPath_VMAddCalledOnce(t *testing.T) { @@ -325,9 +325,9 @@ func TestMapToGuest_SharedPath_VMAddCalledOnce(t *testing.T) { id1, _ := tc.c.Reserve(tc.ctx, share.Config{HostPath: "/host/path"}, mount.Config{}) id2, _ := tc.c.Reserve(tc.ctx, share.Config{HostPath: "/host/path"}, mount.Config{}) - // AddPlan9 and AddLCOWMappedDirectory each called exactly once. + // AddPlan9 and AddMappedDirectory each called exactly once. tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil).Times(1) - tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil).Times(1) + tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil).Times(1) gp1, err := tc.c.MapToGuest(tc.ctx, id1) if err != nil { @@ -356,10 +356,10 @@ func TestUnmapFromGuest_HappyPath(t *testing.T) { id, _ := tc.c.Reserve(tc.ctx, share.Config{HostPath: "/host/path"}, mount.Config{}) tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil) - tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) _, _ = tc.c.MapToGuest(tc.ctx, id) - tc.guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + tc.guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) tc.vmRemove.EXPECT().RemovePlan9(gomock.Any(), gomock.Any()).Return(nil) if err := tc.c.UnmapFromGuest(tc.ctx, id); err != nil { @@ -383,11 +383,11 @@ func TestUnmapFromGuest_GuestUnmountFails_Retryable(t *testing.T) { id, _ := tc.c.Reserve(tc.ctx, share.Config{HostPath: "/host/path"}, mount.Config{}) tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil) - tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) _, _ = tc.c.MapToGuest(tc.ctx, id) // First unmap: guest unmount fails. - tc.guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(errUnmount) + tc.guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(errUnmount) if err := tc.c.UnmapFromGuest(tc.ctx, id); err == nil { t.Fatal("expected error on failed guest unmount") } @@ -396,7 +396,7 @@ func TestUnmapFromGuest_GuestUnmountFails_Retryable(t *testing.T) { } // Retry succeeds. - tc.guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + tc.guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) tc.vmRemove.EXPECT().RemovePlan9(gomock.Any(), gomock.Any()).Return(nil) if err := tc.c.UnmapFromGuest(tc.ctx, id); err != nil { t.Fatalf("retry UnmapFromGuest failed: %v", err) @@ -414,11 +414,11 @@ func TestUnmapFromGuest_VMRemoveFails_Retryable(t *testing.T) { id, _ := tc.c.Reserve(tc.ctx, share.Config{HostPath: "/host/path"}, mount.Config{}) tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil) - tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) _, _ = tc.c.MapToGuest(tc.ctx, id) // First unmap: guest unmount succeeds, VM remove fails. - tc.guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + tc.guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) tc.vmRemove.EXPECT().RemovePlan9(gomock.Any(), gomock.Any()).Return(errVMRemove) if err := tc.c.UnmapFromGuest(tc.ctx, id); err == nil { t.Fatal("expected error on failed VM remove") @@ -446,7 +446,7 @@ func TestUnmapFromGuest_RefCounting_VMRemoveOnLastRef(t *testing.T) { id2, _ := tc.c.Reserve(tc.ctx, share.Config{HostPath: "/host/path"}, mount.Config{}) tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil).Times(1) - tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil).Times(1) + tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil).Times(1) _, _ = tc.c.MapToGuest(tc.ctx, id1) _, _ = tc.c.MapToGuest(tc.ctx, id2) @@ -459,7 +459,7 @@ func TestUnmapFromGuest_RefCounting_VMRemoveOnLastRef(t *testing.T) { } // Second unmap: last ref — guest unmount and VM remove issued. - tc.guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil).Times(1) + tc.guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(nil).Times(1) tc.vmRemove.EXPECT().RemovePlan9(gomock.Any(), gomock.Any()).Return(nil).Times(1) if err := tc.c.UnmapFromGuest(tc.ctx, id2); err != nil { t.Fatalf("second UnmapFromGuest: %v", err) @@ -501,9 +501,9 @@ func TestFullLifecycle_ReuseAfterRelease(t *testing.T) { // First full cycle. id1, _ := tc.c.Reserve(tc.ctx, share.Config{HostPath: "/host/path"}, mount.Config{}) tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil) - tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) _, _ = tc.c.MapToGuest(tc.ctx, id1) - tc.guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + tc.guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) tc.vmRemove.EXPECT().RemovePlan9(gomock.Any(), gomock.Any()).Return(nil) _ = tc.c.UnmapFromGuest(tc.ctx, id1) @@ -568,7 +568,7 @@ func TestUnmapFromGuest_AddToVMFails_MultipleReservations_AllDrain(t *testing.T) // TestUnmapFromGuest_GuestMountFails_MultipleReservations_AllDrain verifies // that when two callers reserve the same host path and MapToGuest fails at the -// guest mount stage (AddToVM succeeds, AddLCOWMappedDirectory fails), the share +// guest mount stage (AddToVM succeeds, AddMappedDirectory fails), the share // and mount stay in the controller's maps until all callers have called // UnmapFromGuest to drain their mount reservations. func TestUnmapFromGuest_GuestMountFails_MultipleReservations_AllDrain(t *testing.T) { @@ -581,7 +581,7 @@ func TestUnmapFromGuest_GuestMountFails_MultipleReservations_AllDrain(t *testing // First caller attempts MapToGuest — AddToVM succeeds, guest mount fails. tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil) - tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(errMount) + tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(errMount) _, err := tc.c.MapToGuest(tc.ctx, id1) if err == nil { t.Fatal("expected error when guest mount fails") diff --git a/internal/controller/device/plan9/mount/mocks/mock_mount.go b/internal/controller/device/plan9/mount/mocks/mock_mount.go index 0267f7b8c7..c60d39fb41 100644 --- a/internal/controller/device/plan9/mount/mocks/mock_mount.go +++ b/internal/controller/device/plan9/mount/mocks/mock_mount.go @@ -43,18 +43,18 @@ func (m *MockGuestPlan9Mounter) EXPECT() *MockGuestPlan9MounterMockRecorder { return m.recorder } -// AddLCOWMappedDirectory mocks base method. -func (m *MockGuestPlan9Mounter) AddLCOWMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error { +// AddMappedDirectory mocks base method. +func (m *MockGuestPlan9Mounter) AddMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddLCOWMappedDirectory", ctx, settings) + ret := m.ctrl.Call(m, "AddMappedDirectory", ctx, settings) ret0, _ := ret[0].(error) return ret0 } -// AddLCOWMappedDirectory indicates an expected call of AddLCOWMappedDirectory. -func (mr *MockGuestPlan9MounterMockRecorder) AddLCOWMappedDirectory(ctx, settings any) *gomock.Call { +// AddMappedDirectory indicates an expected call of AddMappedDirectory. +func (mr *MockGuestPlan9MounterMockRecorder) AddMappedDirectory(ctx, settings any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddLCOWMappedDirectory", reflect.TypeOf((*MockGuestPlan9Mounter)(nil).AddLCOWMappedDirectory), ctx, settings) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddMappedDirectory", reflect.TypeOf((*MockGuestPlan9Mounter)(nil).AddMappedDirectory), ctx, settings) } // MockGuestPlan9Unmounter is a mock of GuestPlan9Unmounter interface. @@ -81,16 +81,16 @@ func (m *MockGuestPlan9Unmounter) EXPECT() *MockGuestPlan9UnmounterMockRecorder return m.recorder } -// RemoveLCOWMappedDirectory mocks base method. -func (m *MockGuestPlan9Unmounter) RemoveLCOWMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error { +// RemoveMappedDirectory mocks base method. +func (m *MockGuestPlan9Unmounter) RemoveMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RemoveLCOWMappedDirectory", ctx, settings) + ret := m.ctrl.Call(m, "RemoveMappedDirectory", ctx, settings) ret0, _ := ret[0].(error) return ret0 } -// RemoveLCOWMappedDirectory indicates an expected call of RemoveLCOWMappedDirectory. -func (mr *MockGuestPlan9UnmounterMockRecorder) RemoveLCOWMappedDirectory(ctx, settings any) *gomock.Call { +// RemoveMappedDirectory indicates an expected call of RemoveMappedDirectory. +func (mr *MockGuestPlan9UnmounterMockRecorder) RemoveMappedDirectory(ctx, settings any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveLCOWMappedDirectory", reflect.TypeOf((*MockGuestPlan9Unmounter)(nil).RemoveLCOWMappedDirectory), ctx, settings) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveMappedDirectory", reflect.TypeOf((*MockGuestPlan9Unmounter)(nil).RemoveMappedDirectory), ctx, settings) } diff --git a/internal/controller/device/plan9/mount/mount.go b/internal/controller/device/plan9/mount/mount.go index 3b990f3b4f..05ab688b41 100644 --- a/internal/controller/device/plan9/mount/mount.go +++ b/internal/controller/device/plan9/mount/mount.go @@ -94,7 +94,7 @@ func (m *Mount) MountToGuest(ctx context.Context, guest GuestPlan9Mounter) (stri log.G(ctx).Debug("mounting Plan9 share in guest") // Issue the guest mount via the GCS mapped directory API. - if err := guest.AddLCOWMappedDirectory(ctx, guestresource.LCOWMappedDirectory{ + if err := guest.AddMappedDirectory(ctx, guestresource.LCOWMappedDirectory{ MountPath: m.guestPath, ShareName: m.shareName, Port: vmutils.Plan9Port, @@ -143,7 +143,7 @@ func (m *Mount) UnmountFromGuest(ctx context.Context, guest GuestPlan9Unmounter) log.G(ctx).Debug("unmounting Plan9 share from guest") // Last reference — issue the physical guest unmount. - if err := guest.RemoveLCOWMappedDirectory(ctx, guestresource.LCOWMappedDirectory{ + if err := guest.RemoveMappedDirectory(ctx, guestresource.LCOWMappedDirectory{ MountPath: m.guestPath, ShareName: m.shareName, Port: vmutils.Plan9Port, diff --git a/internal/controller/device/plan9/mount/mount_test.go b/internal/controller/device/plan9/mount/mount_test.go index cf4568cbaf..2b65a871f8 100644 --- a/internal/controller/device/plan9/mount/mount_test.go +++ b/internal/controller/device/plan9/mount/mount_test.go @@ -74,10 +74,10 @@ func TestReserve_OnUnmountedMount_Errors(t *testing.T) { m := NewReserved("share0", Config{}) // Mount then unmount to reach StateUnmounted. - guest.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + guest.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) _, _ = m.MountToGuest(context.Background(), guest) - guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) _ = m.UnmountFromGuest(context.Background(), guestUnmount) if m.State() != StateUnmounted { @@ -95,7 +95,7 @@ func TestReserve_OnUnmountedMount_Errors(t *testing.T) { // ───────────────────────────────────────────────────────────────────────────── // TestMountToGuest_HappyPath verifies that a mount in StateReserved transitions -// to StateMounted after a successful guest AddLCOWMappedDirectory call and +// to StateMounted after a successful guest AddMappedDirectory call and // returns the expected guest path. func TestMountToGuest_HappyPath(t *testing.T) { ctrl := gomock.NewController(t) @@ -103,7 +103,7 @@ func TestMountToGuest_HappyPath(t *testing.T) { m := NewReserved("share0", Config{ReadOnly: true}) - guest.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + guest.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) guestPath, err := m.MountToGuest(context.Background(), guest) if err != nil { @@ -119,7 +119,7 @@ func TestMountToGuest_HappyPath(t *testing.T) { } // TestMountToGuest_GuestFails_TransitionsToInvalid verifies that when the -// guest AddLCOWMappedDirectory call fails, the mount transitions directly from +// guest AddMappedDirectory call fails, the mount transitions directly from // StateReserved to StateInvalid so outstanding reservations can be drained. func TestMountToGuest_GuestFails_TransitionsToInvalid(t *testing.T) { ctrl := gomock.NewController(t) @@ -127,7 +127,7 @@ func TestMountToGuest_GuestFails_TransitionsToInvalid(t *testing.T) { m := NewReserved("share0", Config{}) - guest.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(errGuestMount) + guest.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(errGuestMount) _, err := m.MountToGuest(context.Background(), guest) if err == nil { @@ -140,7 +140,7 @@ func TestMountToGuest_GuestFails_TransitionsToInvalid(t *testing.T) { // TestMountToGuest_AlreadyMounted_Idempotent verifies that calling MountToGuest // a second time on a StateMounted mount returns the existing guest path without -// issuing a new AddLCOWMappedDirectory call to the guest. +// issuing a new AddMappedDirectory call to the guest. func TestMountToGuest_AlreadyMounted_Idempotent(t *testing.T) { ctrl := gomock.NewController(t) guest := mocks.NewMockGuestPlan9Mounter(ctrl) @@ -148,7 +148,7 @@ func TestMountToGuest_AlreadyMounted_Idempotent(t *testing.T) { m := NewReserved("share0", Config{}) // First mount — guest call must happen exactly once. - guest.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil).Times(1) + guest.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil).Times(1) _, _ = m.MountToGuest(context.Background(), guest) // Second mount on the same mount object — must NOT re-issue guest call. @@ -172,7 +172,7 @@ func TestMountToGuest_OnInvalid_Errors(t *testing.T) { guest := mocks.NewMockGuestPlan9Mounter(ctrl) m := NewReserved("share0", Config{}) - guest.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(errGuestMount) + guest.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(errGuestMount) _, _ = m.MountToGuest(context.Background(), guest) // Try to mount again from StateInvalid. @@ -187,7 +187,7 @@ func TestMountToGuest_OnInvalid_Errors(t *testing.T) { // ───────────────────────────────────────────────────────────────────────────── // TestUnmountFromGuest_HappyPath verifies that unmounting a StateMounted mount -// with refCount=1 issues a guest RemoveLCOWMappedDirectory call and transitions +// with refCount=1 issues a guest RemoveMappedDirectory call and transitions // the mount to the terminal StateUnmounted. func TestUnmountFromGuest_HappyPath(t *testing.T) { ctrl := gomock.NewController(t) @@ -195,10 +195,10 @@ func TestUnmountFromGuest_HappyPath(t *testing.T) { guestUnmount := mocks.NewMockGuestPlan9Unmounter(ctrl) m := NewReserved("share0", Config{}) - guest.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + guest.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) _, _ = m.MountToGuest(context.Background(), guest) - guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) if err := m.UnmountFromGuest(context.Background(), guestUnmount); err != nil { t.Fatalf("unexpected error: %v", err) } @@ -208,7 +208,7 @@ func TestUnmountFromGuest_HappyPath(t *testing.T) { } // TestUnmountFromGuest_GuestFails_StaysInMounted verifies that a failed guest -// RemoveLCOWMappedDirectory call leaves the mount in StateMounted so the caller +// RemoveMappedDirectory call leaves the mount in StateMounted so the caller // can retry. func TestUnmountFromGuest_GuestFails_StaysInMounted(t *testing.T) { ctrl := gomock.NewController(t) @@ -216,10 +216,10 @@ func TestUnmountFromGuest_GuestFails_StaysInMounted(t *testing.T) { guestUnmount := mocks.NewMockGuestPlan9Unmounter(ctrl) m := NewReserved("share0", Config{}) - guest.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + guest.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) _, _ = m.MountToGuest(context.Background(), guest) - guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(errGuestUnmount) + guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(errGuestUnmount) err := m.UnmountFromGuest(context.Background(), guestUnmount) if err == nil { t.Fatal("expected error") @@ -238,14 +238,14 @@ func TestUnmountFromGuest_GuestFails_ThenRetrySucceeds(t *testing.T) { guestUnmount := mocks.NewMockGuestPlan9Unmounter(ctrl) m := NewReserved("share0", Config{}) - guest.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + guest.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) _, _ = m.MountToGuest(context.Background(), guest) - guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(errGuestUnmount) + guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(errGuestUnmount) _ = m.UnmountFromGuest(context.Background(), guestUnmount) // Retry with success. - guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) if err := m.UnmountFromGuest(context.Background(), guestUnmount); err != nil { t.Fatalf("retry unmount failed: %v", err) } @@ -267,7 +267,7 @@ func TestUnmountFromGuest_RefCounting_NoGuestCallUntilLastRef(t *testing.T) { // Add a second reservation. _ = m.Reserve(Config{}) - guest.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + guest.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) _, _ = m.MountToGuest(context.Background(), guest) // First unmount: drops refCount to 1, no guest call. @@ -282,7 +282,7 @@ func TestUnmountFromGuest_RefCounting_NoGuestCallUntilLastRef(t *testing.T) { } // Second unmount: drops refCount to 0, guest call issued. - guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) if err := m.UnmountFromGuest(context.Background(), guestUnmount); err != nil { t.Fatalf("second unmount error: %v", err) } @@ -316,10 +316,10 @@ func TestUnmountFromGuest_OnUnmounted_Errors(t *testing.T) { guestUnmount := mocks.NewMockGuestPlan9Unmounter(ctrl) m := NewReserved("share0", Config{}) - guest.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + guest.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) _, _ = m.MountToGuest(context.Background(), guest) - guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) _ = m.UnmountFromGuest(context.Background(), guestUnmount) // Second unmount on StateUnmounted — must return an error. diff --git a/internal/controller/device/plan9/mount/types.go b/internal/controller/device/plan9/mount/types.go index 39a957cb8e..7fbb0ec981 100644 --- a/internal/controller/device/plan9/mount/types.go +++ b/internal/controller/device/plan9/mount/types.go @@ -21,12 +21,12 @@ func (c Config) Equals(other Config) bool { // GuestPlan9Mounter mounts a Plan9 share inside an LCOW guest. type GuestPlan9Mounter interface { - // AddLCOWMappedDirectory maps a Plan9 share into the LCOW guest. - AddLCOWMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error + // AddMappedDirectory maps a Plan9 share into the LCOW guest. + AddMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error } // GuestPlan9Unmounter unmounts a Plan9 share from an LCOW guest. type GuestPlan9Unmounter interface { - // RemoveLCOWMappedDirectory unmaps a Plan9 share from the LCOW guest. - RemoveLCOWMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error + // RemoveMappedDirectory unmaps a Plan9 share from the LCOW guest. + RemoveMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error } diff --git a/internal/controller/device/plan9/share/share_test.go b/internal/controller/device/plan9/share/share_test.go index d075fb0428..fcd6524165 100644 --- a/internal/controller/device/plan9/share/share_test.go +++ b/internal/controller/device/plan9/share/share_test.go @@ -420,7 +420,7 @@ func TestMountToGuest_RequiresReservedMount(t *testing.T) { } // TestMountToGuest_HappyPath verifies a full ReserveMount → AddToVM → -// MountToGuest flow: the guest AddLCOWMappedDirectory call succeeds and +// MountToGuest flow: the guest AddMappedDirectory call succeeds and // MountToGuest returns a non-empty guest path. func TestMountToGuest_HappyPath(t *testing.T) { ctrl := gomock.NewController(t) @@ -432,7 +432,7 @@ func TestMountToGuest_HappyPath(t *testing.T) { _ = s.AddToVM(context.Background(), vmAdd) _, _ = s.ReserveMount(context.Background(), mount.Config{}) - guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) guestPath, err := s.MountToGuest(context.Background(), guestMount) if err != nil { t.Fatalf("unexpected error: %v", err) @@ -460,10 +460,10 @@ func TestUnmountFromGuest_HappyPath(t *testing.T) { _ = s.AddToVM(context.Background(), vmAdd) _, _ = s.ReserveMount(context.Background(), mount.Config{}) - guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) _, _ = s.MountToGuest(context.Background(), guestMount) - guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) + guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(nil) if err := s.UnmountFromGuest(context.Background(), guestUnmount); err != nil { t.Fatalf("unexpected error: %v", err) } diff --git a/internal/controller/device/scsi/controller_lcow_test.go b/internal/controller/device/scsi/controller_lcow_test.go index 54dc712512..b6b4aad602 100644 --- a/internal/controller/device/scsi/controller_lcow_test.go +++ b/internal/controller/device/scsi/controller_lcow_test.go @@ -18,11 +18,11 @@ type mockGuestOps struct { ejectErr error } -func (m *mockGuestOps) AddLCOWMappedVirtualDisk(_ context.Context, _ guestresource.LCOWMappedVirtualDisk) error { +func (m *mockGuestOps) AddMappedVirtualDisk(_ context.Context, _ guestresource.LCOWMappedVirtualDisk) error { return m.mountErr } -func (m *mockGuestOps) RemoveLCOWMappedVirtualDisk(_ context.Context, _ guestresource.LCOWMappedVirtualDisk) error { +func (m *mockGuestOps) RemoveMappedVirtualDisk(_ context.Context, _ guestresource.LCOWMappedVirtualDisk) error { return m.unmountErr } diff --git a/internal/controller/device/scsi/controller_wcow_test.go b/internal/controller/device/scsi/controller_wcow_test.go index 4c1065ef6d..22e8c7ff35 100644 --- a/internal/controller/device/scsi/controller_wcow_test.go +++ b/internal/controller/device/scsi/controller_wcow_test.go @@ -17,15 +17,15 @@ type mockGuestOps struct { unmountErr error } -func (m *mockGuestOps) AddWCOWMappedVirtualDisk(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { +func (m *mockGuestOps) AddMappedVirtualDisk(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { return m.mountErr } -func (m *mockGuestOps) AddWCOWMappedVirtualDiskForContainerScratch(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { +func (m *mockGuestOps) AddMappedVirtualDiskForContainerScratch(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { return m.mountErr } -func (m *mockGuestOps) RemoveWCOWMappedVirtualDisk(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { +func (m *mockGuestOps) RemoveMappedVirtualDisk(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { return m.unmountErr } diff --git a/internal/controller/device/scsi/disk/disk_lcow_test.go b/internal/controller/device/scsi/disk/disk_lcow_test.go index 3d77b426f2..02848f076c 100644 --- a/internal/controller/device/scsi/disk/disk_lcow_test.go +++ b/internal/controller/device/scsi/disk/disk_lcow_test.go @@ -25,7 +25,7 @@ type mockGuestSCSIMounter struct { err error } -func (m *mockGuestSCSIMounter) AddLCOWMappedVirtualDisk(_ context.Context, _ guestresource.LCOWMappedVirtualDisk) error { +func (m *mockGuestSCSIMounter) AddMappedVirtualDisk(_ context.Context, _ guestresource.LCOWMappedVirtualDisk) error { return m.err } @@ -33,7 +33,7 @@ type mockGuestSCSIUnmounter struct { err error } -func (m *mockGuestSCSIUnmounter) RemoveLCOWMappedVirtualDisk(_ context.Context, _ guestresource.LCOWMappedVirtualDisk) error { +func (m *mockGuestSCSIUnmounter) RemoveMappedVirtualDisk(_ context.Context, _ guestresource.LCOWMappedVirtualDisk) error { return m.err } @@ -80,7 +80,7 @@ func TestDetachFromVM_EjectError(t *testing.T) { } } -func TestMountPartitionToGuest_LCOW_Success(t *testing.T) { +func TestMountPartitionToGuest_Success(t *testing.T) { d := attachedDisk(t) cfg := mount.Config{Partition: 1} _, err := d.ReservePartition(context.Background(), cfg) @@ -96,7 +96,7 @@ func TestMountPartitionToGuest_LCOW_Success(t *testing.T) { } } -func TestMountPartitionToGuest_LCOW_MountError(t *testing.T) { +func TestMountPartitionToGuest_MountError(t *testing.T) { d := attachedDisk(t) cfg := mount.Config{Partition: 1} _, err := d.ReservePartition(context.Background(), cfg) @@ -104,13 +104,12 @@ func TestMountPartitionToGuest_LCOW_MountError(t *testing.T) { t.Fatalf("ReservePartition: %v", err) } _, err = d.MountPartitionToGuest(context.Background(), 1, &mockGuestSCSIMounter{err: errors.New("mount fail")}) - if err != nil { - // This is expected - the mount error propagates. - return + if err == nil { + t.Fatal("expected error, got nil") } } -func TestUnmountPartitionFromGuest_LCOW_Success(t *testing.T) { +func TestUnmountPartitionFromGuest_Success(t *testing.T) { d := attachedDisk(t) cfg := mount.Config{Partition: 1} _, err := d.ReservePartition(context.Background(), cfg) @@ -127,7 +126,7 @@ func TestUnmountPartitionFromGuest_LCOW_Success(t *testing.T) { } } -func TestUnmountPartitionFromGuest_LCOW_UnmountError(t *testing.T) { +func TestUnmountPartitionFromGuest_UnmountError(t *testing.T) { d := attachedDisk(t) cfg := mount.Config{Partition: 1} _, err := d.ReservePartition(context.Background(), cfg) @@ -148,7 +147,7 @@ func TestUnmountPartitionFromGuest_LCOW_UnmountError(t *testing.T) { } } -func TestUnmountPartitionFromGuest_LCOW_RemovesMountWhenFullyUnmounted(t *testing.T) { +func TestUnmountPartitionFromGuest_RemovesMountWhenFullyUnmounted(t *testing.T) { d := attachedDisk(t) cfg := mount.Config{Partition: 1} _, err := d.ReservePartition(context.Background(), cfg) @@ -174,7 +173,7 @@ func TestUnmountPartitionFromGuest_LCOW_RemovesMountWhenFullyUnmounted(t *testin } } -func TestUnmountPartitionFromGuest_LCOW_RetryAfterDetachFailure(t *testing.T) { +func TestUnmountPartitionFromGuest_RetryAfterDetachFailure(t *testing.T) { d := attachedDisk(t) cfg := mount.Config{Partition: 1} _, err := d.ReservePartition(context.Background(), cfg) diff --git a/internal/controller/device/scsi/disk/disk_wcow_test.go b/internal/controller/device/scsi/disk/disk_wcow_test.go index bae4d2d1d5..8792777ea2 100644 --- a/internal/controller/device/scsi/disk/disk_wcow_test.go +++ b/internal/controller/device/scsi/disk/disk_wcow_test.go @@ -21,11 +21,11 @@ type mockGuestSCSIMounter struct { scratchFn func() } -func (m *mockGuestSCSIMounter) AddWCOWMappedVirtualDisk(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { +func (m *mockGuestSCSIMounter) AddMappedVirtualDisk(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { return m.err } -func (m *mockGuestSCSIMounter) AddWCOWMappedVirtualDiskForContainerScratch(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { +func (m *mockGuestSCSIMounter) AddMappedVirtualDiskForContainerScratch(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { if m.scratchFn != nil { m.scratchFn() } @@ -36,7 +36,7 @@ type mockGuestSCSIUnmounter struct { err error } -func (m *mockGuestSCSIUnmounter) RemoveWCOWMappedVirtualDisk(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { +func (m *mockGuestSCSIUnmounter) RemoveMappedVirtualDisk(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { return m.err } @@ -56,7 +56,7 @@ func newDefaultUnmounter() mount.GuestSCSIUnmounter { // --- WCOW-specific tests --- -func TestMountPartitionToGuest_WCOW_Success(t *testing.T) { +func TestMountPartitionToGuest_Success(t *testing.T) { d := attachedDisk(t) cfg := mount.Config{Partition: 1} _, err := d.ReservePartition(context.Background(), cfg) @@ -72,7 +72,7 @@ func TestMountPartitionToGuest_WCOW_Success(t *testing.T) { } } -func TestMountPartitionToGuest_WCOW_MountError(t *testing.T) { +func TestMountPartitionToGuest_MountError(t *testing.T) { d := attachedDisk(t) cfg := mount.Config{Partition: 1} _, err := d.ReservePartition(context.Background(), cfg) @@ -85,7 +85,7 @@ func TestMountPartitionToGuest_WCOW_MountError(t *testing.T) { } } -func TestMountPartitionToGuest_WCOW_FormatWithRefs(t *testing.T) { +func TestMountPartitionToGuest_FormatWithRefs(t *testing.T) { d := attachedDisk(t) cfg := mount.Config{Partition: 1, FormatWithRefs: true} _, err := d.ReservePartition(context.Background(), cfg) @@ -101,7 +101,7 @@ func TestMountPartitionToGuest_WCOW_FormatWithRefs(t *testing.T) { } } -func TestUnmountPartitionFromGuest_WCOW_Success(t *testing.T) { +func TestUnmountPartitionFromGuest_Success(t *testing.T) { d := attachedDisk(t) cfg := mount.Config{Partition: 1} _, err := d.ReservePartition(context.Background(), cfg) @@ -118,7 +118,7 @@ func TestUnmountPartitionFromGuest_WCOW_Success(t *testing.T) { } } -func TestUnmountPartitionFromGuest_WCOW_UnmountError(t *testing.T) { +func TestUnmountPartitionFromGuest_UnmountError(t *testing.T) { d := attachedDisk(t) cfg := mount.Config{Partition: 1} _, err := d.ReservePartition(context.Background(), cfg) @@ -139,7 +139,7 @@ func TestUnmountPartitionFromGuest_WCOW_UnmountError(t *testing.T) { } } -func TestUnmountPartitionFromGuest_WCOW_RemovesMountWhenFullyUnmounted(t *testing.T) { +func TestUnmountPartitionFromGuest_RemovesMountWhenFullyUnmounted(t *testing.T) { d := attachedDisk(t) cfg := mount.Config{Partition: 1} _, err := d.ReservePartition(context.Background(), cfg) diff --git a/internal/controller/device/scsi/mount/mount_lcow.go b/internal/controller/device/scsi/mount/mount_lcow.go index 48130444f5..e6d985f947 100644 --- a/internal/controller/device/scsi/mount/mount_lcow.go +++ b/internal/controller/device/scsi/mount/mount_lcow.go @@ -22,14 +22,14 @@ const ( // 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 + // AddMappedVirtualDisk maps a virtual disk partition into the LCOW guest. + AddMappedVirtualDisk(ctx context.Context, settings guestresource.LCOWMappedVirtualDisk) error } // GuestSCSIUnmounter unmounts a virtual disk partition from an LCOW guest. type GuestSCSIUnmounter interface { - // RemoveLCOWMappedVirtualDisk unmaps a virtual disk partition from the LCOW guest. - RemoveLCOWMappedVirtualDisk(ctx context.Context, settings guestresource.LCOWMappedVirtualDisk) error + // RemoveMappedVirtualDisk unmaps a virtual disk partition from the LCOW guest. + RemoveMappedVirtualDisk(ctx context.Context, settings guestresource.LCOWMappedVirtualDisk) error } // Config describes how a partition of a SCSI disk should be mounted inside @@ -94,7 +94,7 @@ func (m *Mount) mountReserved(ctx context.Context, guest GuestSCSIMounter) error Filesystem: m.config.Filesystem, BlockDev: m.config.BlockDev, } - if err := guest.AddLCOWMappedVirtualDisk(ctx, settings); err != nil { + if err := guest.AddMappedVirtualDisk(ctx, settings); err != nil { return fmt.Errorf("add LCOW mapped virtual disk controller=%d lun=%d: %w", m.controller, m.lun, err) } @@ -124,7 +124,7 @@ func (m *Mount) unmount(ctx context.Context, guest GuestSCSIUnmounter) error { Filesystem: m.config.Filesystem, BlockDev: m.config.BlockDev, } - if err := guest.RemoveLCOWMappedVirtualDisk(ctx, settings); err != nil { + if err := guest.RemoveMappedVirtualDisk(ctx, settings); err != nil { return fmt.Errorf("remove LCOW mapped virtual disk controller=%d lun=%d: %w", m.controller, m.lun, err) } return nil diff --git a/internal/controller/device/scsi/mount/mount_lcow_test.go b/internal/controller/device/scsi/mount/mount_lcow_test.go index 2477ea3492..c040da16c0 100644 --- a/internal/controller/device/scsi/mount/mount_lcow_test.go +++ b/internal/controller/device/scsi/mount/mount_lcow_test.go @@ -16,7 +16,7 @@ type mockMounter struct { err error } -func (m *mockMounter) AddLCOWMappedVirtualDisk(_ context.Context, _ guestresource.LCOWMappedVirtualDisk) error { +func (m *mockMounter) AddMappedVirtualDisk(_ context.Context, _ guestresource.LCOWMappedVirtualDisk) error { return m.err } @@ -24,7 +24,7 @@ type mockUnmounter struct { err error } -func (m *mockUnmounter) RemoveLCOWMappedVirtualDisk(_ context.Context, _ guestresource.LCOWMappedVirtualDisk) error { +func (m *mockUnmounter) RemoveMappedVirtualDisk(_ context.Context, _ guestresource.LCOWMappedVirtualDisk) error { return m.err } @@ -53,7 +53,7 @@ func mountedMount(t *testing.T) *Mount { // --- LCOW-specific tests --- -func TestConfigEquals_LCOW(t *testing.T) { +func TestConfigEquals(t *testing.T) { base := Config{ ReadOnly: true, Encrypted: true, @@ -111,47 +111,7 @@ func TestConfigEquals_LCOW(t *testing.T) { } } -func TestMountToGuest_LCOW_Success(t *testing.T) { - m := NewReserved(0, 0, defaultConfig()) - guestPath, err := m.MountToGuest(context.Background(), &mockMounter{}) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - if guestPath == "" { - t.Error("expected non-empty guestPath") - } - if m.State() != StateMounted { - t.Errorf("expected state %d, got %d", StateMounted, m.State()) - } -} - -func TestMountToGuest_LCOW_Error(t *testing.T) { - mountErr := errors.New("lcow mount failed") - m := NewReserved(0, 0, defaultConfig()) - _, err := m.MountToGuest(context.Background(), &mockMounter{err: mountErr}) - if err == nil { - t.Fatal("expected error, got nil") - } - if !errors.Is(err, mountErr) { - t.Errorf("expected wrapped error %v, got %v", mountErr, err) - } - if m.State() != StateUnmounted { - t.Errorf("expected state %d after failure, got %d", StateUnmounted, m.State()) - } -} - -func TestUnmountFromGuest_LCOW_Success(t *testing.T) { - m := mountedMount(t) - err := m.UnmountFromGuest(context.Background(), &mockUnmounter{}) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - if m.State() != StateUnmounted { - t.Errorf("expected state %d, got %d", StateUnmounted, m.State()) - } -} - -func TestUnmountFromGuest_LCOW_Error(t *testing.T) { +func TestUnmountFromGuest_Error(t *testing.T) { m := mountedMount(t) unmountErr := errors.New("lcow unmount failed") err := m.UnmountFromGuest(context.Background(), &mockUnmounter{err: unmountErr}) diff --git a/internal/controller/device/scsi/mount/mount_wcow.go b/internal/controller/device/scsi/mount/mount_wcow.go index ee0ba70ecc..e8a67f4c2a 100644 --- a/internal/controller/device/scsi/mount/mount_wcow.go +++ b/internal/controller/device/scsi/mount/mount_wcow.go @@ -20,17 +20,17 @@ const ( // GuestSCSIMounter mounts a virtual disk partition inside an WCOW guest. type GuestSCSIMounter interface { - // AddWCOWMappedVirtualDisk maps a virtual disk into the WCOW guest. - AddWCOWMappedVirtualDisk(ctx context.Context, settings guestresource.WCOWMappedVirtualDisk) error - // AddWCOWMappedVirtualDiskForContainerScratch maps a virtual disk as a + // AddMappedVirtualDisk maps a virtual disk into the WCOW guest. + AddMappedVirtualDisk(ctx context.Context, settings guestresource.WCOWMappedVirtualDisk) error + // AddMappedVirtualDiskForContainerScratch maps a virtual disk as a // container scratch disk into the WCOW guest. - AddWCOWMappedVirtualDiskForContainerScratch(ctx context.Context, settings guestresource.WCOWMappedVirtualDisk) error + AddMappedVirtualDiskForContainerScratch(ctx context.Context, settings guestresource.WCOWMappedVirtualDisk) error } // GuestSCSIUnmounter unmounts a virtual disk partition from an LCOW guest. type GuestSCSIUnmounter interface { - // RemoveWCOWMappedVirtualDisk unmaps a virtual disk from the WCOW guest. - RemoveWCOWMappedVirtualDisk(ctx context.Context, settings guestresource.WCOWMappedVirtualDisk) error + // RemoveMappedVirtualDisk unmaps a virtual disk from the WCOW guest. + RemoveMappedVirtualDisk(ctx context.Context, settings guestresource.WCOWMappedVirtualDisk) error } // Config describes how a partition of a SCSI disk should be mounted inside @@ -68,11 +68,11 @@ func (m *Mount) mountReserved(ctx context.Context, guest GuestSCSIMounter) error // FormatWithRefs disks use a separate scratch path to enable ReFS formatting. if m.config.FormatWithRefs { - if err := guest.AddWCOWMappedVirtualDiskForContainerScratch(ctx, settings); err != nil { + if err := guest.AddMappedVirtualDiskForContainerScratch(ctx, settings); err != nil { return fmt.Errorf("add WCOW mapped virtual disk for container scratch controller=%d lun=%d: %w", m.controller, m.lun, err) } } else { - if err := guest.AddWCOWMappedVirtualDisk(ctx, settings); err != nil { + if err := guest.AddMappedVirtualDisk(ctx, settings); err != nil { return fmt.Errorf("add WCOW mapped virtual disk controller=%d lun=%d: %w", m.controller, m.lun, err) } } @@ -94,7 +94,7 @@ func (m *Mount) unmount(ctx context.Context, guest GuestSCSIUnmounter) error { ContainerPath: guestPath, Lun: int32(m.lun), } - if err := guest.RemoveWCOWMappedVirtualDisk(ctx, settings); err != nil { + if err := guest.RemoveMappedVirtualDisk(ctx, settings); err != nil { return fmt.Errorf("remove WCOW mapped virtual disk controller=%d lun=%d: %w", m.controller, m.lun, err) } return nil diff --git a/internal/controller/device/scsi/mount/mount_wcow_test.go b/internal/controller/device/scsi/mount/mount_wcow_test.go index 31a691d7a4..00795af707 100644 --- a/internal/controller/device/scsi/mount/mount_wcow_test.go +++ b/internal/controller/device/scsi/mount/mount_wcow_test.go @@ -17,11 +17,11 @@ type mockMounter struct { scratchFn func() } -func (m *mockMounter) AddWCOWMappedVirtualDisk(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { +func (m *mockMounter) AddMappedVirtualDisk(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { return m.err } -func (m *mockMounter) AddWCOWMappedVirtualDiskForContainerScratch(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { +func (m *mockMounter) AddMappedVirtualDiskForContainerScratch(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { if m.scratchFn != nil { m.scratchFn() } @@ -32,7 +32,7 @@ type mockUnmounter struct { err error } -func (m *mockUnmounter) RemoveWCOWMappedVirtualDisk(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { +func (m *mockUnmounter) RemoveMappedVirtualDisk(_ context.Context, _ guestresource.WCOWMappedVirtualDisk) error { return m.err } @@ -61,7 +61,7 @@ func mountedMount(t *testing.T) *Mount { // --- WCOW-specific tests --- -func TestConfigEquals_WCOW(t *testing.T) { +func TestConfigEquals(t *testing.T) { base := Config{ ReadOnly: true, FormatWithRefs: false, @@ -92,7 +92,7 @@ func TestConfigEquals_WCOW(t *testing.T) { } } -func TestMountToGuest_WCOW_Success(t *testing.T) { +func TestMountToGuest_Success(t *testing.T) { m := NewReserved(0, 0, defaultConfig()) guestPath, err := m.MountToGuest(context.Background(), &mockMounter{}) if err != nil { @@ -106,22 +106,7 @@ func TestMountToGuest_WCOW_Success(t *testing.T) { } } -func TestMountToGuest_WCOW_Error(t *testing.T) { - mountErr := errors.New("wcow mount failed") - m := NewReserved(0, 0, defaultConfig()) - _, err := m.MountToGuest(context.Background(), &mockMounter{err: mountErr}) - if err == nil { - t.Fatal("expected error, got nil") - } - if !errors.Is(err, mountErr) { - t.Errorf("expected wrapped error %v, got %v", mountErr, err) - } - if m.State() != StateUnmounted { - t.Errorf("expected state %d after failure, got %d", StateUnmounted, m.State()) - } -} - -func TestMountToGuest_WCOW_FormatWithRefs(t *testing.T) { +func TestMountToGuest_FormatWithRefs(t *testing.T) { scratchCalled := false m := NewReserved(0, 0, Config{Partition: 1, FormatWithRefs: true}) wm := &mockMounter{scratchFn: func() { scratchCalled = true }} @@ -130,22 +115,11 @@ func TestMountToGuest_WCOW_FormatWithRefs(t *testing.T) { t.Fatalf("unexpected error: %v", err) } if !scratchCalled { - t.Error("expected AddWCOWMappedVirtualDiskForContainerScratch to be called") - } -} - -func TestUnmountFromGuest_WCOW_Success(t *testing.T) { - m := mountedMount(t) - err := m.UnmountFromGuest(context.Background(), &mockUnmounter{}) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - if m.State() != StateUnmounted { - t.Errorf("expected state %d, got %d", StateUnmounted, m.State()) + t.Error("expected AddMappedVirtualDiskForContainerScratch to be called") } } -func TestUnmountFromGuest_WCOW_Error(t *testing.T) { +func TestUnmountFromGuest_Error(t *testing.T) { m := mountedMount(t) unmountErr := errors.New("wcow unmount failed") err := m.UnmountFromGuest(context.Background(), &mockUnmounter{err: unmountErr}) diff --git a/internal/controller/device/vpci/doc.go b/internal/controller/device/vpci/doc.go index c00562aae9..ab5ed600a0 100644 --- a/internal/controller/device/vpci/doc.go +++ b/internal/controller/device/vpci/doc.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) // Package vpci provides a controller for managing virtual PCI (vPCI) device // assignments on a Utility VM (UVM). It handles assigning and removing diff --git a/internal/controller/device/vpci/mocks/mock_vpci.go b/internal/controller/device/vpci/mocks/mock_lcow_vpci.go similarity index 71% rename from internal/controller/device/vpci/mocks/mock_vpci.go rename to internal/controller/device/vpci/mocks/mock_lcow_vpci.go index c541fcc4bc..86e143b69d 100644 --- a/internal/controller/device/vpci/mocks/mock_vpci.go +++ b/internal/controller/device/vpci/mocks/mock_lcow_vpci.go @@ -1,9 +1,9 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: types.go +// Source: github.com/Microsoft/hcsshim/internal/controller/device/vpci (interfaces: vmVPCI,guestVPCI) // // Generated by this command: // -// mockgen -source types.go -package mocks -destination mocks/mock_vpci.go +// mockgen -build_flags=-tags=windows,lcow -package mocks -destination mocks/mock_lcow_vpci.go github.com/Microsoft/hcsshim/internal/controller/device/vpci vmVPCI,guestVPCI // // Package mocks is a generated GoMock package. @@ -71,32 +71,32 @@ func (mr *MockvmVPCIMockRecorder) RemoveDevice(ctx, vmbusGUID any) *gomock.Call return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveDevice", reflect.TypeOf((*MockvmVPCI)(nil).RemoveDevice), ctx, vmbusGUID) } -// MocklinuxGuestVPCI is a mock of linuxGuestVPCI interface. -type MocklinuxGuestVPCI struct { +// MockguestVPCI is a mock of guestVPCI interface. +type MockguestVPCI struct { ctrl *gomock.Controller - recorder *MocklinuxGuestVPCIMockRecorder + recorder *MockguestVPCIMockRecorder isgomock struct{} } -// MocklinuxGuestVPCIMockRecorder is the mock recorder for MocklinuxGuestVPCI. -type MocklinuxGuestVPCIMockRecorder struct { - mock *MocklinuxGuestVPCI +// MockguestVPCIMockRecorder is the mock recorder for MockguestVPCI. +type MockguestVPCIMockRecorder struct { + mock *MockguestVPCI } -// NewMocklinuxGuestVPCI creates a new mock instance. -func NewMocklinuxGuestVPCI(ctrl *gomock.Controller) *MocklinuxGuestVPCI { - mock := &MocklinuxGuestVPCI{ctrl: ctrl} - mock.recorder = &MocklinuxGuestVPCIMockRecorder{mock} +// NewMockguestVPCI creates a new mock instance. +func NewMockguestVPCI(ctrl *gomock.Controller) *MockguestVPCI { + mock := &MockguestVPCI{ctrl: ctrl} + mock.recorder = &MockguestVPCIMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MocklinuxGuestVPCI) EXPECT() *MocklinuxGuestVPCIMockRecorder { +func (m *MockguestVPCI) EXPECT() *MockguestVPCIMockRecorder { return m.recorder } // AddVPCIDevice mocks base method. -func (m *MocklinuxGuestVPCI) AddVPCIDevice(ctx context.Context, settings guestresource.LCOWMappedVPCIDevice) error { +func (m *MockguestVPCI) AddVPCIDevice(ctx context.Context, settings guestresource.LCOWMappedVPCIDevice) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "AddVPCIDevice", ctx, settings) ret0, _ := ret[0].(error) @@ -104,7 +104,7 @@ func (m *MocklinuxGuestVPCI) AddVPCIDevice(ctx context.Context, settings guestre } // AddVPCIDevice indicates an expected call of AddVPCIDevice. -func (mr *MocklinuxGuestVPCIMockRecorder) AddVPCIDevice(ctx, settings any) *gomock.Call { +func (mr *MockguestVPCIMockRecorder) AddVPCIDevice(ctx, settings any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddVPCIDevice", reflect.TypeOf((*MocklinuxGuestVPCI)(nil).AddVPCIDevice), ctx, settings) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddVPCIDevice", reflect.TypeOf((*MockguestVPCI)(nil).AddVPCIDevice), ctx, settings) } diff --git a/internal/controller/device/vpci/state.go b/internal/controller/device/vpci/state.go index dcecdcbb52..36d7be72e4 100644 --- a/internal/controller/device/vpci/state.go +++ b/internal/controller/device/vpci/state.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) package vpci diff --git a/internal/controller/device/vpci/types.go b/internal/controller/device/vpci/types.go index ca2446971c..89f85c0403 100644 --- a/internal/controller/device/vpci/types.go +++ b/internal/controller/device/vpci/types.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) package vpci @@ -8,7 +8,6 @@ import ( "github.com/Microsoft/go-winio/pkg/guid" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) // Device holds the configuration required to assign a vPCI device to the VM. @@ -30,13 +29,6 @@ type vmVPCI interface { RemoveDevice(ctx context.Context, vmbusGUID guid.GUID) error } -// linuxGuestVPCI exposes vPCI device operations in the LCOW guest. -// Implemented by [guestmanager.Guest]. -type linuxGuestVPCI interface { - // AddVPCIDevice adds a vPCI device to the guest. - AddVPCIDevice(ctx context.Context, settings guestresource.LCOWMappedVPCIDevice) error -} - // ============================================================================== // INTERNAL DATA STRUCTURES // ============================================================================== diff --git a/internal/controller/device/vpci/vpci.go b/internal/controller/device/vpci/vpci.go index aa8a675150..4de0e7f3ab 100644 --- a/internal/controller/device/vpci/vpci.go +++ b/internal/controller/device/vpci/vpci.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) package vpci @@ -30,20 +30,20 @@ type Controller struct { // vmVPCI performs host-side vPCI device add/remove on the VM. vmVPCI vmVPCI - // linuxGuestVPCI performs guest-side vPCI device setup for LCOW. - linuxGuestVPCI linuxGuestVPCI + // guestVPCI performs guest-side vPCI device setup. + guestVPCI guestVPCI } // New creates a ready-to-use [Controller]. func New( vmVPCI vmVPCI, - linuxGuestVPCI linuxGuestVPCI, + guestVPCI guestVPCI, ) *Controller { return &Controller{ - vmVPCI: vmVPCI, - linuxGuestVPCI: linuxGuestVPCI, - devices: make(map[guid.GUID]*deviceInfo), - deviceToGUID: make(map[Device]guid.GUID), + vmVPCI: vmVPCI, + guestVPCI: guestVPCI, + devices: make(map[guid.GUID]*deviceInfo), + deviceToGUID: make(map[Device]guid.GUID), } } diff --git a/internal/controller/device/vpci/vpci_lcow.go b/internal/controller/device/vpci/vpci_lcow.go index 762893da1e..8abe10447e 100644 --- a/internal/controller/device/vpci/vpci_lcow.go +++ b/internal/controller/device/vpci/vpci_lcow.go @@ -10,10 +10,16 @@ import ( "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) +// guestVPCI exposes vPCI device operations in the LCOW guest. +type guestVPCI interface { + // AddVPCIDevice adds a vPCI device to the guest. + AddVPCIDevice(ctx context.Context, settings guestresource.LCOWMappedVPCIDevice) error +} + // waitGuestDeviceReady notifies the guest about the new device and blocks until // the required sysfs/device paths are available before workloads use them. func (c *Controller) waitGuestDeviceReady(ctx context.Context, vmBusGUID guid.GUID) error { - return c.linuxGuestVPCI.AddVPCIDevice(ctx, guestresource.LCOWMappedVPCIDevice{ + return c.guestVPCI.AddVPCIDevice(ctx, guestresource.LCOWMappedVPCIDevice{ VMBusGUID: vmBusGUID.String(), }) } diff --git a/internal/controller/device/vpci/vpci_test.go b/internal/controller/device/vpci/vpci_lcow_test.go similarity index 95% rename from internal/controller/device/vpci/vpci_test.go rename to internal/controller/device/vpci/vpci_lcow_test.go index 8010505510..8615ecf9d3 100644 --- a/internal/controller/device/vpci/vpci_test.go +++ b/internal/controller/device/vpci/vpci_lcow_test.go @@ -36,7 +36,7 @@ var ( // and that the device appears in both tracking maps. func TestReserve_NewDevice(t *testing.T) { ctrl := gomock.NewController(t) - c := New(mocks.NewMockvmVPCI(ctrl), mocks.NewMocklinuxGuestVPCI(ctrl)) + c := New(mocks.NewMockvmVPCI(ctrl), mocks.NewMockguestVPCI(ctrl)) ctx := context.Background() dev := newTestDevice() @@ -62,7 +62,7 @@ func TestReserve_NewDevice(t *testing.T) { // same device returns the exact same GUID without creating a new entry. func TestReserve_SameDeviceTwice(t *testing.T) { ctrl := gomock.NewController(t) - c := New(mocks.NewMockvmVPCI(ctrl), mocks.NewMocklinuxGuestVPCI(ctrl)) + c := New(mocks.NewMockvmVPCI(ctrl), mocks.NewMockguestVPCI(ctrl)) ctx := context.Background() dev := newTestDevice() @@ -86,7 +86,7 @@ func TestReserve_SameDeviceTwice(t *testing.T) { // treated as independent reservations. func TestReserve_DifferentVF(t *testing.T) { ctrl := gomock.NewController(t) - c := New(mocks.NewMockvmVPCI(ctrl), mocks.NewMocklinuxGuestVPCI(ctrl)) + c := New(mocks.NewMockvmVPCI(ctrl), mocks.NewMockguestVPCI(ctrl)) ctx := context.Background() dev0 := Device{DeviceInstanceID: "PCI\\VEN_1234&DEV_5678\\0", VirtualFunctionIndex: 0} @@ -111,7 +111,7 @@ func TestReserve_DifferentVF(t *testing.T) { // with an unknown GUID. func TestAddToVM_NoReservation(t *testing.T) { ctrl := gomock.NewController(t) - c := New(mocks.NewMockvmVPCI(ctrl), mocks.NewMocklinuxGuestVPCI(ctrl)) + c := New(mocks.NewMockvmVPCI(ctrl), mocks.NewMockguestVPCI(ctrl)) ctx := context.Background() unknownGUID, _ := guid.NewV4() @@ -125,7 +125,7 @@ func TestAddToVM_NoReservation(t *testing.T) { func TestAddToVM_HappyPath(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -153,7 +153,7 @@ func TestAddToVM_HappyPath(t *testing.T) { func TestAddToVM_Idempotent(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -184,7 +184,7 @@ func TestAddToVM_Idempotent(t *testing.T) { func TestAddToVM_HostFails(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -216,7 +216,7 @@ func TestAddToVM_HostFails(t *testing.T) { func TestAddToVM_StateRemoved(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -239,7 +239,7 @@ func TestAddToVM_StateRemoved(t *testing.T) { func TestAddToVM_GuestFails(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -268,7 +268,7 @@ func TestAddToVM_GuestFails(t *testing.T) { func TestAddToVM_InvalidDevice(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -294,7 +294,7 @@ func TestAddToVM_InvalidDevice(t *testing.T) { func TestAddToVM_ReservedTwice_ThenAdd(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -321,7 +321,7 @@ func TestAddToVM_ReservedTwice_ThenAdd(t *testing.T) { // TestRemoveFromVM_NoDevice verifies that removing an unknown GUID returns an error. func TestRemoveFromVM_NoDevice(t *testing.T) { ctrl := gomock.NewController(t) - c := New(mocks.NewMockvmVPCI(ctrl), mocks.NewMocklinuxGuestVPCI(ctrl)) + c := New(mocks.NewMockvmVPCI(ctrl), mocks.NewMockguestVPCI(ctrl)) ctx := context.Background() unknownGUID, _ := guid.NewV4() @@ -336,7 +336,7 @@ func TestRemoveFromVM_NoDevice(t *testing.T) { func TestRemoveFromVM_ReservedButNeverAdded(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -362,7 +362,7 @@ func TestRemoveFromVM_ReservedButNeverAdded(t *testing.T) { func TestRemoveFromVM_AfterHostAddFails(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -390,7 +390,7 @@ func TestRemoveFromVM_AfterHostAddFails(t *testing.T) { func TestRemoveFromVM_HappyPath(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -416,7 +416,7 @@ func TestRemoveFromVM_HappyPath(t *testing.T) { func TestRemoveFromVM_RefCounting(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -451,7 +451,7 @@ func TestRemoveFromVM_RefCounting(t *testing.T) { func TestRemoveFromVM_HostFails(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -484,7 +484,7 @@ func TestRemoveFromVM_HostFails(t *testing.T) { func TestRemoveFromVM_HostFails_ThenRetry(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -515,7 +515,7 @@ func TestRemoveFromVM_HostFails_ThenRetry(t *testing.T) { func TestRemoveFromVM_InvalidDevice_AfterGuestFail(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -549,7 +549,7 @@ func TestRemoveFromVM_InvalidDevice_AfterGuestFail(t *testing.T) { func TestReserve_AfterRemove(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -579,7 +579,7 @@ func TestReserve_AfterRemove(t *testing.T) { func TestReserve_AfterGuestFailure(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -609,7 +609,7 @@ func TestReserve_AfterGuestFailure(t *testing.T) { func TestRemoveFromVM_AlreadyRemoved(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -639,7 +639,7 @@ func TestRemoveFromVM_AlreadyRemoved(t *testing.T) { func TestAddToVM_HCSSettings(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() @@ -679,7 +679,7 @@ func TestAddToVM_HCSSettings(t *testing.T) { func TestAddToVM_GuestVMBusGUIDForwarded(t *testing.T) { ctrl := gomock.NewController(t) vm := mocks.NewMockvmVPCI(ctrl) - guest := mocks.NewMocklinuxGuestVPCI(ctrl) + guest := mocks.NewMockguestVPCI(ctrl) c := New(vm, guest) ctx := context.Background() diff --git a/internal/controller/device/vpci/vpci_unsupported.go b/internal/controller/device/vpci/vpci_unsupported.go deleted file mode 100644 index 31729ac881..0000000000 --- a/internal/controller/device/vpci/vpci_unsupported.go +++ /dev/null @@ -1,15 +0,0 @@ -//go:build windows && !wcow && !lcow - -package vpci - -import ( - "context" - "fmt" - - "github.com/Microsoft/go-winio/pkg/guid" -) - -// waitGuestDeviceReady is a not supported for unsupported guests. -func (c *Controller) waitGuestDeviceReady(_ context.Context, _ guid.GUID) error { - return fmt.Errorf("unsupported guest") -} diff --git a/internal/controller/device/vpci/vpci_wcow.go b/internal/controller/device/vpci/vpci_wcow.go index db7846a938..d1adf1c7b5 100644 --- a/internal/controller/device/vpci/vpci_wcow.go +++ b/internal/controller/device/vpci/vpci_wcow.go @@ -8,6 +8,10 @@ import ( "github.com/Microsoft/go-winio/pkg/guid" ) +// guestVPCI exposes vPCI device operations in the guest. +// Not applicable for WCOW guests. +type guestVPCI interface{} + // waitGuestDeviceReady is a no-op for Windows guests. WCOW does not require a // guest-side notification as part of vPCI device assignment. func (c *Controller) waitGuestDeviceReady(_ context.Context, _ guid.GUID) error { diff --git a/internal/controller/linuxcontainer/container.go b/internal/controller/linuxcontainer/container.go index 4b56d672df..5fb7cc67f3 100644 --- a/internal/controller/linuxcontainer/container.go +++ b/internal/controller/linuxcontainer/container.go @@ -238,7 +238,7 @@ func (c *Controller) releaseResources(ctx context.Context) error { hcsLayers = append(hcsLayers, hcsschema.Layer{Path: layer.guestPath}) } - if err := c.guest.RemoveLCOWCombinedLayers(ctx, guestresource.LCOWCombinedLayers{ + if err := c.guest.RemoveCombinedLayers(ctx, guestresource.LCOWCombinedLayers{ ContainerID: c.gcsContainerID, ContainerRootPath: c.layers.rootfsPath, Layers: hcsLayers, diff --git a/internal/controller/linuxcontainer/container_test.go b/internal/controller/linuxcontainer/container_test.go index f967fe8833..51071c6f4f 100644 --- a/internal/controller/linuxcontainer/container_test.go +++ b/internal/controller/linuxcontainer/container_test.go @@ -496,7 +496,7 @@ func TestReleaseResources_AllResourceTypes(t *testing.T) { // Expect combined layers removal. guestCtrl.EXPECT(). - RemoveLCOWCombinedLayers(gomock.Any(), guestresource.LCOWCombinedLayers{ + RemoveCombinedLayers(gomock.Any(), guestresource.LCOWCombinedLayers{ ContainerID: c.gcsContainerID, ContainerRootPath: "/rootfs", Layers: []hcsschema.Layer{{Path: "/dev/ro0"}}, @@ -551,7 +551,7 @@ func TestReleaseResources_NoLayers(t *testing.T) { } // TestReleaseResources_LayersNotCombined verifies that when layers exist but -// were not combined, RemoveLCOWCombinedLayers is not called. +// were not combined, RemoveCombinedLayers is not called. func TestReleaseResources_LayersNotCombined(t *testing.T) { t.Parallel() c, scsiCtrl, _, _, _ := newContainerTestController(t) @@ -565,7 +565,7 @@ func TestReleaseResources_LayersNotCombined(t *testing.T) { roLayers: []scsiReservation{{id: roGUID}}, } - // Only unmaps expected; no RemoveLCOWCombinedLayers call. + // Only unmaps expected; no RemoveCombinedLayers call. scsiCtrl.EXPECT().UnmapFromGuest(gomock.Any(), scratchGUID).Return(nil) scsiCtrl.EXPECT().UnmapFromGuest(gomock.Any(), roGUID).Return(nil) @@ -653,7 +653,7 @@ func TestReleaseResources_MultipleROLayers(t *testing.T) { }, } - guestCtrl.EXPECT().RemoveLCOWCombinedLayers(gomock.Any(), gomock.Any()).Return(nil) + guestCtrl.EXPECT().RemoveCombinedLayers(gomock.Any(), gomock.Any()).Return(nil) scsiCtrl.EXPECT().UnmapFromGuest(gomock.Any(), scratchGUID).Return(nil) for _, g := range roGUIDs { scsiCtrl.EXPECT().UnmapFromGuest(gomock.Any(), g).Return(nil) @@ -679,7 +679,7 @@ func TestReleaseResources_RemoveCombinedLayersFails(t *testing.T) { } wantErr := errors.New("remove combined layers failed") - guestCtrl.EXPECT().RemoveLCOWCombinedLayers(gomock.Any(), gomock.Any()).Return(wantErr) + guestCtrl.EXPECT().RemoveCombinedLayers(gomock.Any(), gomock.Any()).Return(wantErr) err := c.releaseResources(t.Context()) if !errors.Is(err, wantErr) { diff --git a/internal/controller/linuxcontainer/layers.go b/internal/controller/linuxcontainer/layers.go index c475d7dcc1..b3aa89e41a 100644 --- a/internal/controller/linuxcontainer/layers.go +++ b/internal/controller/linuxcontainer/layers.go @@ -145,7 +145,7 @@ func (c *Controller) allocateLayers( hcsLayers[i] = hcsschema.Layer{Path: roLayer.guestPath} } - if err = c.guest.AddLCOWCombinedLayers(ctx, guestresource.LCOWCombinedLayers{ + if err = c.guest.AddCombinedLayers(ctx, guestresource.LCOWCombinedLayers{ ContainerID: c.gcsContainerID, ContainerRootPath: c.layers.rootfsPath, Layers: hcsLayers, diff --git a/internal/controller/linuxcontainer/layers_test.go b/internal/controller/linuxcontainer/layers_test.go index 3c798359a6..c21ed3662e 100644 --- a/internal/controller/linuxcontainer/layers_test.go +++ b/internal/controller/linuxcontainer/layers_test.go @@ -109,7 +109,7 @@ func TestAllocateLayers_SingleReadOnlyLayer(t *testing.T) { expectedRootfsPath := ospath.Join("linux", guestpath.LCOWV2RootPrefixInVM, c.gcsPodID, c.gcsContainerID, guestpath.RootfsPath) guestCtrl.EXPECT(). - AddLCOWCombinedLayers(gomock.Any(), guestresource.LCOWCombinedLayers{ + AddCombinedLayers(gomock.Any(), guestresource.LCOWCombinedLayers{ ContainerID: c.gcsContainerID, ContainerRootPath: expectedRootfsPath, Layers: []hcsschema.Layer{{Path: "/dev/sda"}}, @@ -180,7 +180,7 @@ func TestAllocateLayers_MultipleReadOnlyLayers(t *testing.T) { // Combine layers with both read-only layers. guestCtrl.EXPECT(). - AddLCOWCombinedLayers(gomock.Any(), gomock.Any()). + AddCombinedLayers(gomock.Any(), gomock.Any()). Return(nil) if err := c.allocateLayers(t.Context(), layerFolders, nil, false); err != nil { @@ -234,7 +234,7 @@ func TestAllocateLayers_ScratchEncryption(t *testing.T) { Return("/dev/sdb", nil) guestCtrl.EXPECT(). - AddLCOWCombinedLayers(gomock.Any(), gomock.Any()). + AddCombinedLayers(gomock.Any(), gomock.Any()). Return(nil) if err := c.allocateLayers(t.Context(), layerFolders, nil, true); err != nil { @@ -417,7 +417,7 @@ func TestAllocateLayers_ScratchMapToGuestFailure(t *testing.T) { } // TestAllocateLayers_CombineLayersFailure verifies that an -// AddLCOWCombinedLayers failure propagates the error and layersCombined remains +// AddCombinedLayers failure propagates the error and layersCombined remains // false. func TestAllocateLayers_CombineLayersFailure(t *testing.T) { stubResolvePath(t) @@ -447,7 +447,7 @@ func TestAllocateLayers_CombineLayersFailure(t *testing.T) { // CombineLayers fails. guestCtrl.EXPECT(). - AddLCOWCombinedLayers(gomock.Any(), gomock.Any()). + AddCombinedLayers(gomock.Any(), gomock.Any()). Return(errCombineLayers) err := c.allocateLayers(t.Context(), layerFolders, nil, false) @@ -539,7 +539,7 @@ func TestAllocateLayers_RootfsMount(t *testing.T) { Return("/dev/sdb", nil) guestCtrl.EXPECT(). - AddLCOWCombinedLayers(gomock.Any(), gomock.Any()). + AddCombinedLayers(gomock.Any(), gomock.Any()). Return(nil) if err := c.allocateLayers(t.Context(), nil, rootfs, false); err != nil { diff --git a/internal/controller/linuxcontainer/mocks/mock_types.go b/internal/controller/linuxcontainer/mocks/mock_types.go index e47d2ee379..f73c117939 100644 --- a/internal/controller/linuxcontainer/mocks/mock_types.go +++ b/internal/controller/linuxcontainer/mocks/mock_types.go @@ -50,18 +50,18 @@ func (m *Mockguest) EXPECT() *MockguestMockRecorder { return m.recorder } -// AddLCOWCombinedLayers mocks base method. -func (m *Mockguest) AddLCOWCombinedLayers(ctx context.Context, settings guestresource.LCOWCombinedLayers) error { +// AddCombinedLayers mocks base method. +func (m *Mockguest) AddCombinedLayers(ctx context.Context, settings guestresource.LCOWCombinedLayers) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddLCOWCombinedLayers", ctx, settings) + ret := m.ctrl.Call(m, "AddCombinedLayers", ctx, settings) ret0, _ := ret[0].(error) return ret0 } -// AddLCOWCombinedLayers indicates an expected call of AddLCOWCombinedLayers. -func (mr *MockguestMockRecorder) AddLCOWCombinedLayers(ctx, settings any) *gomock.Call { +// AddCombinedLayers indicates an expected call of AddCombinedLayers. +func (mr *MockguestMockRecorder) AddCombinedLayers(ctx, settings any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddLCOWCombinedLayers", reflect.TypeOf((*Mockguest)(nil).AddLCOWCombinedLayers), ctx, settings) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddCombinedLayers", reflect.TypeOf((*Mockguest)(nil).AddCombinedLayers), ctx, settings) } // Capabilities mocks base method. @@ -107,18 +107,18 @@ func (mr *MockguestMockRecorder) DeleteContainerState(ctx, cid any) *gomock.Call return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteContainerState", reflect.TypeOf((*Mockguest)(nil).DeleteContainerState), ctx, cid) } -// RemoveLCOWCombinedLayers mocks base method. -func (m *Mockguest) RemoveLCOWCombinedLayers(ctx context.Context, settings guestresource.LCOWCombinedLayers) error { +// RemoveCombinedLayers mocks base method. +func (m *Mockguest) RemoveCombinedLayers(ctx context.Context, settings guestresource.LCOWCombinedLayers) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RemoveLCOWCombinedLayers", ctx, settings) + ret := m.ctrl.Call(m, "RemoveCombinedLayers", ctx, settings) ret0, _ := ret[0].(error) return ret0 } -// RemoveLCOWCombinedLayers indicates an expected call of RemoveLCOWCombinedLayers. -func (mr *MockguestMockRecorder) RemoveLCOWCombinedLayers(ctx, settings any) *gomock.Call { +// RemoveCombinedLayers indicates an expected call of RemoveCombinedLayers. +func (mr *MockguestMockRecorder) RemoveCombinedLayers(ctx, settings any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveLCOWCombinedLayers", reflect.TypeOf((*Mockguest)(nil).RemoveLCOWCombinedLayers), ctx, settings) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveCombinedLayers", reflect.TypeOf((*Mockguest)(nil).RemoveCombinedLayers), ctx, settings) } // MockscsiController is a mock of scsiController interface. diff --git a/internal/controller/linuxcontainer/types.go b/internal/controller/linuxcontainer/types.go index c926ca3ddf..d49a959ecc 100644 --- a/internal/controller/linuxcontainer/types.go +++ b/internal/controller/linuxcontainer/types.go @@ -27,8 +27,8 @@ type guest interface { CreateContainer(ctx context.Context, cid string, config interface{}) (*gcs.Container, error) DeleteContainerState(ctx context.Context, cid string) error - AddLCOWCombinedLayers(ctx context.Context, settings guestresource.LCOWCombinedLayers) error - RemoveLCOWCombinedLayers(ctx context.Context, settings guestresource.LCOWCombinedLayers) error + AddCombinedLayers(ctx context.Context, settings guestresource.LCOWCombinedLayers) error + RemoveCombinedLayers(ctx context.Context, settings guestresource.LCOWCombinedLayers) error } // scsiController abstracts host-side SCSI disk reservation and guest mapping. diff --git a/internal/controller/network/network_lcow.go b/internal/controller/network/network_lcow.go index 253a3c6606..1ec3fde0eb 100644 --- a/internal/controller/network/network_lcow.go +++ b/internal/controller/network/network_lcow.go @@ -15,10 +15,10 @@ import ( // guestNetwork exposes linux guest network operations. // Implemented by guestmanager.Guest. type guestNetwork interface { - // AddLCOWNetworkInterface adds a network interface to the LCOW guest. - AddLCOWNetworkInterface(ctx context.Context, settings *guestresource.LCOWNetworkAdapter) error - // RemoveLCOWNetworkInterface removes a network interface from the LCOW guest. - RemoveLCOWNetworkInterface(ctx context.Context, settings *guestresource.LCOWNetworkAdapter) error + // AddNetworkInterface adds a network interface to the LCOW guest. + AddNetworkInterface(ctx context.Context, settings *guestresource.LCOWNetworkAdapter) error + // RemoveNetworkInterface removes a network interface from the LCOW guest. + RemoveNetworkInterface(ctx context.Context, settings *guestresource.LCOWNetworkAdapter) error } // addNetNSInsideGuest maps a host network namespace into the guest as a managed Guest Network Namespace. @@ -61,7 +61,7 @@ func (c *Controller) addEndpointToGuestNamespace(ctx context.Context, nicID stri log.G(ctx).Tracef("built LCOW network adapter: %+v", lcowAdapter) - if err := c.guestNetwork.AddLCOWNetworkInterface(ctx, lcowAdapter); err != nil { + if err := c.guestNetwork.AddNetworkInterface(ctx, lcowAdapter); err != nil { return fmt.Errorf("add NIC %s to guest (endpoint %s): %w", nicID, endpoint.Id, err) } @@ -78,7 +78,7 @@ func (c *Controller) removeEndpointFromGuestNamespace(ctx context.Context, nicID if c.isNamespaceSupportedByGuest { // 1. LCOW guest-side removal. - if err := c.guestNetwork.RemoveLCOWNetworkInterface(ctx, &guestresource.LCOWNetworkAdapter{ + if err := c.guestNetwork.RemoveNetworkInterface(ctx, &guestresource.LCOWNetworkAdapter{ NamespaceID: c.namespaceID, ID: nicID, }); err != nil { diff --git a/internal/vm/guestmanager/block_cims.go b/internal/vm/guestmanager/block_cims.go index eb2c7f52e0..a1ed260c76 100644 --- a/internal/vm/guestmanager/block_cims.go +++ b/internal/vm/guestmanager/block_cims.go @@ -11,8 +11,8 @@ import ( "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) -// AddWCOWBlockCIMs adds WCOW block CIM mounts in the guest. -func (gm *Guest) AddWCOWBlockCIMs(ctx context.Context, settings *guestresource.CWCOWBlockCIMMounts) error { +// AddBlockCIMs adds WCOW block CIM mounts in the guest. +func (gm *Guest) AddBlockCIMs(ctx context.Context, settings *guestresource.CWCOWBlockCIMMounts) error { request := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeWCOWBlockCims, @@ -29,8 +29,8 @@ func (gm *Guest) AddWCOWBlockCIMs(ctx context.Context, settings *guestresource.C return nil } -// RemoveWCOWBlockCIMs removes WCOW block CIM mounts in the guest. -func (gm *Guest) RemoveWCOWBlockCIMs(ctx context.Context, settings *guestresource.CWCOWBlockCIMMounts) error { +// RemoveBlockCIMs removes WCOW block CIM mounts in the guest. +func (gm *Guest) RemoveBlockCIMs(ctx context.Context, settings *guestresource.CWCOWBlockCIMMounts) error { request := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeWCOWBlockCims, diff --git a/internal/vm/guestmanager/combinedlayers_lcow.go b/internal/vm/guestmanager/combinedlayers_lcow.go index 6d16a28d19..09d12bf138 100644 --- a/internal/vm/guestmanager/combinedlayers_lcow.go +++ b/internal/vm/guestmanager/combinedlayers_lcow.go @@ -11,8 +11,8 @@ import ( "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) -// AddLCOWCombinedLayers adds LCOW combined layers in the guest. -func (gm *Guest) AddLCOWCombinedLayers(ctx context.Context, settings guestresource.LCOWCombinedLayers) error { +// AddCombinedLayers adds LCOW combined layers in the guest. +func (gm *Guest) AddCombinedLayers(ctx context.Context, settings guestresource.LCOWCombinedLayers) error { modifyRequest := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeCombinedLayers, @@ -28,8 +28,8 @@ func (gm *Guest) AddLCOWCombinedLayers(ctx context.Context, settings guestresour return nil } -// RemoveLCOWCombinedLayers removes LCOW combined layers in the guest. -func (gm *Guest) RemoveLCOWCombinedLayers(ctx context.Context, settings guestresource.LCOWCombinedLayers) error { +// RemoveCombinedLayers removes LCOW combined layers in the guest. +func (gm *Guest) RemoveCombinedLayers(ctx context.Context, settings guestresource.LCOWCombinedLayers) error { modifyRequest := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeCombinedLayers, diff --git a/internal/vm/guestmanager/combinedlayers_wcow.go b/internal/vm/guestmanager/combinedlayers_wcow.go index ffa19aa438..b9ed2bc57b 100644 --- a/internal/vm/guestmanager/combinedlayers_wcow.go +++ b/internal/vm/guestmanager/combinedlayers_wcow.go @@ -11,8 +11,8 @@ import ( "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) -// AddWCOWCombinedLayers adds WCOW combined layers in the guest. -func (gm *Guest) AddWCOWCombinedLayers(ctx context.Context, settings guestresource.WCOWCombinedLayers) error { +// AddCombinedLayers adds WCOW combined layers in the guest. +func (gm *Guest) AddCombinedLayers(ctx context.Context, settings guestresource.WCOWCombinedLayers) error { modifyRequest := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeCombinedLayers, @@ -28,8 +28,8 @@ func (gm *Guest) AddWCOWCombinedLayers(ctx context.Context, settings guestresour return nil } -// AddCWCOWCombinedLayers adds combined layers in the CWCOW guest. -func (gm *Guest) AddCWCOWCombinedLayers(ctx context.Context, settings guestresource.CWCOWCombinedLayers) error { +// AddConfidentialCombinedLayers adds combined layers in the CWCOW guest. +func (gm *Guest) AddConfidentialCombinedLayers(ctx context.Context, settings guestresource.CWCOWCombinedLayers) error { modifyRequest := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeCWCOWCombinedLayers, @@ -45,8 +45,8 @@ func (gm *Guest) AddCWCOWCombinedLayers(ctx context.Context, settings guestresou return nil } -// RemoveWCOWCombinedLayers removes WCOW combined layers in the guest. -func (gm *Guest) RemoveWCOWCombinedLayers(ctx context.Context, settings guestresource.WCOWCombinedLayers) error { +// RemoveCombinedLayers removes WCOW combined layers in the guest. +func (gm *Guest) RemoveCombinedLayers(ctx context.Context, settings guestresource.WCOWCombinedLayers) error { modifyRequest := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeCombinedLayers, @@ -62,8 +62,8 @@ func (gm *Guest) RemoveWCOWCombinedLayers(ctx context.Context, settings guestres return nil } -// RemoveCWCOWCombinedLayers removes combined layers in CWCOW guest. -func (gm *Guest) RemoveCWCOWCombinedLayers(ctx context.Context, settings guestresource.CWCOWCombinedLayers) error { +// RemoveConfidentialCombinedLayers removes combined layers in CWCOW guest. +func (gm *Guest) RemoveConfidentialCombinedLayers(ctx context.Context, settings guestresource.CWCOWCombinedLayers) error { modifyRequest := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeCWCOWCombinedLayers, diff --git a/internal/vm/guestmanager/device_lcow.go b/internal/vm/guestmanager/device_lcow.go index 61524a0ccc..a5650be72b 100644 --- a/internal/vm/guestmanager/device_lcow.go +++ b/internal/vm/guestmanager/device_lcow.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && lcow package guestmanager diff --git a/internal/vm/guestmanager/doc.go b/internal/vm/guestmanager/doc.go index efe0df91b2..af849c2ad3 100644 --- a/internal/vm/guestmanager/doc.go +++ b/internal/vm/guestmanager/doc.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) /* Package guestmanager manages guest-side operations for utility VMs (UVMs) via the @@ -20,8 +20,8 @@ GCS connection: After the connection is established, use the manager interfaces for guest-side changes: - _ = g.AddLCOWNetworkInterface(ctx, &guestresource.LCOWNetworkAdapter{...}) - _ = g.AddLCOWMappedVirtualDisk(ctx, guestresource.LCOWMappedVirtualDisk{...}) + _ = g.AddNetworkInterface(ctx, &guestresource.LCOWNetworkAdapter{...}) + _ = g.AddMappedVirtualDisk(ctx, guestresource.LCOWMappedVirtualDisk{...}) # Layer Boundaries diff --git a/internal/vm/guestmanager/guest.go b/internal/vm/guestmanager/guest.go index b8ef0f11be..54e0a56e53 100644 --- a/internal/vm/guestmanager/guest.go +++ b/internal/vm/guestmanager/guest.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) package guestmanager diff --git a/internal/vm/guestmanager/hvsocket.go b/internal/vm/guestmanager/hvsocket.go index 8cb616fd0f..f18a9b99b5 100644 --- a/internal/vm/guestmanager/hvsocket.go +++ b/internal/vm/guestmanager/hvsocket.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && wcow package guestmanager diff --git a/internal/vm/guestmanager/manager.go b/internal/vm/guestmanager/manager.go index 474e9ca63c..573a641399 100644 --- a/internal/vm/guestmanager/manager.go +++ b/internal/vm/guestmanager/manager.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) package guestmanager diff --git a/internal/vm/guestmanager/mapped_directory_lcow.go b/internal/vm/guestmanager/mapped_directory_lcow.go index a401f7ff26..ee175769a5 100644 --- a/internal/vm/guestmanager/mapped_directory_lcow.go +++ b/internal/vm/guestmanager/mapped_directory_lcow.go @@ -11,8 +11,8 @@ import ( "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) -// AddLCOWMappedDirectory maps a directory into LCOW guest. -func (gm *Guest) AddLCOWMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error { +// AddMappedDirectory maps a directory into LCOW guest. +func (gm *Guest) AddMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error { request := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeMappedDirectory, @@ -28,8 +28,8 @@ func (gm *Guest) AddLCOWMappedDirectory(ctx context.Context, settings guestresou return nil } -// RemoveLCOWMappedDirectory unmaps a directory from LCOW guest. -func (gm *Guest) RemoveLCOWMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error { +// RemoveMappedDirectory unmaps a directory from LCOW guest. +func (gm *Guest) RemoveMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error { request := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeMappedDirectory, diff --git a/internal/vm/guestmanager/network_lcow.go b/internal/vm/guestmanager/network_lcow.go index a993d3c431..b0c71a85a3 100644 --- a/internal/vm/guestmanager/network_lcow.go +++ b/internal/vm/guestmanager/network_lcow.go @@ -11,8 +11,8 @@ import ( "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) -// AddLCOWNetworkInterface adds a network interface to the LCOW guest. -func (gm *Guest) AddLCOWNetworkInterface(ctx context.Context, settings *guestresource.LCOWNetworkAdapter) error { +// AddNetworkInterface adds a network interface to the LCOW guest. +func (gm *Guest) AddNetworkInterface(ctx context.Context, settings *guestresource.LCOWNetworkAdapter) error { modifyRequest := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeNetwork, @@ -28,8 +28,8 @@ func (gm *Guest) AddLCOWNetworkInterface(ctx context.Context, settings *guestres return nil } -// RemoveLCOWNetworkInterface removes a network interface from the LCOW guest. -func (gm *Guest) RemoveLCOWNetworkInterface(ctx context.Context, settings *guestresource.LCOWNetworkAdapter) error { +// RemoveNetworkInterface removes a network interface from the LCOW guest. +func (gm *Guest) RemoveNetworkInterface(ctx context.Context, settings *guestresource.LCOWNetworkAdapter) error { modifyRequest := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeNetwork, diff --git a/internal/vm/guestmanager/request_helpers.go b/internal/vm/guestmanager/request_helpers.go index 60481abf5e..a8876b27d8 100644 --- a/internal/vm/guestmanager/request_helpers.go +++ b/internal/vm/guestmanager/request_helpers.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) package guestmanager diff --git a/internal/vm/guestmanager/scsi.go b/internal/vm/guestmanager/scsi.go index c4f6bfa89b..4605a78499 100644 --- a/internal/vm/guestmanager/scsi.go +++ b/internal/vm/guestmanager/scsi.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) package guestmanager diff --git a/internal/vm/guestmanager/scsi_lcow.go b/internal/vm/guestmanager/scsi_lcow.go index c62c01d013..719aa19020 100644 --- a/internal/vm/guestmanager/scsi_lcow.go +++ b/internal/vm/guestmanager/scsi_lcow.go @@ -11,8 +11,8 @@ import ( "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) -// AddLCOWMappedVirtualDisk maps a virtual disk into a LCOW guest. -func (gm *Guest) AddLCOWMappedVirtualDisk(ctx context.Context, settings guestresource.LCOWMappedVirtualDisk) error { +// AddMappedVirtualDisk maps a virtual disk into a LCOW guest. +func (gm *Guest) AddMappedVirtualDisk(ctx context.Context, settings guestresource.LCOWMappedVirtualDisk) error { request := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeMappedVirtualDisk, @@ -28,8 +28,8 @@ func (gm *Guest) AddLCOWMappedVirtualDisk(ctx context.Context, settings guestres return nil } -// RemoveLCOWMappedVirtualDisk unmaps a virtual disk from the LCOW guest. -func (gm *Guest) RemoveLCOWMappedVirtualDisk(ctx context.Context, settings guestresource.LCOWMappedVirtualDisk) error { +// RemoveMappedVirtualDisk unmaps a virtual disk from the LCOW guest. +func (gm *Guest) RemoveMappedVirtualDisk(ctx context.Context, settings guestresource.LCOWMappedVirtualDisk) error { request := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeMappedVirtualDisk, diff --git a/internal/vm/guestmanager/scsi_wcow.go b/internal/vm/guestmanager/scsi_wcow.go index d2dbf58ca0..968f4502b7 100644 --- a/internal/vm/guestmanager/scsi_wcow.go +++ b/internal/vm/guestmanager/scsi_wcow.go @@ -11,8 +11,8 @@ import ( "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) -// AddWCOWMappedVirtualDisk maps a virtual disk into a WCOW guest. -func (gm *Guest) AddWCOWMappedVirtualDisk(ctx context.Context, settings guestresource.WCOWMappedVirtualDisk) error { +// AddMappedVirtualDisk maps a virtual disk into a WCOW guest. +func (gm *Guest) AddMappedVirtualDisk(ctx context.Context, settings guestresource.WCOWMappedVirtualDisk) error { request := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeMappedVirtualDisk, @@ -28,8 +28,8 @@ func (gm *Guest) AddWCOWMappedVirtualDisk(ctx context.Context, settings guestres return nil } -// AddWCOWMappedVirtualDiskForContainerScratch attaches a scratch disk in the WCOW guest. -func (gm *Guest) AddWCOWMappedVirtualDiskForContainerScratch(ctx context.Context, settings guestresource.WCOWMappedVirtualDisk) error { +// AddMappedVirtualDiskForContainerScratch attaches a scratch disk in the WCOW guest. +func (gm *Guest) AddMappedVirtualDiskForContainerScratch(ctx context.Context, settings guestresource.WCOWMappedVirtualDisk) error { request := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeMappedVirtualDiskForContainerScratch, @@ -45,8 +45,8 @@ func (gm *Guest) AddWCOWMappedVirtualDiskForContainerScratch(ctx context.Context return nil } -// RemoveWCOWMappedVirtualDisk unmaps a virtual disk from the WCOW guest. -func (gm *Guest) RemoveWCOWMappedVirtualDisk(ctx context.Context, settings guestresource.WCOWMappedVirtualDisk) error { +// RemoveMappedVirtualDisk unmaps a virtual disk from the WCOW guest. +func (gm *Guest) RemoveMappedVirtualDisk(ctx context.Context, settings guestresource.WCOWMappedVirtualDisk) error { request := &hcsschema.ModifySettingRequest{ GuestRequest: guestrequest.ModificationRequest{ ResourceType: guestresource.ResourceTypeMappedVirtualDisk, diff --git a/internal/vm/guestmanager/security_policy.go b/internal/vm/guestmanager/security_policy.go index bb04749ced..458356e259 100644 --- a/internal/vm/guestmanager/security_policy.go +++ b/internal/vm/guestmanager/security_policy.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) package guestmanager diff --git a/internal/vm/vmmanager/doc.go b/internal/vm/vmmanager/doc.go index df022c14e4..0ba469b508 100644 --- a/internal/vm/vmmanager/doc.go +++ b/internal/vm/vmmanager/doc.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) /* Package vmmanager manages host-side VM configuration and lifecycle for utility VMs (UVMs). diff --git a/internal/vm/vmmanager/lifetime.go b/internal/vm/vmmanager/lifetime.go index c98cba82a4..f09459d5cf 100644 --- a/internal/vm/vmmanager/lifetime.go +++ b/internal/vm/vmmanager/lifetime.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) package vmmanager diff --git a/internal/vm/vmmanager/network.go b/internal/vm/vmmanager/network.go index e30488ba60..f4a31a415a 100644 --- a/internal/vm/vmmanager/network.go +++ b/internal/vm/vmmanager/network.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) package vmmanager diff --git a/internal/vm/vmmanager/pci.go b/internal/vm/vmmanager/pci.go index f3d12a3ad3..3811ef00b4 100644 --- a/internal/vm/vmmanager/pci.go +++ b/internal/vm/vmmanager/pci.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) package vmmanager diff --git a/internal/vm/vmmanager/pipe.go b/internal/vm/vmmanager/pipe.go index f46904ae14..91d1608758 100644 --- a/internal/vm/vmmanager/pipe.go +++ b/internal/vm/vmmanager/pipe.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && wcow package vmmanager diff --git a/internal/vm/vmmanager/plan9.go b/internal/vm/vmmanager/plan9.go index 9222268477..292b7cd123 100644 --- a/internal/vm/vmmanager/plan9.go +++ b/internal/vm/vmmanager/plan9.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && lcow package vmmanager diff --git a/internal/vm/vmmanager/resources.go b/internal/vm/vmmanager/resources.go index c91ae3db07..040ba63a6d 100644 --- a/internal/vm/vmmanager/resources.go +++ b/internal/vm/vmmanager/resources.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) package vmmanager diff --git a/internal/vm/vmmanager/scsi.go b/internal/vm/vmmanager/scsi.go index 038ac66a5e..7d2e59c986 100644 --- a/internal/vm/vmmanager/scsi.go +++ b/internal/vm/vmmanager/scsi.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) package vmmanager diff --git a/internal/vm/vmmanager/utils.go b/internal/vm/vmmanager/utils.go index 5790fd5b0d..535c963f4d 100644 --- a/internal/vm/vmmanager/utils.go +++ b/internal/vm/vmmanager/utils.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) package vmmanager diff --git a/internal/vm/vmmanager/uvm.go b/internal/vm/vmmanager/uvm.go index 45f53220e7..ccff4747fb 100644 --- a/internal/vm/vmmanager/uvm.go +++ b/internal/vm/vmmanager/uvm.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && (lcow || wcow) package vmmanager diff --git a/internal/vm/vmmanager/vmsocket.go b/internal/vm/vmmanager/vmsocket.go index c6fb7a0bfe..e1d89cc003 100644 --- a/internal/vm/vmmanager/vmsocket.go +++ b/internal/vm/vmmanager/vmsocket.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && wcow package vmmanager diff --git a/internal/vm/vmmanager/vpmem.go b/internal/vm/vmmanager/vpmem.go index fddaf66fe8..84ea3cfe70 100644 --- a/internal/vm/vmmanager/vpmem.go +++ b/internal/vm/vmmanager/vpmem.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && lcow package vmmanager diff --git a/internal/vm/vmmanager/vsmb.go b/internal/vm/vmmanager/vsmb.go index b957f257a2..1eb5939f03 100644 --- a/internal/vm/vmmanager/vsmb.go +++ b/internal/vm/vmmanager/vsmb.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && wcow package vmmanager diff --git a/test/parity/vm/hcs_lcow_document_creator_test.go b/test/parity/vm/hcs_lcow_document_creator_test.go index 03be8c6797..c6cf54eb82 100644 --- a/test/parity/vm/hcs_lcow_document_creator_test.go +++ b/test/parity/vm/hcs_lcow_document_creator_test.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && lcow package vmparity diff --git a/test/parity/vm/lcow_doc_test.go b/test/parity/vm/lcow_doc_test.go index 5d45b9c8b8..ffa4523de1 100644 --- a/test/parity/vm/lcow_doc_test.go +++ b/test/parity/vm/lcow_doc_test.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && lcow package vmparity