You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by an...@apache.org on 2014/03/05 08:52:52 UTC
[07/20] git commit: updated refs/heads/4.3 to 3297fcc
CLOUDSTACK-6146. [VMware] [ESXi 5.5] Live storage migration of an already migrated volume fails
In vCenter 5.5, once a volume is migrated the VMDKs are renamed to match the name of the VM.
If a volume has been renamed upon migration update its volumePath to that of the new disk filename.
(cherry picked from commit c652ff45dffaafa1cb0de29103e90fe936382028)
Signed-off-by: Animesh Chaturvedi <an...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e63af74f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e63af74f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e63af74f
Branch: refs/heads/4.3
Commit: e63af74f8ef76be4b30fdd6fd74fdd4e023fc622
Parents: 5b2cdf4
Author: Likitha Shetty <li...@citrix.com>
Authored: Mon Feb 24 10:12:58 2014 +0530
Committer: Animesh Chaturvedi <an...@apache.org>
Committed: Tue Mar 4 23:39:18 2014 -0800
----------------------------------------------------------------------
.../vmware/resource/VmwareResource.java | 17 +++++++++++++----
.../hypervisor/vmware/mo/VirtualMachineMO.java | 18 ++++++++++++------
2 files changed, 25 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e63af74f/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 d1fea92..d27d81f 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
@@ -4517,12 +4517,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
throw new Exception(msg);
}
- VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(
- new DatastoreMO(srcHyperHost.getContext(), morDs), vmName,
- volumePath + ".vmdk");
+ DatastoreMO targetDsMo = new DatastoreMO(srcHyperHost.getContext(), morDs);
+ String fullVolumePath = VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(targetDsMo, vmName, volumePath + ".vmdk");
+ int diskId = getVirtualDiskInfo(vmMo, volumePath + ".vmdk");
diskLocator = new VirtualMachineRelocateSpecDiskLocator();
diskLocator.setDatastore(morDs);
- diskLocator.setDiskId(getVirtualDiskInfo(vmMo, volumePath + ".vmdk"));
+ diskLocator.setDiskId(diskId);
diskLocators.add(diskLocator);
relocateSpec.getDisk().add(diskLocator);
@@ -4534,6 +4534,15 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
s_logger.debug("Successfully migrated volume " + volumePath + " to target datastore " + tgtDsName);
}
+ // Update and return volume path because that could have changed after migration
+ if (!targetDsMo.fileExists(fullVolumePath)) {
+ VirtualDisk[] disks = vmMo.getAllDiskDevice();
+ for (VirtualDisk disk : disks)
+ if (disk.getKey() == diskId) {
+ volumePath = vmMo.getVmdkFileBaseName(disk);
+ }
+ }
+
return new MigrateVolumeAnswer(cmd, true, null, volumePath);
} catch (Exception e) {
String msg = "Catch Exception " + e.getClass().getName() + " due to " + e.toString();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e63af74f/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 e4e2712..69a7e50 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -1783,17 +1783,23 @@ public class VirtualMachineMO extends BaseMO {
VirtualDevice[] devices = getAllDiskDevice();
for(VirtualDevice device : devices) {
if(device instanceof VirtualDisk) {
- VirtualDeviceBackingInfo backingInfo = ((VirtualDisk)device).getBacking();
- if(backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
- VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
- DatastoreFile dsBackingFile = new DatastoreFile(diskBackingInfo.getFileName());
- vmdkFileBaseNames.add(dsBackingFile.getFileBaseName());
- }
+ vmdkFileBaseNames.add(getVmdkFileBaseName((VirtualDisk)device));
}
}
return vmdkFileBaseNames;
}
+ public String getVmdkFileBaseName(VirtualDisk disk) throws Exception {
+ String vmdkFileBaseName = null;
+ VirtualDeviceBackingInfo backingInfo = disk.getBacking();
+ if(backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
+ VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
+ DatastoreFile dsBackingFile = new DatastoreFile(diskBackingInfo.getFileName());
+ vmdkFileBaseName = dsBackingFile.getFileBaseName();
+ }
+ return vmdkFileBaseName;
+ }
+
// this method relies on un-offical VMware API
@Deprecated
public void moveAllVmDiskFiles(DatastoreMO destDsMo, String destDsDir, boolean followDiskChain) throws Exception {