Skip to content

Commit

Permalink
CA-335721: Add missing case blktap2 for cached devices.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSimsCitrix committed Mar 3, 2020
1 parent 1c4985b commit 513abea
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/blktap2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,7 @@ def __init__(self, uuid, target, driver_info):
self.__o_direct = None
self.__o_direct_reason = None
self.lock = Lock("vdi", uuid)
self.tap = None

def get_o_direct_capability(self, options):
"""Returns True/False based on licensing and caching_params"""
Expand Down Expand Up @@ -1556,7 +1557,7 @@ def attach(self, sr_uuid, vdi_uuid, writable, activate = False, caching_params =

# Return backend/ link
back_path = self.BackendLink.from_uuid(sr_uuid, vdi_uuid).path()
if self.tap:
if self.tap_wanted():
# Only have NBD if we also have a tap
nbd_path =\
"nbd:unix:" + VDI.NBDLink.from_uuid(sr_uuid, vdi_uuid).path()
Expand Down Expand Up @@ -1767,7 +1768,7 @@ def _deactivate(self, sr_uuid, vdi_uuid, caching_params):
return

nbd_link = VDI.NBDLink.from_uuid(sr_uuid, vdi_uuid)
if not util.pathexists(nbd_link.path()):
if (not util.pathexists(nbd_link.path())) and self.tap_wanted():
util.SMlog("Backend path %s does not exist" % nbd_link.path())
return

Expand Down Expand Up @@ -2003,6 +2004,7 @@ def _setup_cache(self, session, sr_uuid, vdi_uuid, local_sr_uuid,
util.SMlog("Local read cache: %s, local leaf: %s" % \
(read_cache_path, local_leaf_path))

self.tap = leaf_tapdisk
return leaf_tapdisk.get_devpath()

def remove_cache(self, sr_uuid, vdi_uuid, params):
Expand Down

0 comments on commit 513abea

Please sign in to comment.