Skip to content

Commit 56a9fa0

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 56a9fa0

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

drivers/LargeBlockSR.py

Lines changed: 4 additions & 5 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]
@@ -208,7 +207,7 @@ def _get_device(self):
208207
return vg_device
209208

210209
def _is_vg_connection_correct(self):
211-
output = util.pread2(["vgs", "--noheadings", "-o", "vg_name,devices", self.vgname]).split()
210+
output = util.pread2(["vgs", "--noheadings", "-o", "vg_name,devices", self.vgname, "--config", "devices{scan=[\"/dev/\"]}"]).split()
212211
output[1] = output[1].split("(")[0]
213212
return bool(re.match(r"(.*\.512)|(/dev/loop[0-9]+)", output[1]))
214213

@@ -224,7 +223,7 @@ def _redo_vg_connection(self):
224223
util.SMlog("Reconnecting VG {} to use emulated device".format(self.vgname))
225224
try:
226225
lvutil.setActiveVG(self.vgname, False)
227-
lvutil.setActiveVG(self.vgname, True, config="devices{ global_filter = [ \"a|/dev/loop.*|\", \"r|.*|\" ] }")
226+
lvutil.setActiveVG(self.vgname, True, config="devices{ scan = [\"/dev/\"] global_filter = [ \"a|/dev/loop.*|\", \"r|.*|\" ] }")
228227
except util.CommandException as e:
229228
xs_errors.XenError("LargeBlockVGReconnectFailed", opterr="Failed to reconnect the VolumeGroup {}, error: {}".format(self.vgname, e))
230229

0 commit comments

Comments
 (0)