Skip to content

Commit

Permalink
core: only use a shared lock for thin template overlays
Browse files Browse the repository at this point in the history
When downloading a disk that is an overlay of a template, take only a
shared lock on the disk and skip the locked disk validation, this would
allow downloading disks of thin VMs without failing on the disk being
locked.

Bug-Url: Bug-Url: https://bugzilla.redhat.com/1879391
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
  • Loading branch information
bennyz authored and ahadas committed Jun 24, 2022
1 parent c7111ee commit 6c7f72b
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,18 @@ protected Map<String, Pair<String, String>> getSharedLocks() {
// StartVmBackup should handle locks
return locks;
}

if (!Guid.isNullOrEmpty(getParameters().getImageId()) && getDiskImage() != null) {
List<VM> vms = vmDao.getVmsListForDisk(getDiskImage().getId(), true);
vms.forEach(vm -> locks.put(vm.getId().toString(),
LockMessagesMatchUtil.makeLockingPair(LockingGroup.VM, getDiskIsBeingTransferredLockMessage())));
}

if (getDiskImage() != null && getParameters().getTransferType() == TransferType.Download) {
locks.put(getDiskImage().getId().toString(),
LockMessagesMatchUtil.makeLockingPair(LockingGroup.DISK, EngineMessage.ACTION_TYPE_FAILED_DISK_IS_LOCKED));
}

return locks;
}

Expand All @@ -466,7 +472,8 @@ protected Map<String, Pair<String, String>> getExclusiveLocks() {
// StartVmBackup should handle locks
return locks;
}
if (getDiskImage() != null) {

if (getDiskImage() != null && getParameters().getTransferType() == TransferType.Upload) {
locks.put(getDiskImage().getId().toString(),
LockMessagesMatchUtil.makeLockingPair(LockingGroup.DISK, getDiskIsBeingTransferredLockMessage()));
}
Expand Down

0 comments on commit 6c7f72b

Please sign in to comment.