Skip to content

Commit 85979fc

Browse files
nvazquezyadvr
authored andcommitted
vmware: Fix worker VMs hardware version small bug
1 parent 5895435 commit 85979fc

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@ private Ternary<String, Long, Long> createTemplateFromVolume(VirtualMachineMO vm
647647
}
648648

649649
// 4 MB is the minimum requirement for VM memory in VMware
650-
vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(), VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()), null);
650+
String hardwareVersion = vmMo.getVmxFormattedVirtualHardwareVersion();
651+
vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(), VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()), hardwareVersion);
651652
clonedVm = vmMo.getRunningHost().findVmOnHyperHost(workerVmName);
652653
if (clonedVm == null) {
653654
String msg = "Unable to create dummy VM to export volume. volume path: " + volumePath;
@@ -965,7 +966,8 @@ private void exportVolumeToSecondaryStorage(VirtualMachineMO vmMo, String volume
965966

966967
if (clonedWorkerVMNeeded) {
967968
// 4 MB is the minimum requirement for VM memory in VMware
968-
vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(), VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()), null);
969+
String hardwareVersion = vmMo.getVmxFormattedVirtualHardwareVersion();
970+
vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(), VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()), hardwareVersion);
969971
clonedVm = vmMo.getRunningHost().findVmOnHyperHost(workerVmName);
970972
if (clonedVm == null) {
971973
String msg = "Unable to create dummy VM to export volume. volume path: " + volumePath;

vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,8 +1651,8 @@ public static VirtualMachineMO createWorkerVM(VmwareHypervisorHost hyperHost, Da
16511651
VirtualMachineMO workingVM = null;
16521652
VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec();
16531653
vmConfig.setName(vmName);
1654-
if (hardwareVersion != null){
1655-
vmConfig.setVersion(("vmx-" + hardwareVersion));
1654+
if (StringUtils.isNotBlank(hardwareVersion)){
1655+
vmConfig.setVersion(hardwareVersion);
16561656
} else {
16571657
ClusterMO clusterMo = new ClusterMO(hyperHost.getContext(), hyperHost.getHyperHostCluster());
16581658
DatacenterMO dataCenterMo = new DatacenterMO(hyperHost.getContext(), hyperHost.getHyperHostDatacenter());

vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3292,6 +3292,21 @@ public int getVirtualHardwareVersion() throws Exception {
32923292
return vhOption.getHwVersion();
32933293
}
32943294

3295+
/**
3296+
* Return a hardware version string in the format expected by Vmware
3297+
* Format: "vmx-DD" where DD represents the hardware version number
3298+
*/
3299+
public String getVmxFormattedVirtualHardwareVersion() throws Exception {
3300+
StringBuilder builder = new StringBuilder();
3301+
builder.append("vmx-");
3302+
int hwVersion = getVirtualHardwareVersion();
3303+
if (hwVersion < 10) {
3304+
builder.append("0");
3305+
}
3306+
builder.append(String.valueOf(hwVersion));
3307+
return builder.toString();
3308+
}
3309+
32953310
public VirtualHardwareOption getVirtualHardwareOption() throws Exception {
32963311
VirtualMachineConfigOption vmConfigOption = _context.getService().queryConfigOption(getEnvironmentBrowser(), null, null);
32973312
return vmConfigOption.getHardwareOptions();

0 commit comments

Comments
 (0)