From nobody Sun Feb 8 07:15:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1658136664; cv=none; d=zohomail.com; s=zohoarc; b=adkz50m+PDwUlxlFkIWSuIvhOh9SsdHMIWGFuUk63FvFpMwarvEPduRoyKoimepG1EJmRiHP8lI148yIZasoUk0NRNjARmuMWgUoK0fSPucFhExxqrAEdluJAJ1PNwnl5ZQLRbu1qeO/okHdm9Kum5pT8kRVX30BQHUEsE/eK3I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658136664; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l6NFFll1080zIZn4/O85SiEDuxuvn1RfLH6k603bJM8=; b=U44olgfs5EDw6P6KQb2K2fEjtnoJIc4nJxwOP0/sa1Fwk72b1fYNfVfla0Bk0fV/UVHHzowX7wiLDsu4YfJwENfqAXQUT6v5OqTNkGi7+nMCpiAFM9bSoQ87NZze4ZcxmZGZUHDj8k6WChP5Feg2gODhxl6/t52XhX732tyfrbg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1658136664698637.1726376340443; Mon, 18 Jul 2022 02:31:04 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-642-C7DBV_jzNHukSMUO02EK6g-1; Mon, 18 Jul 2022 05:30:58 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 550071C06EC5; Mon, 18 Jul 2022 09:30:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43063141511F; Mon, 18 Jul 2022 09:30:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2D42C1947056; Mon, 18 Jul 2022 09:30:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D6F3E194705C for ; Mon, 18 Jul 2022 09:30:55 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CB4262166B29; Mon, 18 Jul 2022 09:30:55 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 770EB2166B26 for ; Mon, 18 Jul 2022 09:30:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658136663; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=l6NFFll1080zIZn4/O85SiEDuxuvn1RfLH6k603bJM8=; b=ac5p8LS8Kr87Tpn6dlNU4fpO6aSYQTqtNI1fwxJgKJM4pWE5CCjTI5CZEqoV1cre8ZWCZk bSO7OX8wlcg/+jYpTnj9HqBFv5sFxAM4/kVvXpV8pPE9je6jat45NcrGE6bSDWJLoLXBb5 yQrDq2FneD3zp5HvxthrgP+oytdY/Ug= X-MC-Unique: C7DBV_jzNHukSMUO02EK6g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 6/8] qemu_domain: Move TPM post parse code into qemuDomainTPMDefPostParse() Date: Mon, 18 Jul 2022 11:30:48 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1658136666097100001 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 --- src/qemu/qemu_domain.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 09fc88e7fa..bcee4d2602 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4593,17 +4593,6 @@ qemuDomainDefTPMsPostParse(virDomainDef *def) for (i =3D 0; i < def->ntpms; i++) { virDomainTPMDef *tpm =3D def->tpms[i]; =20 - /* TPM 1.2 and 2 are not compatible, so we choose a specific versi= on here */ - if (tpm->type =3D=3D VIR_DOMAIN_TPM_TYPE_EMULATOR && - tpm->data.emulator.version =3D=3D VIR_DOMAIN_TPM_VERSION_DEFAU= LT) { - if (tpm->model =3D=3D VIR_DOMAIN_TPM_MODEL_SPAPR || - tpm->model =3D=3D VIR_DOMAIN_TPM_MODEL_CRB || - qemuDomainIsARMVirt(def)) - tpm->data.emulator.version =3D VIR_DOMAIN_TPM_VERSION_2_0; - else - tpm->data.emulator.version =3D VIR_DOMAIN_TPM_VERSION_1_2; - } - if (tpm->model =3D=3D VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY) { if (proxyTPM) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -5806,15 +5795,26 @@ qemuDomainHostdevDefPostParse(virDomainHostdevDef *= hostdev, =20 static int qemuDomainTPMDefPostParse(virDomainTPMDef *tpm, - virArch arch) + const virDomainDef *def) { if (tpm->model =3D=3D VIR_DOMAIN_TPM_MODEL_DEFAULT) { - if (ARCH_IS_PPC64(arch)) + if (ARCH_IS_PPC64(def->os.arch)) tpm->model =3D VIR_DOMAIN_TPM_MODEL_SPAPR; else tpm->model =3D VIR_DOMAIN_TPM_MODEL_TIS; } =20 + /* TPM 1.2 and 2 are not compatible, so we choose a specific version h= ere */ + if (tpm->type =3D=3D VIR_DOMAIN_TPM_TYPE_EMULATOR && + tpm->data.emulator.version =3D=3D VIR_DOMAIN_TPM_VERSION_DEFAULT) { + if (tpm->model =3D=3D VIR_DOMAIN_TPM_MODEL_SPAPR || + tpm->model =3D=3D VIR_DOMAIN_TPM_MODEL_CRB || + qemuDomainIsARMVirt(def)) + tpm->data.emulator.version =3D VIR_DOMAIN_TPM_VERSION_2_0; + else + tpm->data.emulator.version =3D VIR_DOMAIN_TPM_VERSION_1_2; + } + return 0; } =20 @@ -5941,7 +5941,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDef *dev, break; =20 case VIR_DOMAIN_DEVICE_TPM: - ret =3D qemuDomainTPMDefPostParse(dev->data.tpm, def->os.arch); + ret =3D qemuDomainTPMDefPostParse(dev->data.tpm, def); break; =20 case VIR_DOMAIN_DEVICE_MEMORY: --=20 2.35.1