From nobody Sun Feb 8 06:05:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1591812762; cv=none; d=zohomail.com; s=zohoarc; b=mH/eYF/tNMhG0pQoLcXmB0him3Jm2Oz53iu6Kk5BQ+IBC7srSLUzjFbSnUffQYoMqgbu/H7mfUcTHGeN8z96fqt8lVwE8+4a85IxUc4o+coJxpQnrhQb6Ac0MNk7UaMN4jjyX7qGhU69WL1Hminj4dMOyBAyXskvCZmDKXQxKbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591812762; h=Content-Type:Content-Transfer-Encoding:Cc: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=AZpwZt4H7lfkRdzPwNN1+5sYpOCD4D2L2Xt0wUy0Hxg=; b=TAj8XvMErwvm2tjA2HGaRwHeYkRX92E6uH7T07sicc7bLyiSBbTPP4qwx4OG3EzJu2jyV/UDII9VJFpYcGW9AL/8k+zlTbim1Udw1w7qYKaH7mAQk4HvUtHhkA3wkPsGt7EwjqCc7/uDyPaq3WBn+MBiul9y8mifpGyZXLchza8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1591812762478416.0075737015611; Wed, 10 Jun 2020 11:12:42 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-116-oXpt3QzHOJmAgguJryrS4w-1; Wed, 10 Jun 2020 14:12:39 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A9DB81902EA2; Wed, 10 Jun 2020 18:12:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8878060F8A; Wed, 10 Jun 2020 18:12:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5A3F7B34A6; Wed, 10 Jun 2020 18:12:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05AICID5020162 for ; Wed, 10 Jun 2020 14:12:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id F0C6E10F8E1E; Wed, 10 Jun 2020 18:12:17 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC93810F8E1D for ; Wed, 10 Jun 2020 18:12:17 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D3295101A525 for ; Wed, 10 Jun 2020 18:12:17 +0000 (UTC) Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-60-egJUlr1OOoKYKaxbqQMJqw-1; Wed, 10 Jun 2020 14:12:15 -0400 Received: by mail-qk1-f195.google.com with SMTP id n141so3006957qke.2 for ; Wed, 10 Jun 2020 11:12:15 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:b081:e954:9388:2ec6:d6f4]) by smtp.gmail.com with ESMTPSA id z4sm569415qtu.33.2020.06.10.11.12.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2020 11:12:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591812761; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=AZpwZt4H7lfkRdzPwNN1+5sYpOCD4D2L2Xt0wUy0Hxg=; b=Fn+2RoxVpWsZC+kU9xDAuNBuOo8aTH3J0SmF7k6si7Vf3NU9AbQlKrPLsnLyi44bQdT1vt 0y+ktsVyZmGSTRY8XlpNa/0m30FBE+gfrdt7/5/gS9OT2ujWI/CHNQA31/ZAq6tpEJeckZ kre5KezFRfjRlb64nQRVCkgA3Vkswbw= X-MC-Unique: oXpt3QzHOJmAgguJryrS4w-1 X-MC-Unique: egJUlr1OOoKYKaxbqQMJqw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AZpwZt4H7lfkRdzPwNN1+5sYpOCD4D2L2Xt0wUy0Hxg=; b=eXQ248ZbOzW+oi+WZ4DQRL7CHsalZ3KZhWMj/iZ9Pyivvwp/VzjtuP/4T6ubHygfJh fagsrUH/g0lhLPQGxfk0abvyhvcjl0bipbZOZD0n8HP8bS0EQMZuW4DSmlxEcQz6wN8b 3eeOxvf3L1As9LZN/Ab6GR6ShQAm52Tyi+KV5QU9BilHAh1mFUaJaAjJEjY7Vl7av5Xd nCrsGZl1shNMX/tf7S1dDq3JJwko6BpOT5bycsuJq3keTVHsQlBR8SwXr2v6Y+CF6j6G H83TsVvHovHdL0tK7rnlFXR8R9jh3CB5HUmR23ClmjrODbto2S53QKHosF2RdBe/PNRV q6Iw== X-Gm-Message-State: AOAM532ND+xiq4r3QO3BSmaVqMLGOgN0S8f9Jgjt0BcEYseiG8HHxIxX AcflAQRAnK3M6pcxXZtDdyN87CIM X-Google-Smtp-Source: ABdhPJz2kaYKLPrDd6TKX3O7+rQziJBr+3y0mRFBviH3m2YbF0s3dFAqNQ3ZrW3dIpG6ciDOzfIFXQ== X-Received: by 2002:a05:620a:a56:: with SMTP id j22mr4334076qka.287.1591812734718; Wed, 10 Jun 2020 11:12:14 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v7 06/10] qemu: add validations after TPM Proxy model introduction Date: Wed, 10 Jun 2020 15:11:48 -0300 Message-Id: <20200610181152.374479-7-danielhb413@gmail.com> In-Reply-To: <20200610181152.374479-1-danielhb413@gmail.com> References: <20200610181152.374479-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , stefanb@linux.ibm.com, sathnaga@linux.vnet.ibm.com, david@gibson.dropbear.id.au X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Previous patch handled the conversion of def->tpm to the array def->tpms and the XML parsing logic. This patch handles the validations needed to ensure the intended behavior. The existing qemuValidateDomainDeviceDefTPM() function was updated to guarantee that the VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY model is exclusive to PPC64 guests and to the VIR_DOMAIN_TPM_TYPE_PASSTHROUGH backend. A new function called qemuDomainDefTPMsPostParse() was added to guarantee that the following combinations in the same domain are valid: - a single TPM device - a single TPM Proxy device - a single TPM + single TPM Proxy devices And these combinations in the same domain are NOT valid: - 2 or more TPM devices - 2 or more TPM Proxy devices Tested-by: Satheesh Rajendran Reviewed-by: Stefan Berger Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 37 +++++++++++++++++++++++++++++++++++++ src/qemu/qemu_validate.c | 19 +++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5de308d285..6586c86a8d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4963,6 +4963,40 @@ qemuDomainDefTsegPostParse(virDomainDefPtr def, } =20 =20 +static int +qemuDomainDefTPMsPostParse(virDomainDefPtr def) +{ + virDomainTPMDefPtr proxyTPM =3D NULL; + virDomainTPMDefPtr regularTPM =3D NULL; + size_t i; + + if (def->ntpms < 2) + return 0; + + for (i =3D 0; i < def->ntpms; i++) { + virDomainTPMDefPtr 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(virDomainDefPtr def, void *opaque G_GNUC_UNUSED) @@ -5049,6 +5083,9 @@ qemuDomainDefPostParse(virDomainDefPtr def, if (qemuDomainDefTsegPostParse(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 b1a81ab193..f77030bd46 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -3655,6 +3655,25 @@ qemuValidateDomainDeviceDefTPM(virDomainTPMDef *tpm, case VIR_DOMAIN_TPM_MODEL_SPAPR: flag =3D QEMU_CAPS_DEVICE_TPM_SPAPR; break; + case VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY: + if (!ARCH_IS_PPC64(def->os.arch)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("TPM Proxy model %s is only available for " + "PPC64 guests"), + virDomainTPMModelTypeToString(tpm->model)); + return -1; + } + + /* TPM Proxy devices have 'passthrough' backend */ + if (tpm->type !=3D VIR_DOMAIN_TPM_TYPE_PASSTHROUGH) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("TPM Proxy model %s requires " + "'Passthrough' backend"), + virDomainTPMModelTypeToString(tpm->model)); + } + + flag =3D QEMU_CAPS_DEVICE_SPAPR_TPM_PROXY; + break; case VIR_DOMAIN_TPM_MODEL_LAST: default: virReportEnumRangeError(virDomainTPMModel, tpm->model); --=20 2.26.2