Skip to content

Commit

Permalink
feat(LargeBlock): Rename the VG to use our prefix
Browse files Browse the repository at this point in the history
We override the variable used by EXTSR for creation/access to the VG.

Signed-off-by: Damien Thenot <[email protected]>
  • Loading branch information
Nambrok committed Mar 18, 2024
1 parent 4a42836 commit 714fc57
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/LargeBlockSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import xs_errors
import os
import re
import lvutil

CAPABILITIES = ["SR_PROBE", "SR_UPDATE", "SR_SUPPORTS_LOCAL_CACHING",
"VDI_CREATE", "VDI_DELETE", "VDI_ATTACH", "VDI_DETACH",
Expand All @@ -43,6 +44,8 @@
'configuration': CONFIGURATION
}

LARGEBLOCK_PREFIX = "XSLargeBlock-"

class LargeBlockSR(EXTSR.EXTSR):
"""Emulating 512b drives for EXT storage repository"""

Expand All @@ -56,6 +59,8 @@ def handles(srtype):
def load(self, sr_uuid):
super(LargeBlockSR, self).load(sr_uuid=sr_uuid)
self.is_deleting = False
self.vgname = LARGEBLOCK_PREFIX + sr_uuid
self.remotepath = os.path.join("/dev", self.vgname, sr_uuid)

def attach(self, sr_uuid):
if not self.is_deleting:
Expand Down Expand Up @@ -91,6 +96,11 @@ def delete(self, sr_uuid):
finally:
self._destroy_emulated_device(old_devices)
self.is_deleting = False
@deviceCheck
def probe(self):
# We override EXTSR.probe because it uses EXT_PREFIX in this call
return lvutil.srlist_toxml(lvutil.scan_srlist(LARGEBLOCK_PREFIX, self.dconf['device']),
LARGEBLOCK_PREFIX)

def _create_loopdev(self, dev, new_path):
cmd = ["losetup", "-f", "-v", "--show", "--sector-size", str(self.LOOP_SECTOR_SIZE), dev]
Expand Down

0 comments on commit 714fc57

Please sign in to comment.