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 09D3D1009C for ; Fri, 2 Jan 2015 14:36:02 +0000 (UTC) Received: (qmail 55266 invoked by uid 500); 2 Jan 2015 14:35:54 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 55215 invoked by uid 500); 2 Jan 2015 14:35:54 -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 55126 invoked by uid 99); 2 Jan 2015 14:35:54 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Jan 2015 14:35:54 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 40CEEA3C685; Fri, 2 Jan 2015 14:35:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: widodh@apache.org To: commits@cloudstack.apache.org Date: Fri, 02 Jan 2015 14:36:19 -0000 Message-Id: In-Reply-To: <5c56ac3fb2b34819ac40b6562dbc4d9c@git.apache.org> References: <5c56ac3fb2b34819ac40b6562dbc4d9c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [27/50] [abbrv] git commit: updated refs/heads/reporter to b26f3fc CLOUDSTACK-8113. VM migration fails with "Message: No such disk device: " error. Consolidate VM disks once VM/volumes are migrated. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/cb211f18 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/cb211f18 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/cb211f18 Branch: refs/heads/reporter Commit: cb211f18d14dcc9d988254a4b50b55ca0b080ed5 Parents: 77bd069 Author: Likitha Shetty Authored: Tue Dec 23 14:20:34 2014 +0530 Committer: Likitha Shetty Committed: Tue Dec 23 14:28:17 2014 +0530 ---------------------------------------------------------------------- .../vmware/resource/VmwareResource.java | 24 ++++++++++++++++++++ .../hypervisor/vmware/mo/VirtualMachineMO.java | 12 ++++++++++ 2 files changed, 36 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cb211f18/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index c2cf9e9..5a16f03 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -3054,6 +3054,18 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa s_logger.debug("Successfully migrated storage of VM " + vmName + " to target datastore(s)"); } + // Consolidate VM disks. + // In case of a linked clone VM, if VM's disks are not consolidated, + // further VM operations such as volume snapshot, VM snapshot etc. will result in DB inconsistencies. + String apiVersion = HypervisorHostHelper.getVcenterApiVersion(vmMo.getContext()); + if (apiVersion.compareTo("5.0") >= 0) { + if (!vmMo.consolidateVmDisks()) { + s_logger.warn("VM disk consolidation failed after storage migration. Yet proceeding with VM migration."); + } else { + s_logger.debug("Successfully consolidated disks of VM " + vmName + "."); + } + } + // Update and return volume path for every disk because that could have changed after migration for (Entry entry : volToFiler.entrySet()) { volume = entry.getKey(); @@ -3163,6 +3175,18 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa s_logger.debug("Successfully migrated volume " + volumePath + " to target datastore " + tgtDsName); } + // Consolidate VM disks. + // In case of a linked clone VM, if VM's disks are not consolidated, + // further volume operations on the ROOT volume such as volume snapshot etc. will result in DB inconsistencies. + String apiVersion = HypervisorHostHelper.getVcenterApiVersion(vmMo.getContext()); + if (apiVersion.compareTo("5.0") >= 0) { + if (!vmMo.consolidateVmDisks()) { + s_logger.warn("VM disk consolidation failed after storage migration."); + } else { + s_logger.debug("Successfully consolidated disks of VM " + vmName + "."); + } + } + // Update and return volume path because that could have changed after migration if (!targetDsMo.fileExists(fullVolumePath)) { VirtualDisk[] disks = vmMo.getAllDiskDevice(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cb211f18/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java index c2e9d7f..471b4a8 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java @@ -2638,4 +2638,16 @@ public class VirtualMachineMO extends BaseMO { } return guestOsSupportsMemoryHotAdd && virtualHardwareSupportsMemoryHotAdd; } + + public boolean consolidateVmDisks() throws Exception { + ManagedObjectReference morTask = _context.getService().consolidateVMDisksTask(_mor); + boolean result = _context.getVimClient().waitForTask(morTask); + if (result) { + _context.waitForTaskProgressDone(morTask); + return true; + } else { + s_logger.error("VMware ConsolidateVMDisks_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask)); + } + return false; + } }