Skip to content

Commit

Permalink
fix: bug potentially not removing RW device.
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim An <maksiman@microsoft.com>
  • Loading branch information
anmaxvl committed Apr 18, 2023
1 parent 792a588 commit 1cf3d81
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/guest/runtime/hcsv2/uvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ func (h *Host) CreateContainer(ctx context.Context, id string, settings *prot.VM
return c, nil
}

func (h *Host) modifyHostSettings(ctx context.Context, containerID string, req *guestrequest.ModificationRequest) (err error) {
func (h *Host) modifyHostSettings(ctx context.Context, containerID string, req *guestrequest.ModificationRequest) (retErr error) {
switch req.ResourceType {
case guestresource.ResourceTypeMappedVirtualDisk:
mvd := req.Settings.(*guestresource.LCOWMappedVirtualDisk)
Expand All @@ -561,7 +561,7 @@ func (h *Host) modifyHostSettings(ctx context.Context, containerID string, req *
return err
}
defer func() {
if err != nil {
if retErr != nil {
_ = h.hostMounts.RemoveRWDevice(mvd.MountPath, source)
}
}()
Expand All @@ -570,7 +570,7 @@ func (h *Host) modifyHostSettings(ctx context.Context, containerID string, req *
return err
}
defer func() {
if err != nil {
if retErr != nil {
_ = h.hostMounts.AddRWDevice(mvd.MountPath, source, mvd.Encrypted)
}
}()
Expand Down

0 comments on commit 1cf3d81

Please sign in to comment.