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

Signed-off-by: Tal Nisan <[email protected]>
Bug-Url: https://bugzilla.redhat.com/1111655
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/48/31548/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 fa6eef4..1a39ad4 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
@@ -15,6 +15,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;
@@ -64,22 +65,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,
@@ -124,16 +121,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/31548
To unsubscribe, visit http://gerrit.ovirt.org/settings

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

Reply via email to