mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-4659: Fix the regression caused by worker VM consolidation for GC purpose
This commit is contained in:
parent
5820b071b8
commit
1598571dfc
@ -654,15 +654,10 @@ 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);
|
||||
|
||||
long physicalSize = new File(installFullPath + "/" + templateUniqueName + ".ova").length();
|
||||
@ -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(),
|
||||
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);
|
||||
}
|
||||
Pair<VirtualMachineMO, String[]> cloneResult = vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(),
|
||||
VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()));
|
||||
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) {
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user