From nobody Sun Feb 8 22:43:33 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=1658136726; cv=none; d=zohomail.com; s=zohoarc; b=Kuq2zKQEuI96nbq4azfeoBO3K96C9wHe8KTEn8F1/c5NaQjZJTeLQsEV8bbwVucgwvOYo+Yz/67l2gN7+bTaDZisQp5VtYu9udtCUfY/4mJ9/qEcS5qR6UvCs8EBiIZrp79dSsfyPjCFvFv+Ds9cLKdlBdbQOGLvcQf4+b9qhMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658136726; 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=H/GwXXEx9omzhlOhGeBxiuvlQTjdXNCr8YE1HUc2Rew=; b=C6PkJ/cBOQlc4UDOxZtRM4xtiP4tsnJKJBYVVFSgdK0Y9rhdFeBNVR8bat15FSgU/2UZFRGT16A7aArvKMOuK6lNg6X1BOGmlaSduWG48wqguaNyf5aRhYDartVXzYVFMeklPWQiNYkUcnXauxZ/KYp+CdSbnIA/UWI2sAJTfz4= 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 1658136726346569.5393441322857; Mon, 18 Jul 2022 02:32:06 -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-610-2ZrPmfC8P32JrM9T-ib73Q-1; Mon, 18 Jul 2022 05:31:00 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 56B6A296A602; Mon, 18 Jul 2022 09:30:58 +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 4248D2166B29; Mon, 18 Jul 2022 09:30:58 +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 09D491947054; Mon, 18 Jul 2022 09:30:58 +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 7DA461947063 for ; Mon, 18 Jul 2022 09:30:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 61E7C2166B29; Mon, 18 Jul 2022 09:30:56 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DD5E2166B26 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=1658136725; 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=H/GwXXEx9omzhlOhGeBxiuvlQTjdXNCr8YE1HUc2Rew=; b=AKNLa3MCE2Ok3fRnn/DjygNAu17iYfjCMXnBOqX7MlxCBMF/O9M8uFycbhEu3yqoLfk02v 3WAqOTDWzOU9yecZsT8kqyRKbOlo0yzJXqDrbQci5HdYEP1ZNzkS+cFZyz+3WqBV7H4jd6 JvI1Ei0cZVUeGxdjex/FBO5yvkuUNJY= X-MC-Unique: 2ZrPmfC8P32JrM9T-ib73Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 7/8] qemu: Move TPMs validation out of PostParse Date: Mon, 18 Jul 2022 11:30:49 +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.78 on 10.11.54.6 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: 1658136728376100001 Content-Type: text/plain; charset="utf-8"; x-default="true" After previous cleanup, the qemuDomainDefTPMsPostParse() function does nothing more than validates TPM devices. Therefore, it should live in qemu_validate.c instead of qemu_domain.c. Move it there and rename to reflect the fact that the function is doing validation instead of PostParsing. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/qemu/qemu_domain.c | 34 ---------------------------------- src/qemu/qemu_validate.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index bcee4d2602..e3d1bb548f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4583,37 +4583,6 @@ qemuDomainDefNumaCPUsPostParse(virDomainDef *def, } =20 =20 -static int -qemuDomainDefTPMsPostParse(virDomainDef *def) -{ - virDomainTPMDef *proxyTPM =3D NULL; - virDomainTPMDef *regularTPM =3D NULL; - size_t i; - - for (i =3D 0; i < def->ntpms; i++) { - virDomainTPMDef *tpm =3D def->tpms[i]; - - if (tpm->model =3D=3D VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY) { - if (proxyTPM) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("only a single TPM Proxy device is suppor= ted")); - return -1; - } else { - proxyTPM =3D tpm; - } - } else if (regularTPM) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("only a single TPM non-proxy device is suppor= ted")); - return -1; - } else { - regularTPM =3D tpm; - } - } - - return 0; -} - - static int qemuDomainDefPostParseBasic(virDomainDef *def, void *opaque G_GNUC_UNUSED) @@ -4709,9 +4678,6 @@ qemuDomainDefPostParse(virDomainDef *def, if (qemuDomainDefNumaCPUsPostParse(def, qemuCaps) < 0) return -1; =20 - if (qemuDomainDefTPMsPostParse(def) < 0) - return -1; - return 0; } =20 diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index ff164118b7..ce8f92f301 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1113,6 +1113,37 @@ qemuValidateDomainDefPanic(const virDomainDef *def, } =20 =20 +static int +qemuValidateDomainDefTPMs(const virDomainDef *def) +{ + const virDomainTPMDef *proxyTPM =3D NULL; + const virDomainTPMDef *regularTPM =3D NULL; + size_t i; + + for (i =3D 0; i < def->ntpms; i++) { + virDomainTPMDef *tpm =3D def->tpms[i]; + + if (tpm->model =3D=3D VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY) { + if (proxyTPM) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("only a single TPM Proxy device is suppor= ted")); + return -1; + } else { + proxyTPM =3D tpm; + } + } else if (regularTPM) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("only a single TPM non-proxy device is suppor= ted")); + return -1; + } else { + regularTPM =3D tpm; + } + } + + return 0; +} + + int qemuValidateLifecycleAction(virDomainLifecycleAction onPoweroff, virDomainLifecycleAction onReboot, @@ -1310,6 +1341,9 @@ qemuValidateDomainDef(const virDomainDef *def, if (qemuValidateDomainDefPanic(def, qemuCaps) < 0) return -1; =20 + if (qemuValidateDomainDefTPMs(def) < 0) + return -1; + if (def->sec) { switch ((virDomainLaunchSecurity) def->sec->sectype) { case VIR_DOMAIN_LAUNCH_SECURITY_SEV: --=20 2.35.1