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,14 +654,9 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4 MB is the minimum requirement for VM memory in VMware
|
// 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()));
|
VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()));
|
||||||
clonedVm = vmMo.getRunningHost().findVmOnHyperHost(workerVmName);
|
clonedVm = cloneResult.first();
|
||||||
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.exportVm(secondaryMountPoint + "/" + installPath, templateUniqueName, true, false);
|
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
|
// 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()));
|
VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()));
|
||||||
clonedVm = vmMo.getRunningHost().findVmOnHyperHost(workerVmName);
|
clonedVm = cloneResult.first();
|
||||||
if(clonedVm == null) {
|
String disks[] = cloneResult.second();
|
||||||
String msg = "Unable to create dummy VM to export volume. volume path: " + volumePath;
|
|
||||||
s_logger.error(msg);
|
|
||||||
throw new Exception(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
clonedVm.exportVm(exportPath, exportName, false, false);
|
clonedVm.exportVm(exportPath, exportName, false, false);
|
||||||
|
|
||||||
return new Pair<String, String[]>(volumeDeviceInfo.second(), disks);
|
return new Pair<String, String[]>(volumeDeviceInfo.second(), disks);
|
||||||
} finally {
|
} finally {
|
||||||
if(clonedVm != null) {
|
if(clonedVm != null) {
|
||||||
|
|||||||
@ -1545,15 +1545,15 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// return the disk chain (VMDK datastore paths) for cloned snapshot
|
// 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 {
|
ManagedObjectReference morDs) throws Exception {
|
||||||
assert(morDs != null);
|
assert(morDs != null);
|
||||||
String[] disks = getCurrentSnapshotDiskChainDatastorePaths(diskDevice);
|
String[] disks = getCurrentSnapshotDiskChainDatastorePaths(diskDevice);
|
||||||
cloneFromDiskChain(clonedVmName, cpuSpeedMHz, memoryMb, disks, morDs);
|
VirtualMachineMO clonedVm = cloneFromDiskChain(clonedVmName, cpuSpeedMHz, memoryMb, disks, morDs);
|
||||||
return disks;
|
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 {
|
String[] disks, ManagedObjectReference morDs) throws Exception {
|
||||||
assert(disks != null);
|
assert(disks != null);
|
||||||
assert(disks.length >= 1);
|
assert(disks.length >= 1);
|
||||||
@ -1576,6 +1576,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
vmConfigSpec.getDeviceChange().add(deviceConfigSpec);
|
vmConfigSpec.getDeviceChange().add(deviceConfigSpec);
|
||||||
clonedVmMo.configureVm(vmConfigSpec);
|
clonedVmMo.configureVm(vmConfigSpec);
|
||||||
bSuccess = true;
|
bSuccess = true;
|
||||||
|
return clonedVmMo;
|
||||||
} finally {
|
} finally {
|
||||||
if(!bSuccess) {
|
if(!bSuccess) {
|
||||||
clonedVmMo.detachAllDisks();
|
clonedVmMo.detachAllDisks();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user