cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [27/50] [abbrv] git commit: updated refs/heads/reporter to b26f3fc
Date Fri, 02 Jan 2015 14:36:19 GMT
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 <likitha.shetty@citrix.com>
Authored: Tue Dec 23 14:20:34 2014 +0530
Committer: Likitha Shetty <likitha.shetty@citrix.com>
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<VolumeTO, StorageFilerTO> 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;
+    }
 }


Mime
View raw message