Skip to content

Commit b4dc9ec

Browse files
committed
fix(largeblock): redo VG activation using custom config
The change of system config for LVM means that `/dev/` is not scanned, meaning the loop device is never used for VG activation. Add a custom scan parameter to LVM commands. We also now systematically do the call to _redo_vg_connection to use our custom parameters to enable the LV on the correct device before calling `EXTSR.attach()`. Signed-off-by: Damien Thenot <damien.thenot@vates.tech>
1 parent f373af5 commit b4dc9ec

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

drivers/LargeBlockSR.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ def attach(self, sr_uuid) -> None:
7272
vg_device = self._get_device()
7373
self.dconf["device"] = ",".join(vg_device)
7474
self._create_emulated_device()
75-
if not self._is_vg_connection_correct(): # Check if we need to redo the connection by parsing `vgs -o vg_name,devices self.vgname`
76-
self._redo_vg_connection() # Call redo VG connection to connect it correctly to the loop device instead of the real 4KiB block device
75+
self._redo_vg_connection() # Call redo VG connection to connect it correctly to the loop device instead of the real 4KiB block device
7776
super(LargeBlockSR, self).attach(sr_uuid)
7877

7978
@override
@@ -187,7 +186,7 @@ def _get_device_from_loopdev(loopdevs):
187186

188187
def _get_device_from_vg(self):
189188
devices = []
190-
output = util.pread2(["vgs", "--noheadings", "-o", "vg_name,devices", self.vgname]).splitlines()
189+
output = util.pread2(["vgs", "--noheadings", "-o", "vg_name,devices", self.vgname, "--config", "devices{scan=[\"/dev/\"]}"]).splitlines()
191190
for line in output:
192191
line = line.split()
193192
dev = line[1].split("(")[0]
@@ -207,11 +206,6 @@ def _get_device(self):
207206

208207
return vg_device
209208

210-
def _is_vg_connection_correct(self):
211-
output = util.pread2(["vgs", "--noheadings", "-o", "vg_name,devices", self.vgname]).split()
212-
output[1] = output[1].split("(")[0]
213-
return bool(re.match(r"(.*\.512)|(/dev/loop[0-9]+)", output[1]))
214-
215209
def _redo_vg_connection(self):
216210
"""
217211
In case of using a LargeBlockSR, the LVM scan at boot will find the LogicalVolume on the real block device.
@@ -224,7 +218,7 @@ def _redo_vg_connection(self):
224218
util.SMlog("Reconnecting VG {} to use emulated device".format(self.vgname))
225219
try:
226220
lvutil.setActiveVG(self.vgname, False)
227-
lvutil.setActiveVG(self.vgname, True, config="devices{ global_filter = [ \"a|/dev/loop.*|\", \"r|.*|\" ] }")
221+
lvutil.setActiveVG(self.vgname, True, config="devices{ scan = [\"/dev/\"] global_filter = [ \"a|/dev/loop.*|\", \"r|.*|\" ] }")
228222
except util.CommandException as e:
229223
xs_errors.XenError("LargeBlockVGReconnectFailed", opterr="Failed to reconnect the VolumeGroup {}, error: {}".format(self.vgname, e))
230224

0 commit comments

Comments
 (0)