Tal Nisan has uploaded a new change for review.

Change subject: core: Do not convert to preallocated images import to a block 
domain
......................................................................

core: Do not convert to preallocated images import to a block domain

Images that are imported to a block domain were converted to
preallocated since block domain does not support a raw-sparse image.
Instead now we convert the volume format from raw to cow only in case
that the original volume is raw-sparse

Bug-Url: https://bugzilla.redhat.com/1116486
Signed-off-by: Tal Nisan <[email protected]>
Change-Id: I519cf519857928899bf4cb4b65a862696e3a8aaa
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CopyImageGroupCommand.java
1 file changed, 22 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/21/31521/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CopyImageGroupCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CopyImageGroupCommand.java
index 973a0d7..2c791d7 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CopyImageGroupCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CopyImageGroupCommand.java
@@ -17,6 +17,7 @@
 import org.ovirt.engine.core.common.businessentities.ImageOperation;
 import org.ovirt.engine.core.common.businessentities.ImageStorageDomainMapId;
 import org.ovirt.engine.core.common.businessentities.StorageDomainStatic;
+import org.ovirt.engine.core.common.businessentities.VolumeFormat;
 import org.ovirt.engine.core.common.businessentities.VolumeType;
 import org.ovirt.engine.core.common.businessentities.image_storage_domain_map;
 import org.ovirt.engine.core.common.vdscommands.CopyImageVDSCommandParameters;
@@ -70,22 +71,18 @@
                     VDSCommandType.CopyImage,
                     new 
CopyImageVDSCommandParameters(getStorageDomain().getStoragePoolId(),
                             sourceDomainId,
-                            getParameters()
-                                    .getContainerId(),
+                            getParameters().getContainerId(),
                             getParameters().getImageGroupID(),
-                            getParameters()
-                                    .getImageId(),
+                            getParameters().getImageId(),
                             getParameters().getDestImageGroupId(),
                             getParameters().getDestinationImageId(),
                             "",
                             getParameters().getStorageDomainId(),
-                            getParameters()
-                                    .getCopyVolumeType(),
-                            getParameters().getVolumeFormat(),
-                            
getVolumeTypeForDomain(getParameters().getStorageDomainId()),
+                            getParameters().getCopyVolumeType(),
+                            getVolumeFormatForDomain(),
+                            getParameters().getVolumeType(),
                             isWipeAfterDelete(),
-                            getParameters()
-                                    .getForceOverride()));
+                            getParameters().getForceOverride()));
         } else {
             vdsReturnValue = runVdsCommand(
                     VDSCommandType.MoveImageGroup,
@@ -130,16 +127,22 @@
 
     /**
      * Since we are supporting copy/move operations between different storage 
families (file/block) we have to
-     * predetermine the volume type according to the destination storage type, 
for block domains we cannot use sparse
-     * for file domains we will use the same type of the original image
-     * @param storageDomainId
-     * @return
+     * predetermine the volume format according to the destination storage 
type, for block domains we cannot use sparse
+     * combined with raw so we will change the raw to cow in that case, file 
domains will have the original format
+     * retained
      */
-    private VolumeType getVolumeTypeForDomain(Guid storageDomainId) {
-        StorageDomainStatic destDomain = 
getStorageDomainStaticDAO().get(storageDomainId);
-        VolumeType volumeType = destDomain.getStorageType().isBlockDomain() ? 
VolumeType.Preallocated :
-                getParameters().getVolumeType();
-        return volumeType;
+    private VolumeFormat getVolumeFormatForDomain() {
+        if (getParameters().getVolumeFormat() == VolumeFormat.COW) {
+            return VolumeFormat.COW;
+        }
+
+        StorageDomainStatic destDomain = 
getStorageDomainStaticDAO().get(getParameters().getStorageDomainId());
+        if (destDomain.getStorageType().isBlockDomain() && 
getParameters().getVolumeType() == VolumeType.Sparse) {
+            return VolumeFormat.COW;
+        }
+        else {
+            return VolumeFormat.RAW;
+        }
     }
 
     /**


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I519cf519857928899bf4cb4b65a862696e3a8aaa
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Tal Nisan <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to