cloudstack-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CLOUDSTACK-7982) Storage live migration support for KVM
Date Fri, 08 Dec 2017 10:05:00 GMT

    [ https://issues.apache.org/jira/browse/CLOUDSTACK-7982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16283295#comment-16283295
] 

ASF GitHub Bot commented on CLOUDSTACK-7982:
--------------------------------------------

DaanHoogland commented on a change in pull request #1709: CLOUDSTACK-7982: KVM live migration
with local storage
URL: https://github.com/apache/cloudstack/pull/1709#discussion_r155565727
 
 

 ##########
 File path: plugins/hypervisors/kvm/src/org/apache/cloudstack/storage/motion/KVMStorageMotionStrategy.java
 ##########
 @@ -0,0 +1,282 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.storage.motion;
+
+
+import com.cloud.agent.AgentManager;
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.CancelMigrationAnswer;
+import com.cloud.agent.api.CancelMigrationCommand;
+import com.cloud.agent.api.MigrateWithStorageAnswer;
+import com.cloud.agent.api.MigrateWithStorageCommand;
+import com.cloud.agent.api.storage.CreateAnswer;
+import com.cloud.agent.api.storage.CreateCommand;
+import com.cloud.agent.api.to.DataObjectType;
+import com.cloud.agent.api.to.StorageFilerTO;
+import com.cloud.agent.api.to.VirtualMachineTO;
+import com.cloud.agent.api.to.VolumeTO;
+import com.cloud.exception.AgentUnavailableException;
+import com.cloud.exception.OperationTimedoutException;
+import com.cloud.host.Host;
+import com.cloud.hypervisor.Hypervisor;
+import com.cloud.storage.DataStoreRole;
+import com.cloud.storage.DiskOfferingVO;
+import com.cloud.storage.StorageManager;
+import com.cloud.storage.StoragePool;
+import com.cloud.storage.Volume;
+import com.cloud.storage.VolumeVO;
+import com.cloud.storage.dao.DiskOfferingDao;
+import com.cloud.storage.dao.VolumeDao;
+import com.cloud.utils.Pair;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.vm.DiskProfile;
+import com.cloud.vm.VMInstanceVO;
+import com.cloud.vm.dao.VMInstanceDao;
+import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionStrategy;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
+import org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.framework.config.ConfigKey;
+import org.apache.cloudstack.storage.command.DeleteCommand;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.to.VolumeObjectTO;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class KVMStorageMotionStrategy  implements DataMotionStrategy {
+    private static final Logger s_logger = Logger.getLogger(KVMStorageMotionStrategy.class);
+
+    protected final ConfigKey<Integer> MigrateWait = new ConfigKey<Integer>(Integer.class,
"migratewait", "Advanced", "3600", "Time (in seconds) to wait for VM migrate finish.", true,
ConfigKey.Scope.Global, null);
+
+    @Inject
+    AgentManager agentMgr;
+    @Inject
+    VolumeDao volDao;
+    @Inject
+    VolumeDataFactory volFactory;
+    @Inject
+    PrimaryDataStoreDao storagePoolDao;
+    @Inject
+    VMInstanceDao instanceDao;
+    @Inject
+    DiskOfferingDao diskOfferingDao;
+    @Inject
+    TemplateDataFactory tmplFactory;
+    @Inject
+    StorageManager storageManager;
+    @Inject
+    EndPointSelector endPointSelector;
+    @Inject
+    DataStoreManager dataStoreManager;
+
+    @Override
+    public StrategyPriority canHandle(DataObject srcData, DataObject destData) {
+        return StrategyPriority.CANT_HANDLE;
+    }
+
+    @Override
+    public StrategyPriority canHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost,
Host destHost) {
+        if (srcHost.getHypervisorType() == Hypervisor.HypervisorType.KVM && destHost.getHypervisorType()
== Hypervisor.HypervisorType.KVM) {
+            return StrategyPriority.HYPERVISOR;
+        }
+        return StrategyPriority.CANT_HANDLE;
+    }
+
+    @Override
+    public void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult>
callback) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo,
Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
+        Answer answer = null;
+        String errMsg = null;
+        try {
+            VMInstanceVO instance = instanceDao.findById(vmTo.getId());
+            if (instance != null) {
+                answer = migrateVmWithVolumes(instance, vmTo, srcHost, destHost, volumeMap);
+                errMsg = answer.getDetails();
+
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("Got answer from migration, result: " + (answer.getResult()
? "ok" : "failed, reason: " + (answer.getDetails() == null ? "<null>" : answer.getDetails())));
+                }
+
+            } else {
+                throw new CloudRuntimeException("Unsupported operation requested for moving
data.");
+            }
+        } catch (Exception e) {
+            s_logger.error("copyAsync failed", e);
+            errMsg = e.getMessage();
+        }
+
+        CopyCommandResult result = new CopyCommandResult("", answer);
+
+        if (answer != null) {
+            result.setSuccess(answer.getResult());
+            if (!answer.getResult()) {
+                result.setResult(errMsg);
+            }
+        } else {
+            result.setSuccess(false);
+            result.setResult(errMsg);
+        }
+
+        callback.complete(result);
+    }
+
+    private Answer migrateVmWithVolumes(VMInstanceVO vm, VirtualMachineTO to, Host srcHost,
Host destHost, Map<VolumeInfo, DataStore> volumeToPool) throws AgentUnavailableException
{
+
+        // Initiate migration of a virtual machine with it's volumes.
+        List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerTo = new ArrayList<Pair<VolumeTO,
StorageFilerTO>>();
+        VolumeVO rootVolume = null;
+        VolumeInfo rootVolumeInfo = null;
+        for (Map.Entry<VolumeInfo, DataStore> entry : volumeToPool.entrySet()) {
+            VolumeInfo volume = entry.getKey();
+            VolumeTO volumeTo = new VolumeTO(volume, storagePoolDao.findById(volume.getPoolId()));
+            StorageFilerTO filerTo = new StorageFilerTO((StoragePool)entry.getValue());
+            volumeToFilerTo.add(new Pair<VolumeTO, StorageFilerTO>(volumeTo, filerTo));
+            if (volume.getType().equals(DataObjectType.VOLUME) && volume.getVolumeType().equals(Volume.Type.ROOT))
{
+                rootVolume = volDao.findById(volume.getId());
+                rootVolumeInfo = volume;
+            }
+        }
+
+        DiskOfferingVO diskOffering = diskOfferingDao.findById(rootVolume.getDiskOfferingId());
+        DiskProfile diskProfile = new DiskProfile(rootVolume, diskOffering, vm.getHypervisorType());
+        StoragePool destStoragePool = storageManager.findLocalStorageOnHost(destHost.getId());
 
 Review comment:
   same as in the VolumeOrchestrator this is assuming LVM based localstorage. we should be
defensive against that assumption,

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Storage live migration support for KVM
> --------------------------------------
>
>                 Key: CLOUDSTACK-7982
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-7982
>             Project: CloudStack
>          Issue Type: Improvement
>      Security Level: Public(Anyone can view this level - this is the default.) 
>            Reporter: Wei Zhou
>            Assignee: Marc-Aurèle Brothier
>             Fix For: Future
>
>
> Currently it supports Xenserver, Vmware, Hyper-V, but not KVM.
> We need to add the implementation for KVM.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message