CLOUDSTACK-4659: Fix the regression caused by worker VM consolidation for GC purpose

This commit is contained in:
Kelven Yang 2013-09-15 11:39:32 -07:00
parent 5820b071b8
commit 1598571dfc
2 changed files with 12 additions and 21 deletions

View File

@ -654,14 +654,9 @@ public class VmwareStorageProcessor implements StorageProcessor {
}
// 4 MB is the minimum requirement for VM memory in VMware
vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(),
Pair<VirtualMachineMO, String[]> cloneResult = vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(),
VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()));
clonedVm = vmMo.getRunningHost().findVmOnHyperHost(workerVmName);
if(clonedVm == null) {
String msg = "Unable to create dummy VM to export volume. volume path: " + volumePath;
s_logger.error(msg);
throw new Exception(msg);
}
clonedVm = cloneResult.first();
clonedVm.exportVm(secondaryMountPoint + "/" + installPath, templateUniqueName, true, false);
@ -978,17 +973,12 @@ public class VmwareStorageProcessor implements StorageProcessor {
}
// 4 MB is the minimum requirement for VM memory in VMware
String disks[] = vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(),
Pair<VirtualMachineMO, String[]> cloneResult = vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(),
VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()));
clonedVm = vmMo.getRunningHost().findVmOnHyperHost(workerVmName);
if(clonedVm == null) {
String msg = "Unable to create dummy VM to export volume. volume path: " + volumePath;
s_logger.error(msg);
throw new Exception(msg);
}
clonedVm = cloneResult.first();
String disks[] = cloneResult.second();
clonedVm.exportVm(exportPath, exportName, false, false);
return new Pair<String, String[]>(volumeDeviceInfo.second(), disks);
} finally {
if(clonedVm != null) {

View File

@ -1545,15 +1545,15 @@ public class VirtualMachineMO extends BaseMO {
}
// return the disk chain (VMDK datastore paths) for cloned snapshot
public String[] cloneFromCurrentSnapshot(String clonedVmName, int cpuSpeedMHz, int memoryMb, String diskDevice,
public Pair<VirtualMachineMO, String[]> cloneFromCurrentSnapshot(String clonedVmName, int cpuSpeedMHz, int memoryMb, String diskDevice,
ManagedObjectReference morDs) throws Exception {
assert(morDs != null);
String[] disks = getCurrentSnapshotDiskChainDatastorePaths(diskDevice);
cloneFromDiskChain(clonedVmName, cpuSpeedMHz, memoryMb, disks, morDs);
return disks;
VirtualMachineMO clonedVm = cloneFromDiskChain(clonedVmName, cpuSpeedMHz, memoryMb, disks, morDs);
return new Pair<VirtualMachineMO, String[]>(clonedVm, disks);
}
public void cloneFromDiskChain(String clonedVmName, int cpuSpeedMHz, int memoryMb,
public VirtualMachineMO cloneFromDiskChain(String clonedVmName, int cpuSpeedMHz, int memoryMb,
String[] disks, ManagedObjectReference morDs) throws Exception {
assert(disks != null);
assert(disks.length >= 1);
@ -1576,6 +1576,7 @@ public class VirtualMachineMO extends BaseMO {
vmConfigSpec.getDeviceChange().add(deviceConfigSpec);
clonedVmMo.configureVm(vmConfigSpec);
bSuccess = true;
return clonedVmMo;
} finally {
if(!bSuccess) {
clonedVmMo.detachAllDisks();