nvazquez commented on code in PR #6661:
URL: https://github.com/apache/cloudstack/pull/6661#discussion_r951279416


##########
server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java:
##########
@@ -2905,9 +2905,13 @@ public Volume migrateVolume(MigrateVolumeCmd cmd) {
                 }
 
                 if (liveMigrateVolume && 
HypervisorType.KVM.equals(host.getHypervisorType())) {
-                    throw new InvalidParameterValueException("KVM does not 
support volume live migration due to the limited possibility to refresh VM XML 
domain. " +
-                            "Therefore, to live migrate a volume between 
storage pools, one must migrate the VM to a different host as well to force the 
VM XML domain update. " +
-                            "Use 'migrateVirtualMachineWithVolumes' instead.");
+                    StoragePoolVO destinationStoragePoolVo = 
_storagePoolDao.findById(storagePoolId);
+
+                    if (!(storagePoolVO.getPoolType() == 
Storage.StoragePoolType.StorPool && destinationStoragePoolVo.getPoolType() == 
Storage.StoragePoolType.StorPool)) {

Review Comment:
   Also this condition, can be hard to read



##########
plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java:
##########
@@ -709,24 +710,55 @@ public void copyAsync(DataObject srcData, DataObject 
dstData, AsyncCompletionCal
                 } else {
                     // download volume - first copies to secondary
                     VolumeObjectTO srcTO = (VolumeObjectTO)srcData.getTO();
-                    
StorPoolUtil.spLog("StorpoolPrimaryDataStoreDriverImpl.copyAsnc SRC path=%s ", 
srcTO.getPath());
-                    
StorPoolUtil.spLog("StorpoolPrimaryDataStoreDriverImpl.copyAsnc DST 
canonicalName=%s ", dstData.getDataStore().getClass().getCanonicalName());
+                    
StorPoolUtil.spLog("StorpoolPrimaryDataStoreDriverImpl.copyAsnc SRC path=%s DST 
canonicalName=%s ", srcTO.getPath(), 
dstData.getDataStore().getClass().getCanonicalName());
                     PrimaryDataStoreTO checkStoragePool = 
dstData.getTO().getDataStore() instanceof PrimaryDataStoreTO ? 
(PrimaryDataStoreTO)dstData.getTO().getDataStore() : null;
                     final String name = 
StorPoolStorageAdaptor.getVolumeNameFromPath(srcTO.getPath(), true);
-                    
StorPoolUtil.spLog("StorpoolPrimaryDataStoreDriverImpl.copyAsnc DST 
tmpSnapName=%s ,srcUUID=%s", name, srcTO.getUuid());
 
                     if (checkStoragePool != null && 
checkStoragePool.getPoolType().equals(StoragePoolType.StorPool)) {
                         SpConnectionDesc conn = 
StorPoolUtil.getSpConnection(dstData.getDataStore().getUuid(), 
dstData.getDataStore().getId(), storagePoolDetailsDao, primaryStoreDao);
                         String baseOn = 
StorPoolStorageAdaptor.getVolumeNameFromPath(srcTO.getPath(), true);
                         //uuid tag will be the same as srcData.uuid
                         String volumeName = srcData.getUuid();
-                        
StorPoolUtil.spLog("StorpoolPrimaryDataStoreDriverImpl.copyAsnc volumeName=%s, 
baseOn=%s", volumeName, baseOn);
-                        final SpApiResponse response = 
StorPoolUtil.volumeCopy(volumeName, baseOn, "volume", srcInfo.getMaxIops(), 
conn);
-                        srcTO.setSize(srcData.getSize());
-                        
srcTO.setPath(StorPoolUtil.devPath(StorPoolUtil.getNameFromResponse(response, 
false)));
-                        
StorPoolUtil.spLog("StorpoolPrimaryDataStoreDriverImpl.copyAsnc DST to=%s", 
srcTO);
 
-                        answer = new CopyCmdAnswer(srcTO);
+                        String vmUuid = null;
+                        String vcPolicyTag = null;
+
+                        VMInstanceVO vm = null;
+                        if (srcInfo.getInstanceId() != null) {
+                            vm = 
vmInstanceDao.findById(srcInfo.getInstanceId());
+                        }
+
+                        if (vm != null) {
+                            vmUuid = vm.getUuid();
+                            vcPolicyTag = getVcPolicyTag(vm.getId());
+                        }
+
+                        if (vm != null && vm.getState().equals(State.Running)) 
{
+                            // migrate volume to another StorPool template
+                            SpApiResponse resp = 
StorPoolUtil.volumeUpadateTemplate(name, conn);

Review Comment:
   Minor one: typo on the method name



##########
plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java:
##########
@@ -709,24 +710,55 @@ public void copyAsync(DataObject srcData, DataObject 
dstData, AsyncCompletionCal
                 } else {
                     // download volume - first copies to secondary
                     VolumeObjectTO srcTO = (VolumeObjectTO)srcData.getTO();
-                    
StorPoolUtil.spLog("StorpoolPrimaryDataStoreDriverImpl.copyAsnc SRC path=%s ", 
srcTO.getPath());
-                    
StorPoolUtil.spLog("StorpoolPrimaryDataStoreDriverImpl.copyAsnc DST 
canonicalName=%s ", dstData.getDataStore().getClass().getCanonicalName());
+                    
StorPoolUtil.spLog("StorpoolPrimaryDataStoreDriverImpl.copyAsnc SRC path=%s DST 
canonicalName=%s ", srcTO.getPath(), 
dstData.getDataStore().getClass().getCanonicalName());
                     PrimaryDataStoreTO checkStoragePool = 
dstData.getTO().getDataStore() instanceof PrimaryDataStoreTO ? 
(PrimaryDataStoreTO)dstData.getTO().getDataStore() : null;
                     final String name = 
StorPoolStorageAdaptor.getVolumeNameFromPath(srcTO.getPath(), true);
-                    
StorPoolUtil.spLog("StorpoolPrimaryDataStoreDriverImpl.copyAsnc DST 
tmpSnapName=%s ,srcUUID=%s", name, srcTO.getUuid());
 
                     if (checkStoragePool != null && 
checkStoragePool.getPoolType().equals(StoragePoolType.StorPool)) {
                         SpConnectionDesc conn = 
StorPoolUtil.getSpConnection(dstData.getDataStore().getUuid(), 
dstData.getDataStore().getId(), storagePoolDetailsDao, primaryStoreDao);
                         String baseOn = 
StorPoolStorageAdaptor.getVolumeNameFromPath(srcTO.getPath(), true);
                         //uuid tag will be the same as srcData.uuid
                         String volumeName = srcData.getUuid();
-                        
StorPoolUtil.spLog("StorpoolPrimaryDataStoreDriverImpl.copyAsnc volumeName=%s, 
baseOn=%s", volumeName, baseOn);
-                        final SpApiResponse response = 
StorPoolUtil.volumeCopy(volumeName, baseOn, "volume", srcInfo.getMaxIops(), 
conn);
-                        srcTO.setSize(srcData.getSize());
-                        
srcTO.setPath(StorPoolUtil.devPath(StorPoolUtil.getNameFromResponse(response, 
false)));
-                        
StorPoolUtil.spLog("StorpoolPrimaryDataStoreDriverImpl.copyAsnc DST to=%s", 
srcTO);
 
-                        answer = new CopyCmdAnswer(srcTO);
+                        String vmUuid = null;
+                        String vcPolicyTag = null;
+
+                        VMInstanceVO vm = null;
+                        if (srcInfo.getInstanceId() != null) {
+                            vm = 
vmInstanceDao.findById(srcInfo.getInstanceId());
+                        }
+
+                        if (vm != null) {
+                            vmUuid = vm.getUuid();
+                            vcPolicyTag = getVcPolicyTag(vm.getId());
+                        }
+
+                        if (vm != null && vm.getState().equals(State.Running)) 
{

Review Comment:
   Maybe this logic can be extracted to a new method



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to