From: Michal Privoznik Date: Mon, 18 Jul 2022 07:10:12 +0000 (+0200) Subject: qemu_domain: Move TPM post parse code into qemuDomainTPMDefPostParse() X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=2b3e8ddd9d46cbfecbb537bb183ddbcc66713079;p=libvirt.git qemu_domain: Move TPM post parse code into qemuDomainTPMDefPostParse() In the qemuDomainDefPostParse() we aim to fill in top level values, which require overall view of domain, or those parts of configuration that are not a device in domain XML (e.g. vCPUs). However, inside of qemuDomainDefTPMsPostParse(), which is called from aforementioned function, we do two tings: 1) fill in missing info (TPM version), and 2) validate TPM definition. Now, if 1) is moved into qemuDomainTPMDefPostParse() (the device post parse callback), then 2) can be moved into validation step. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8d96d7b084..873b8b309c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4593,17 +4593,6 @@ qemuDomainDefTPMsPostParse(virDomainDef *def) for (i = 0; i < def->ntpms; i++) { virDomainTPMDef *tpm = def->tpms[i]; - /* TPM 1.2 and 2 are not compatible, so we choose a specific version here */ - if (tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR && - tpm->data.emulator.version == VIR_DOMAIN_TPM_VERSION_DEFAULT) { - if (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR || - tpm->model == VIR_DOMAIN_TPM_MODEL_CRB || - qemuDomainIsARMVirt(def)) - tpm->data.emulator.version = VIR_DOMAIN_TPM_VERSION_2_0; - else - tpm->data.emulator.version = VIR_DOMAIN_TPM_VERSION_1_2; - } - if (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY) { if (proxyTPM) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -5807,15 +5796,26 @@ qemuDomainHostdevDefPostParse(virDomainHostdevDef *hostdev, static int qemuDomainTPMDefPostParse(virDomainTPMDef *tpm, - virArch arch) + const virDomainDef *def) { if (tpm->model == VIR_DOMAIN_TPM_MODEL_DEFAULT) { - if (ARCH_IS_PPC64(arch)) + if (ARCH_IS_PPC64(def->os.arch)) tpm->model = VIR_DOMAIN_TPM_MODEL_SPAPR; else tpm->model = VIR_DOMAIN_TPM_MODEL_TIS; } + /* TPM 1.2 and 2 are not compatible, so we choose a specific version here */ + if (tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR && + tpm->data.emulator.version == VIR_DOMAIN_TPM_VERSION_DEFAULT) { + if (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR || + tpm->model == VIR_DOMAIN_TPM_MODEL_CRB || + qemuDomainIsARMVirt(def)) + tpm->data.emulator.version = VIR_DOMAIN_TPM_VERSION_2_0; + else + tpm->data.emulator.version = VIR_DOMAIN_TPM_VERSION_1_2; + } + return 0; } @@ -5942,7 +5942,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDef *dev, break; case VIR_DOMAIN_DEVICE_TPM: - ret = qemuDomainTPMDefPostParse(dev->data.tpm, def->os.arch); + ret = qemuDomainTPMDefPostParse(dev->data.tpm, def); break; case VIR_DOMAIN_DEVICE_MEMORY: