Skip to content

Commit

Permalink
core: skip disk profiles validation on memory disk
Browse files Browse the repository at this point in the history
When we create the memory or metadata disks they are a result of live
snapshot with memory or hibernation command. In some cases the user can
own the VM, including the option to execute the above command but he may
not have the disk profile permission to add those disks.

This patch will skip the permission validation in those cases, allowing
a user to create attach disks for disks that are not a real virutal
disks.

Change-Id: Ib04048d652c8d98df84ffccc4babd71730b218dc
Bug-Url: https://bugzilla.redhat.com/1565183
Signed-off-by: Liran Rotenberg <lrotenbe@redhat.com>
  • Loading branch information
liranr23 committed Aug 18, 2022
1 parent 52f06b2 commit 8efd30c
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.ovirt.engine.core.common.businessentities.ActionGroup;
import org.ovirt.engine.core.common.businessentities.aaa.DbUser;
import org.ovirt.engine.core.common.businessentities.profiles.DiskProfile;
import org.ovirt.engine.core.common.businessentities.storage.DiskContentType;
import org.ovirt.engine.core.common.businessentities.storage.DiskImage;
import org.ovirt.engine.core.common.businessentities.storage.DiskStorageType;
import org.ovirt.engine.core.common.errors.EngineMessage;
Expand Down Expand Up @@ -63,6 +64,9 @@ public ValidationResult setAndValidateDiskProfiles(Map<DiskImage, Guid> map, DbU
diskImage.getDiskStorageType(), diskImage.getDiskAlias());
continue;
}
if (shouldSetDiskProfileOnImage(diskImage)) {
continue;
}
if (diskImage.getDiskProfileId() == null && storageDomainId != null) {
List<DiskProfile> diskProfilesList = storageDiskProfilesMap.get(storageDomainId);
if (diskProfilesList == null) {
Expand Down Expand Up @@ -149,4 +153,9 @@ private boolean isDiskProfilePermitted(DiskProfile diskProfile,
diskProfile.getId(),
VdcObjectType.DiskProfile) != null;
}

private boolean shouldSetDiskProfileOnImage(DiskImage diskImage) {
return diskImage.getContentType() == DiskContentType.MEMORY_DUMP_VOLUME
|| diskImage.getContentType() == DiskContentType.MEMORY_METADATA_VOLUME;
}
}

0 comments on commit 8efd30c

Please sign in to comment.