Skip to content

Commit

Permalink
core: Don’t mark TPM device as special
Browse files Browse the repository at this point in the history
TPM device has its own special handling and thus is not a special
device with general properties.  Let’s honor this also by handling TPM
separately from other hardware items.
  • Loading branch information
mz-pdm authored and smelamud committed Aug 17, 2022
1 parent fa22970 commit e962af9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ public static boolean isSpecialDevice(String device, VmDeviceGeneralType type, b
switch(type) {
case MDEV:
case SOUND:
case TPM:
return true;
case CONSOLE:
return VmDeviceType.CONSOLE.getName().equals(device);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,12 @@ protected void readHardwareSection(XmlNode section) {
break;

case OvfHardware.OTHER:
VmDevice vmDevice = readOtherHardwareItem(item);
readVirtioSerial = readVirtioSerial ||
VmDeviceType.VIRTIOSERIAL.getName().equals(vmDevice.getDevice());
final VmDeviceGeneralType type = VmDeviceGeneralType
.forValue(String.valueOf(selectSingleNode(item, VMD_TYPE, _xmlNS).innerText));
final VmDevice vmDevice = type == VmDeviceGeneralType.TPM
? readManagedVmDevice(item, readDeviceId(item))
: readOtherHardwareItem(item, type);
readVirtioSerial = readVirtioSerial || VmDeviceType.VIRTIOSERIAL.getName().equals(vmDevice.getDevice());
break;
}
}
Expand Down Expand Up @@ -510,12 +513,10 @@ private void readUsbItem(XmlNode node) {
vmBase.setUsbPolicy(usbPolicy != null ? UsbPolicy.forStringValue(usbPolicy.innerText) : UsbPolicy.ENABLED_NATIVE);
}

private VmDevice readOtherHardwareItem(XmlNode node) {
private VmDevice readOtherHardwareItem(XmlNode node, VmDeviceGeneralType type) {
boolean managed = false;
if (selectSingleNode(node, VMD_TYPE, _xmlNS) != null
&& StringUtils.isNotEmpty(selectSingleNode(node, VMD_TYPE, _xmlNS).innerText)) {
VmDeviceGeneralType type = VmDeviceGeneralType
.forValue(String.valueOf(selectSingleNode(node, VMD_TYPE, _xmlNS).innerText));
String device = selectSingleNode(node, VMD_DEVICE, _xmlNS).innerText;
// special devices are treated as managed devices but still have the OTHER OVF ResourceType
managed = VmDeviceCommonUtils.isSpecialDevice(device, type, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,6 @@ private void writeOtherDevices() {
// mdev_type predefined property is written instead
continue;
}
if (device.getType() == VmDeviceGeneralType.TPM) {
// TPM device has its own write method
continue;
}
devices.add(device);
}
}
Expand Down

0 comments on commit e962af9

Please sign in to comment.