Alissa Bonas has posted comments on this change.

Change subject: core: Add storage validation when plugging an image.
......................................................................


Patch Set 4: (3 inline comments)

....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AttachDiskToVmCommand.java
Line 100:         }
Line 101:         if (isImageDisk) {
Line 102:             StorageDomain storageDomain = 
getStorageDomainDAO().getForStoragePool(
Line 103:                     ((DiskImage) disk).getStorageIds().get(0), 
((DiskImage) disk).getStoragePoolId());
Line 104:             StorageDomainValidator storageDomainValidator = new 
StorageDomainValidator(storageDomain);
what happens here if storageDomain returned one row above as null? (when 
getting it from db from getStorageDomainDAO())
Line 105:             if 
(!validate(storageDomainValidator.isDomainExistAndActive())) {
Line 106:                 return false;
Line 107:             }
Line 108:         }


....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotPlugDiskToVmCommand.java
Line 50:                 isVmNotInPreviewSnapshot() &&
Line 51:                 imageValidation();
Line 52:     }
Line 53: 
Line 54:     private boolean imageValidation() {
this method checks among other checks if domain is active, which is not exactly 
an image validation.
Please consider renaming the method.
Line 55:         if (disk.getDiskStorageType() != DiskStorageType.IMAGE) {
Line 56:             return true;
Line 57:         }
Line 58:         StorageDomain storageDomain = 
getStorageDomainDAO().getForStoragePool(


Line 56:             return true;
Line 57:         }
Line 58:         StorageDomain storageDomain = 
getStorageDomainDAO().getForStoragePool(
Line 59:                 ((DiskImage) disk).getStorageIds().get(0), 
((DiskImage) disk).getStoragePoolId());
Line 60:         StorageDomainValidator storageDomainValidator = new 
StorageDomainValidator(storageDomain);
The casting to DiskImage is done here twice .
Since this is a downcasting operation, it is an overhead in runtime.
- please do it only once.
Line 61:         return 
validate(storageDomainValidator.isDomainExistAndActive());
Line 62:     }
Line 63: 
Line 64:     private boolean checkCanPerformPlugUnPlugDisk() {


-- 
To view, visit http://gerrit.ovirt.org/17170
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ieeb2522bc5aa280b9b98ef728737aeeaa82d1263
Gerrit-PatchSet: 4
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Maor Lipchuk <mlipc...@redhat.com>
Gerrit-Reviewer: Alissa Bonas <abo...@redhat.com>
Gerrit-Reviewer: Allon Mureinik <amure...@redhat.com>
Gerrit-Reviewer: Daniel Erez <de...@redhat.com>
Gerrit-Reviewer: Liron Ar <lara...@redhat.com>
Gerrit-Reviewer: Maor Lipchuk <mlipc...@redhat.com>
Gerrit-Reviewer: Sergey Gotliv <sgot...@redhat.com>
Gerrit-Reviewer: Tal Nisan <tni...@redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to