Skip to content

Commit

Permalink
Merge pull request #157 from jterry75/fix_detachvhd
Browse files Browse the repository at this point in the history
Fix regression in DetachVhd
  • Loading branch information
jterry75 authored Aug 6, 2019
2 parents a969fb0 + 5adf678 commit 6c72808
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions vhd/vhd.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,21 @@ func CreateVhdx(path string, maxSizeInGb, blockSizeInMb uint32) error {
return nil
}

// DetachVhd detaches a VHD attached at the given path.
// DetachVhd detaches a mounted container layer vhd found at `path`.
func DetachVhd(path string) error {
handle, err := OpenVirtualDisk(path, VirtualDiskAccessDetach, OpenVirtualDiskFlagNone)
handle, err := OpenVirtualDisk(
path,
VirtualDiskAccessNone,
OpenVirtualDiskFlagCachedIO|OpenVirtualDiskFlagIgnoreRelativeParentLocator)

if err != nil {
return err
}
defer syscall.CloseHandle(handle)
return detachVirtualDisk(handle, 0, 0)
}

// OpenVirtuaDisk obtains a handle to a VHD opened with supplied access mask and flags.
// OpenVirtualDisk obtains a handle to a VHD opened with supplied access mask and flags.
func OpenVirtualDisk(path string, accessMask VirtualDiskAccessMask, flag VirtualDiskFlag) (syscall.Handle, error) {
var (
defaultType virtualStorageType
Expand Down

0 comments on commit 6c72808

Please sign in to comment.