From nobody Sun Feb 8 01:33:19 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1591104741; cv=none; d=zohomail.com; s=zohoarc; b=Wtgz69lThh4DQWCxjoym9Yu4kSPL67pi0vwDhfTtZ6UZiA3luQa6diAAfJwVZ1Vutku0i0WtXZ4yo19kvHHJGlNY8jsroJeNcwwCHk8Ilo32hCIZibdnftjKCXodzmvRRWpoKzP8G3+vOXHBZ9dzsKTRn3PwExAzFntSlHblMW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591104741; 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=hPAv/PSgrnX0CMBIsRq/2NZdEs68MMbhjBK+rTL3Fr8=; b=dt94D6lmk1EAjH5xPqFwuYHTgCXcy1EY4VD9b3hJxOV9OzKbo0dgbWWg62CIDUeblr3yzs8S+68JlmT8almVik0qcgkSpcTxTca8LCaer2ovFFltHXQT33wXTGzgAfYPE1pzE6RFraHmZGshhXMnMk4PuxlQ/lBiB0nPdLhUgG0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1591104741872641.4723631614887; Tue, 2 Jun 2020 06:32:21 -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-332-1ZMD_ELYMyuJep2jO83UJA-1; Tue, 02 Jun 2020 09:32:18 -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 9F72B81E22C; Tue, 2 Jun 2020 13:32:09 +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 7B0056199D; Tue, 2 Jun 2020 13:32:09 +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 49F559701D; Tue, 2 Jun 2020 13:32:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 052DW7Aw007370 for ; Tue, 2 Jun 2020 09:32:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3EA11217B43B; Tue, 2 Jun 2020 13:32:07 +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 B24CF2156A54 for ; Tue, 2 Jun 2020 13:31:59 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (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 6ACB0108C273 for ; Tue, 2 Jun 2020 13:31:58 +0000 (UTC) Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-60-0CFpPd93N7S-5j2ja1ZLbg-1; Tue, 02 Jun 2020 09:31:52 -0400 Received: by mail-qt1-f195.google.com with SMTP id k22so10566612qtm.6; Tue, 02 Jun 2020 06:31:52 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:9da7:da03:b92e:aafb:831c]) by smtp.gmail.com with ESMTPSA id c58sm2735424qtd.27.2020.06.02.06.31.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 06:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591104740; 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=hPAv/PSgrnX0CMBIsRq/2NZdEs68MMbhjBK+rTL3Fr8=; b=MTG0nTXvw3mpj9+GbJD7OjfyYI1qp4YKS2fX225LOIYhlPZcd/MTLhHUaoRpGiOuWdw9IB 0/1rtpqtHhOsOre+OLofuo0vXgu4ahxT0KZDDA9LUn+TyEFIRn8a3oyWbIZvcjM89pvI0C 9kRyynViAtZeHE2UX5n7NPnHAwMKqZ4= X-MC-Unique: 1ZMD_ELYMyuJep2jO83UJA-1 X-MC-Unique: 0CFpPd93N7S-5j2ja1ZLbg-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=hPAv/PSgrnX0CMBIsRq/2NZdEs68MMbhjBK+rTL3Fr8=; b=uKkxtCcERL0k6NHqudxlZsZb6wJxLvdVg6PIKGuJc0frGN+Uka1bU/3ZZl/pdsFx2a gKPVducUj25m1VpO+zwkL7SB4b8FaPhuxuKfFOq1UnQxbigGPtWCyJWgAAzvkEHCcG3g 2+4uECS0+837fw6QEqslBW4Z07i9wHvU314WpW7VpXulDQS5krBDyZyEyPYOxEC27do5 l4gZvRqcemHfoW/TZCjjRVjN6J7A/yyZnabg+e/rBpq3saUd20beOvegBjcXF7f+3MqN Ls+cHZRMMzUmGqAH3Hjxn4HSNoSipP8W/SoswCVIG43B/c/n1nxCAJtKNpvN6/ZCe3DS Dl6w== X-Gm-Message-State: AOAM533BtAGgiJG+E7sBxL6/qI2hpasf2Cue7AYGLkyOMGeFW3JENQ3d RSvz31vgsU56b6Jv3v9rutWO79Lo X-Google-Smtp-Source: ABdhPJxPLPxohVNuZI7zG1o4H7AdNOgkxJAGXrg6pOzOkpgOTg39UiiXIVe9fBoRjyHtryUmtNLVsw== X-Received: by 2002:ac8:1858:: with SMTP id n24mr27280570qtk.189.1591104711834; Tue, 02 Jun 2020 06:31:51 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v6 06/10] qemu: add validations after TPM Proxy model introduction Date: Tue, 2 Jun 2020 10:31:03 -0300 Message-Id: <20200602133107.1987182-7-danielhb413@gmail.com> In-Reply-To: <20200602133107.1987182-1-danielhb413@gmail.com> References: <20200602133107.1987182-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , jtomko@redhat.com, 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 --- 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 3173fc3a3b..b1b50f05d4 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4953,6 +4953,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) @@ -5039,6 +5073,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 584d1375b8..28e02ebefc 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -3623,6 +3623,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