Skip to content

Commit 81e26ab

Browse files
committed
vTPM: requires UEFI on vmware and do nothing if it is not enabled/disabled
1 parent c74f339 commit 81e26ab

File tree

1 file changed

+10
-6
lines changed
  • plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource

1 file changed

+10
-6
lines changed

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3218,22 +3218,26 @@ protected void configureSpecVideoCardNewVRamSize(VirtualMachineVideoCard videoCa
32183218
* @throws Exception exception
32193219
*/
32203220
protected void configureVirtualTPM(VirtualMachineMO vmMo, VirtualMachineTO vmSpec, VirtualMachineConfigSpec vmConfigSpec, String bootMode) throws Exception {
3221-
String bootType = vmSpec.getDetails().getOrDefault(ApiConstants.BootType.UEFI.toString(), null);
32223221
String virtualTPMEnabled = vmSpec.getDetails().getOrDefault(VmDetailConstants.VIRTUAL_TPM_ENABLED, null);
3223-
if (StringUtils.isNotBlank(bootMode) && !bootMode.equalsIgnoreCase("bios")
3224-
&& "secure".equalsIgnoreCase(bootType)
3225-
&& Boolean.parseBoolean(virtualTPMEnabled)) {
3226-
logger.debug("Adding Virtual TPM device");
3222+
if (Boolean.parseBoolean(virtualTPMEnabled)) {
3223+
if (StringUtils.isBlank(bootMode) || !bootMode.equalsIgnoreCase("uefi")) {
3224+
throw new Exception("VM instance with Virtual TPM must use UEFI boot mode");
3225+
}
32273226
for (VirtualDevice device : vmMo.getAllDeviceList()) {
32283227
if (device instanceof VirtualTPM) {
3228+
logger.debug("Virtual TPM device has already been added, returning");
32293229
return;
32303230
}
32313231
}
3232+
logger.debug("Adding Virtual TPM device");
32323233
addVirtualTPMDevice(vmConfigSpec);
3234+
} else if (virtualTPMEnabled == null) {
3235+
logger.debug("Virtual TPM device is neither enabled nor disabled, skipping");
32333236
} else {
3234-
logger.debug(String.format("Virtual TPM device is not enabled. It is only enabled when boot type is SECURE (actually %s) and vTPM is enabled (actually %s)", bootType, virtualTPMEnabled));
3237+
logger.debug(String.format("Virtual TPM device is disabled. It is enabled when boot mode is UEFI (actually %s) and vTPM is enabled (actually %s)", bootMode, virtualTPMEnabled));
32353238
for (VirtualDevice device : vmMo.getAllDeviceList()) {
32363239
if (device instanceof VirtualTPM) {
3240+
logger.debug("Removing Virtual TPM device as it is disabled");
32373241
removeVirtualTPMDevice(vmConfigSpec, (VirtualTPM) device);
32383242
}
32393243
}

0 commit comments

Comments
 (0)