Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3A12110B3F for ; Mon, 3 Feb 2014 07:06:43 +0000 (UTC) Received: (qmail 89806 invoked by uid 500); 3 Feb 2014 07:06:43 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 89579 invoked by uid 500); 3 Feb 2014 07:06:39 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 89572 invoked by uid 99); 3 Feb 2014 07:06:37 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Feb 2014 07:06:37 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id F14958C173E; Mon, 3 Feb 2014 07:06:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: likithas@apache.org To: commits@cloudstack.apache.org Message-Id: <8c5f97d1684d4a1481557c99f69f6a53@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/4.3-forward to 92abb94 Date: Mon, 3 Feb 2014 07:06:36 +0000 (UTC) Updated Branches: refs/heads/4.3-forward b811bc094 -> 92abb9439 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/92abb943 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/92abb943 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/92abb943 Branch: refs/heads/4.3-forward Commit: 92abb9439e7a4f18d79e2a48e72a0ee94d84f477 Parents: b811bc0 Author: Likitha Shetty Authored: Mon Feb 3 11:34:54 2014 +0530 Committer: Likitha Shetty Committed: Mon Feb 3 12:28:29 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/92abb943/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 d9923d2..81be19f 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; @@ -5113,14 +5114,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 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 future = _volService.expungeVolumeAsync(volFactory.getVolume(root.getId())); + try { + future.get(); + } catch (Exception e) { + s_logger.debug("Failed to expunge volume:" + root.getId(), e); + } } }