Skip to content

Commit

Permalink
Ensure we can detach when deflate call is not possible
Browse files Browse the repository at this point in the history
Raising during detach call can leak a tapdisk process
that will cause trouble later.

Signed-off-by: BenjiReis <[email protected]>
  • Loading branch information
benjamreis committed Nov 30, 2023
1 parent 7e2a342 commit f3c4bfd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/lvhdutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def attachThin(journaler, srUuid, vdiUuid):
lock.release()


def detachThin(session, lvmCache, srUuid, vdiUuid):
def detachThinImpl(session, lvmCache, srUuid, vdiUuid):
"""Shrink the VDI to the minimal size if no one is using it"""
lvName = LV_PREFIX[vhdutil.VDI_TYPE_VHD] + vdiUuid
path = os.path.join(VG_LOCATION, VG_PREFIX + srUuid, lvName)
Expand All @@ -273,6 +273,13 @@ def detachThin(session, lvmCache, srUuid, vdiUuid):
lock.release()


def detachThin(session, lvmCache, srUuid, vdiUuid):
try:
detachThinImpl(session, lvmCache, srUuid, vdiUuid)
except Exception as e:
util.SMlog(f'Failed to detach properly VDI {vdiUuid}: {e}')


def createVHDJournalLV(lvmCache, jName, size):
"""Create a LV to hold a VHD journal"""
lvName = "%s_%s" % (JVHD_TAG, jName)
Expand Down

0 comments on commit f3c4bfd

Please sign in to comment.