@@ -5197,6 +5197,21 @@ def _prepare_ebtables_for_mocbr(self, cmd):
5197
5197
bash .bash_r (EBTABLES_CMD + rule )
5198
5198
bash .bash_r ("ebtables-save | uniq | ebtables-restore" )
5199
5199
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
+
5200
5215
def _start_vm (self , cmd ):
5201
5216
try :
5202
5217
vm = get_vm_by_uuid_no_retry (cmd .vmInstanceUuid , False )
@@ -5232,8 +5247,7 @@ def _start_vm(self, cmd):
5232
5247
vm .restore (snapshot_path )
5233
5248
finally :
5234
5249
if mount_path :
5235
- linux .umount (mount_path )
5236
- linux .rmdir_if_empty (mount_path )
5250
+ self .umount_snapshot_path (mount_path )
5237
5251
5238
5252
lvm .deactive_lv (cmd .memorySnapshotPath )
5239
5253
return
0 commit comments