On 11/23/21 19:04, Daniel P. Berrangé wrote: > This reports what TPM features QEMU supports, provided that swtpm is > installed in the host. > > Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> > --- > 71 files changed, 104 insertions(+) > > diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c > index a4c492dde2..374909bef2 100644 > --- a/src/qemu/qemu_capabilities.c > +++ b/src/qemu/qemu_capabilities.c > @@ -49,6 +49,7 @@ > #include "qemu_process.h" > #include "qemu_firmware.h" > #include "virutil.h" > +#include "virtpm.h" > > #include <fcntl.h> > #include <sys/stat.h> > @@ -6206,6 +6207,35 @@ virQEMUCapsFillDomainDeviceFSCaps(virQEMUCaps *qemuCaps, > } > > > +void > +virQEMUCapsFillDomainDeviceTPMCaps(virQEMUCaps *qemuCaps, > + virDomainCapsDeviceTPM *tpm) > +{ > + if (virTPMEmulatorInit() < 0) { > + virResetLastError(); > + tpm->supported = VIR_TRISTATE_BOOL_NO; > + } else { Nitpick. Put 'return' in the branch above and drop 'else'. One level of indendation can be saved this way. > + tpm->supported = VIR_TRISTATE_BOOL_YES; > + tpm->model.report = true; > + tpm->backendModel.report = true; > + > + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_TIS)) > + VIR_DOMAIN_CAPS_ENUM_SET(tpm->model, VIR_DOMAIN_TPM_MODEL_TIS); > + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_CRB)) > + VIR_DOMAIN_CAPS_ENUM_SET(tpm->model, VIR_DOMAIN_TPM_MODEL_CRB); > + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_SPAPR)) > + VIR_DOMAIN_CAPS_ENUM_SET(tpm->model, VIR_DOMAIN_TPM_MODEL_SPAPR); > + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPAPR_TPM_PROXY)) > + VIR_DOMAIN_CAPS_ENUM_SET(tpm->model, VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY); > + > + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_PASSTHROUGH)) > + VIR_DOMAIN_CAPS_ENUM_SET(tpm->backendModel, VIR_DOMAIN_TPM_TYPE_PASSTHROUGH); > + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_EMULATOR)) > + VIR_DOMAIN_CAPS_ENUM_SET(tpm->backendModel, VIR_DOMAIN_TPM_TYPE_EMULATOR); > + } > +} Michal