@@ -5197,6 +5197,21 @@ def _prepare_ebtables_for_mocbr(self, cmd):
51975197 bash .bash_r (EBTABLES_CMD + rule )
51985198 bash .bash_r ("ebtables-save | uniq | ebtables-restore" )
51995199
5200+ def umount_snapshot_path (self , mount_path ):
5201+ @linux .retry (times = 15 , sleep_time = 1 )
5202+ def wait_path_unused (path ):
5203+ used_process = linux .linux_lsof (path )
5204+ if len (used_process ) != 0 :
5205+ raise RetryException ("path %s still used: %s" % (path , used_process ))
5206+
5207+ try :
5208+ wait_path_unused (mount_path )
5209+ finally :
5210+ used_process = linux .linux_lsof (mount_path )
5211+ if len (used_process ) == 0 :
5212+ linux .umount (mount_path )
5213+ linux .rm_dir_force (mount_path )
5214+
52005215 def _start_vm (self , cmd ):
52015216 try :
52025217 vm = get_vm_by_uuid_no_retry (cmd .vmInstanceUuid , False )
@@ -5232,8 +5247,7 @@ def _start_vm(self, cmd):
52325247 vm .restore (snapshot_path )
52335248 finally :
52345249 if mount_path :
5235- linux .umount (mount_path )
5236- linux .rmdir_if_empty (mount_path )
5250+ self .umount_snapshot_path (mount_path )
52375251
52385252 lvm .deactive_lv (cmd .memorySnapshotPath )
52395253 return
0 commit comments