Introduce VIR_DOMAIN_TPM_MODEL_DEFAULT as a default model which we use in case the user does not provide a model in the device XML. It has the TIS's previous value of '0'. In the post parsing function we change this default value to 'TIS' to have the same model as before.
Signed-off-by: Stefan Berger <stef...@linux.ibm.com> Reviewed-by: Ján Tomko <jto...@redhat.com> --- src/conf/domain_conf.c | 1 + src/conf/domain_conf.h | 1 + src/qemu/qemu_domain.c | 14 +++++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c7cc830c1d..040643e78f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1125,6 +1125,7 @@ VIR_ENUM_IMPL(virDomainRNGBackend, VIR_ENUM_IMPL(virDomainTPMModel, VIR_DOMAIN_TPM_MODEL_LAST, + "default", "tpm-tis", "tpm-crb", ); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2bd80c2fbf..cb4a0cedf0 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1252,6 +1252,7 @@ struct _virDomainHubDef { }; typedef enum { + VIR_DOMAIN_TPM_MODEL_DEFAULT, VIR_DOMAIN_TPM_MODEL_TIS, VIR_DOMAIN_TPM_MODEL_CRB, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6ebee4d5f4..e152448cc6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9035,6 +9035,15 @@ qemuDomainHostdevDefPostParse(virDomainHostdevDefPtr hostdev, } +static int +qemuDomainTPMDefPostParse(virDomainTPMDefPtr tpm) +{ + if (tpm->model == VIR_DOMAIN_TPM_MODEL_DEFAULT) + tpm->model = VIR_DOMAIN_TPM_MODEL_TIS; + return 0; +} + + static int qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, const virDomainDef *def, @@ -9088,6 +9097,10 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, ret = qemuDomainHostdevDefPostParse(dev->data.hostdev, qemuCaps); break; + case VIR_DOMAIN_DEVICE_TPM: + ret = qemuDomainTPMDefPostParse(dev->data.tpm); + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: @@ -9100,7 +9113,6 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: case VIR_DOMAIN_DEVICE_RNG: - case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_MEMORY: case VIR_DOMAIN_DEVICE_IOMMU: ret = 0; -- 2.17.1