Skip to content

Commit

Permalink
core: permissive memory snapshot disk
Browse files Browse the repository at this point in the history
When creating memory disk for live VM snapshot, the engine selects the
storage domain to use. The engine might select a storage domain that the
current user doesn't have permission on. This will fail to add the
memory disk and the snapshot operation will fail.
With this patch, the storage domains will be also filtered based on the
user permission.

Change-Id: Id1a1c529dde795628f214c0c9d9a28efac89eec0
Bug-Url: https://bugzilla.redhat.com/1565183
Signed-off-by: Liran Rotenberg <lrotenbe@redhat.com>
  • Loading branch information
liranr23 authored and ahadas committed Jun 28, 2022
1 parent d95b4d4 commit b11e94b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public Guid getStorageDomainId() {
MemoryUtils.METADATA_SIZE_IN_BYTES);
StorageDomain storageDomain = memoryStorageHandler.findStorageDomainForMemory(
getStoragePoolId(), diskDummiesForMemSize,
DisksFilter.filterImageDisks(diskDao.getAllForVm(getVmId())), getVm());
DisksFilter.filterImageDisks(diskDao.getAllForVm(getVmId())), getVm(), getUserId());
if (storageDomain != null) {
cachedStorageDomainId = storageDomain.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ private StorageDomain findDomainForMemoryImagesAndCreateDummies(List<DiskImage>
MemoryUtils.createDiskDummies(vmOverheadCalculator.getSnapshotMemorySizeInBytes(getVm()),
MemoryUtils.METADATA_SIZE_IN_BYTES);
StorageDomain storageDomain = memoryStorageHandler.findStorageDomainForMemory(
getParameters().getStoragePoolId(), memoryDisks, getVmDisksDummies(), getVm());
getParameters().getStoragePoolId(), memoryDisks, getVmDisksDummies(), getVm(), getUserId());
disksList.addAll(memoryDisks.asList());
return storageDomain;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ public class MemoryStorageHandler {
* @param vmForLogging
* The VM which the memory volumes being created belong to.<br/>
* Note: This parameter is used for logging purposed only.
* @param userId
* The user doing the action.
* @return storage domain in the given pool with at least the required amount of free space,
* or null if no such storage domain exists in the pool
*/
public StorageDomain findStorageDomainForMemory(Guid storagePoolId, MemoryDisks memoryDisks,
Collection<DiskImage> vmDisks, VM vmForLogging) {
List<StorageDomain> domainsInPool = storageDomainDao.getAllForStoragePool(storagePoolId);
Collection<DiskImage> vmDisks, VM vmForLogging, Guid userId) {
List<StorageDomain> domainsInPool = storageDomainDao.getAllForStoragePool(storagePoolId, userId, true);
StorageDomain storageDomainForMemory = findStorageDomainForMemory(domainsInPool, memoryDisks, vmDisks);
if (storageDomainForMemory != null) {
updateDisksStorage(storageDomainForMemory, memoryDisks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public Map<String, String> getJobMessageProperties() {
public Guid getStorageDomainIdForVmMemory(MemoryDisks memoryDisks) {
if (cachedStorageDomainId.equals(Guid.Empty) && getVm() != null) {
StorageDomain storageDomain = memoryStorageHandler.findStorageDomainForMemory(
getVm().getStoragePoolId(), memoryDisks, getDisksList(), getVm());
getVm().getStoragePoolId(), memoryDisks, getDisksList(), getVm(), getUserId());
if (storageDomain != null) {
cachedStorageDomainId = storageDomain.getId();
}
Expand Down

0 comments on commit b11e94b

Please sign in to comment.