You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by li...@apache.org on 2014/02/03 08:10:06 UTC
git commit: updated refs/heads/master to 9cb37ec
Updated Branches:
refs/heads/master 9cb2458a5 -> 9cb37ec34
CLOUDSTACK-6007. Restore VM command fails with NPE.
If a VM instance is deployed with startVm=false, then calling restoreVm on the instance fails with NPE
because CS tries to expunge a volume that has not been created in primary store.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9cb37ec3
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9cb37ec3
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9cb37ec3
Branch: refs/heads/master
Commit: 9cb37ec349a6740a2f012ef4e6ac58a6c3b13907
Parents: 9cb2458
Author: Likitha Shetty <li...@citrix.com>
Authored: Mon Feb 3 11:34:54 2014 +0530
Committer: Likitha Shetty <li...@citrix.com>
Committed: Mon Feb 3 12:32:14 2014 +0530
----------------------------------------------------------------------
server/src/com/cloud/vm/UserVmManagerImpl.java | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cb37ec3/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 7efea69..82b9bfb 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -71,6 +71,7 @@ import org.apache.cloudstack.engine.service.api.OrchestrationService;
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.engine.subsystem.api.storage.VolumeService;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
import org.apache.cloudstack.framework.async.AsyncCallFuture;
@@ -4737,14 +4738,17 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
_volsDao.detachVolume(root.getId());
volumeMgr.destroyVolume(root);
- // For VMware hypervisor since the old root volume is replaced by the new root volume in storage, force expunge old root volume
+ // For VMware hypervisor since the old root volume is replaced by the new root volume, force expunge old root volume if it has been created in storage
if (vm.getHypervisorType() == HypervisorType.VMware) {
- s_logger.info("Expunging volume " + root.getId() + " from primary data store");
- AsyncCallFuture<VolumeApiResult> future = _volService.expungeVolumeAsync(volFactory.getVolume(root.getId()));
- try {
- future.get();
- } catch (Exception e) {
- s_logger.debug("Failed to expunge volume:" + root.getId(), e);
+ VolumeInfo volumeInStorage = volFactory.getVolume(root.getId());
+ if (volumeInStorage != null) {
+ s_logger.info("Expunging volume " + root.getId() + " from primary data store");
+ AsyncCallFuture<VolumeApiResult> future = _volService.expungeVolumeAsync(volFactory.getVolume(root.getId()));
+ try {
+ future.get();
+ } catch (Exception e) {
+ s_logger.debug("Failed to expunge volume:" + root.getId(), e);
+ }
}
}