@@ -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 ):
0 commit comments