Skip to content

Commit aff94e1

Browse files
committed
feature(lvmsr): enable vdi_revert on all lvm based SRs
Signed-off-by: Antoine Bartuccio <antoine.bartuccio@vates.tech>
1 parent a3736ad commit aff94e1

4 files changed

Lines changed: 28 additions & 3 deletions

File tree

drivers/LVMSR.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ class LVMSR(SR.SR):
232232
TEST_MODE_VHD_FAIL_RESIZE_END:
233233
"VHD_UTIL_TEST_FAIL_RESIZE_END"
234234
}
235+
236+
# Journals that should prevent VMs from booting while pending
237+
_CRITICAL_JOURNALS = [
238+
RevertLogEntry.JRN_KEY,
239+
InsertCloneLogEntry.JRN_KEY,
240+
]
241+
235242
testMode = ""
236243

237244
legacyMode = True
@@ -328,13 +335,25 @@ def load(self, sr_uuid) -> None:
328335
self.legacyMode = False
329336

330337
if lvutil._checkVG(self.vgname):
338+
# Disable SR on slaves when mounting VDIs if
339+
# a critical journal is pending
340+
if (
341+
not self.isMaster
342+
and self.cmd not in ["vdi_detach", "vdi_activate", "vdi_deactivate", "nop"]
343+
and self._has_critical_journals()
344+
):
345+
raise xs_errors.XenError(
346+
"SRUnavailable", opterr="Critical journals are pending"
347+
)
348+
331349
if self.isMaster and not self.cmd in [
332350
"vdi_attach",
333351
"vdi_detach",
334352
"vdi_activate",
335353
"vdi_deactivate",
336354
]:
337355
self._undoAllJournals()
356+
338357
if not self.cmd in ["sr_attach", "sr_probe"]:
339358
self._checkMetadataVolume()
340359

@@ -1033,6 +1052,12 @@ def _loadvdis(self):
10331052
util.SMlog("Scan found hidden leaf (%s), ignoring" % uuid)
10341053
del self.vdis[uuid]
10351054

1055+
def _has_critical_journals(self) -> bool:
1056+
for key in self._CRITICAL_JOURNALS:
1057+
if any(self.journaler.getAll(key)):
1058+
return True
1059+
return False
1060+
10361061
def _ensureSpaceAvailable(self, amount_needed):
10371062
space_available = lvutil._getVGstats(self.vgname)['freespace']
10381063
if (space_available < amount_needed):

drivers/LVMoFCoESR.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"VDI_GENERATE_CONFIG", "VDI_SNAPSHOT", "VDI_CLONE",
3535
"VDI_RESIZE", "ATOMIC_PAUSE", "VDI_RESET_ON_BOOT/2",
3636
"VDI_UPDATE", "VDI_MIRROR", "VDI_CONFIG_CBT", "VDI_ACTIVATE",
37-
"VDI_DEACTIVATE"]
37+
"VDI_DEACTIVATE", "VDI_REVERT"]
3838

3939
CONFIGURATION = [['SCSIid', 'The scsi_id of the destination LUN'],
4040
['allocation', 'Valid values are thick or thin(optional,\

drivers/LVMoHBASR.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"VDI_CREATE", "VDI_DELETE", "VDI_ATTACH", "VDI_DETACH",
4242
"VDI_GENERATE_CONFIG", "VDI_SNAPSHOT", "VDI_CLONE", "VDI_MIRROR",
4343
"VDI_RESIZE", "ATOMIC_PAUSE", "VDI_RESET_ON_BOOT/2",
44-
"VDI_UPDATE", "VDI_CONFIG_CBT", "VDI_ACTIVATE", "VDI_DEACTIVATE"]
44+
"VDI_UPDATE", "VDI_CONFIG_CBT", "VDI_ACTIVATE", "VDI_DEACTIVATE", "VDI_REVERT"]
4545

4646
CONFIGURATION = [['SCSIid', 'The scsi_id of the destination LUN'], \
4747
['allocation', 'Valid values are thick or thin (optional, defaults to thick)']]

drivers/LVMoISCSISR.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"VDI_GENERATE_CONFIG", "VDI_CLONE", "VDI_SNAPSHOT",
4646
"VDI_RESIZE", "ATOMIC_PAUSE", "VDI_RESET_ON_BOOT/2",
4747
"VDI_UPDATE", "VDI_MIRROR", "VDI_CONFIG_CBT",
48-
"VDI_ACTIVATE", "VDI_DEACTIVATE"]
48+
"VDI_ACTIVATE", "VDI_DEACTIVATE", "VDI_REVERT"]
4949

5050
CONFIGURATION = [['SCSIid', 'The scsi_id of the destination LUN'], \
5151
['target', 'IP address or hostname of the iSCSI target'], \

0 commit comments

Comments
 (0)