You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2015/02/02 11:17:05 UTC
[07/20] git commit: updated refs/heads/4.5 to 64e938b
CLOUDSTACK-8113. VM migration fails with "Message: No such disk device: " error.
Consolidate VM disks once VM/volumes are migrated.
(cherry picked from commit cb211f18d14dcc9d988254a4b50b55ca0b080ed5)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ad92b850
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ad92b850
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ad92b850
Branch: refs/heads/4.5
Commit: ad92b8507697e27ae9fd2c602cdeca61862eef7d
Parents: 45d3223
Author: Likitha Shetty <li...@citrix.com>
Authored: Tue Dec 23 14:20:34 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Mon Feb 2 13:51:29 2015 +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/ad92b850/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 9ad3a5f..e98b829 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -3057,6 +3057,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<VolumeTO, StorageFilerTO> entry : volToFiler.entrySet()) {
volume = entry.getKey();
@@ -3166,6 +3178,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/ad92b850/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;
+ }
}