Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public boolean performNextOperation(int completedChildCount) {
// at the end of CreateSnapshotForVm command called from the executeCommand() method.
// Here the lock is acquired again and will be released when this command (LiveMigrateDisk)
// finishes.
EngineLock removeSnapshotLock = createEngineLockForSnapshotRemove();
EngineLock removeSnapshotLock = getEngineLockForSnapshotRemove();
if (!lockManager.acquireLock(removeSnapshotLock).isAcquired()) {
log.info("Failed to acquire VM lock, will retry on the next polling cycle");
return true;
Expand Down Expand Up @@ -378,6 +378,17 @@ private EngineLock createEngineLockForSnapshotRemove() {
getSharedLocksForSnapshotRemove());
}

private EngineLock getEngineLockForSnapshotRemove() {
EngineLock lock = getLock();
if (lock != null && !lock.getExclusiveLocks().isEmpty()) {
// In the generic scenario, use the lock created by the MigrateDiskCommand
return lock;
}
// This happens when the engine was restarted during active live disk migration. Use special lock to clean up
// temporary VM snapshot created by the migration
return createEngineLockForSnapshotRemove();
}

private boolean isConsiderSuccessful() {
return getParameters().getLiveDiskMigrateStage() == LiveDiskMigrateStage.AUTO_GENERATED_SNAPSHOT_REMOVE_END;
}
Expand Down