From nobody Tue Nov 26 00:31:02 2024 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=1589379132; cv=none; d=zohomail.com; s=zohoarc; b=V1FXRw28bIWTs6/bmYYIZWUrPY5LdDYEfS+VJ6ZEpiX5bjieR+Ynj3uuAqEwvPLjWR/IXWuf1Bi2UBcqObXoy/bFcBHjxsQT1eHk2tAN+2fcti3y6cXbvYpXho35HbyF+ETn5GB9bjbqrdxV37YlHNlUmMgztitNjGFcryIK8OU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589379132; 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=7UNFEkpwchPZu9LV7NiYQhf2gcGkt4JbhA+K+XJIc4c=; b=E+m5yYKqLSnhTLGM/2ghqAmi5V+luQvO+lJIMGFk3TCG+xR9cnht7ticsaiJ/3UuN6T0Jkc8Aun07zwiCOonpjL1mlxJAfJH1RVl1xrX6VH5pWSNdGiWOpN6XARnnvB1EUrxKlVtP8Ivz15d3JOiKSkA4bP2CNVAmx0P+0O6zkc= 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-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1589379132980570.3130842418219; Wed, 13 May 2020 07:12:12 -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-348-8U2NzML4OXWB5ItzBvQcCQ-1; Wed, 13 May 2020 10:12:07 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E92E8018A2; Wed, 13 May 2020 14:12:02 +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 EEC88783B3; Wed, 13 May 2020 14:12:01 +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 BD97A4CAB0; Wed, 13 May 2020 14:12:01 +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 04DEB5UZ026931 for ; Wed, 13 May 2020 10:11:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id F23092156A53; Wed, 13 May 2020 14:11:04 +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 DEAF42156A4B for ; Wed, 13 May 2020 14:11:03 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 9B1F11097ACA for ; Wed, 13 May 2020 14:11:03 +0000 (UTC) Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-511-4eikH_fXOAK0Re6RPkDaXA-1; Wed, 13 May 2020 10:10:57 -0400 Received: by mail-qt1-f194.google.com with SMTP id h26so14214364qtu.8 for ; Wed, 13 May 2020 07:10:57 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:fbf2:bc5e:c314:af31:7070]) by smtp.gmail.com with ESMTPSA id y28sm9906755qtc.62.2020.05.13.07.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 07:10:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589379130; 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=7UNFEkpwchPZu9LV7NiYQhf2gcGkt4JbhA+K+XJIc4c=; b=HgjsLg8Oz9MIyU3puNqrSwDOPHakIiz4792rhgX0eiZ/sm2zHie2bDE304U7QTSS1WR4m1 S7l2PWHw9er00lI0Qr7ngtNY5cGhn7jA1jhXfEi6qHobHO/eTmkJTSysm1FfXRcHedYDWA C2bW3h8RLmi+HE1KU2nSOfYs5ruWrgI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589379131; 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=7UNFEkpwchPZu9LV7NiYQhf2gcGkt4JbhA+K+XJIc4c=; b=B4tSe4BETfHN2MjAuEifhFP+5pJ79SBdKJAxaa8UfK07flT8Y/1LE3g8pqHsWCpcS3sDpc 5tx2EFFmDYLwLfMiqGVLbow/Phyzkmvm6xUIPX3+9+bPaVoFCiE7mxPIQPmlC2+lChoH4y YyrhvdlubesF0LVecYEJY1JUG6Txc80= X-MC-Unique: 8U2NzML4OXWB5ItzBvQcCQ-1 X-MC-Unique: 4eikH_fXOAK0Re6RPkDaXA-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=7UNFEkpwchPZu9LV7NiYQhf2gcGkt4JbhA+K+XJIc4c=; b=mjuzsGR6X87WIzm8yp2XyjGxeyP14Pek0sZm5JZsa6/dg1dinSDs5npXtJC0TxCAm3 UXxDNCP7PPZ+idGlcu4afuoSIIron09atPi/wB71h5wIYMbkz38yB9ZmstFxKdOtxIys +hnXgphnaa7IPvGrGEM9FmbwTsCErtByAGfKZVEEQXw7S42UZX9umf54txFNLWFkwdxy JWAIOI68DUvIGwj/XsYu5sU5PP3WuzMADts9WkSNio+jFSe37Ej/D93PIe6CljAwkIy2 e+lGJ1lYdGBOHY3R9HyfFBCvoo4pI1450PVE6F4r9mLk12eSKcsJXwx6dnZSx2c5Jkeb PK5g== X-Gm-Message-State: AGi0PubIhL1FGCWp2g0dIske9ZXVpjp5EHRnn//iYns5wrQHNsxAPTQ0 gcp+xXEhiuhqRvPOGbvKqMWHw3AQWO4= X-Google-Smtp-Source: APiQypKyeppeeOdVdjikjcdQallhp8nrL+6nhyfMxW76MJ6ICVdaW+kZsINl5txaN6L+hxwZ0pXhXA== X-Received: by 2002:ac8:4b5b:: with SMTP id e27mr26439367qts.46.1589379057041; Wed, 13 May 2020 07:10:57 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 4/8] domain_conf.c: XML parsing for VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY Date: Wed, 13 May 2020 11:10:35 -0300 Message-Id: <20200513141040.2580726-5-danielhb413@gmail.com> In-Reply-To: <20200513141040.2580726-1-danielhb413@gmail.com> References: <20200513141040.2580726-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 , stefanb@linux.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.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Aside from trivial XML parsing/format changes, this patch adds additional rules for TPM device support to better accomodate all the available scenarios with the new TPM Proxy. The changes make no impact to existing domains. This means that the scenario of a domain with a single TPM device is still supported in the same way. The restriction of multiple TPM devices got alleviated to allow a TPM Proxy device to be added together with a TPM device in the same domain. All other combinations are still forbidden. To summarize, after this patch, 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 These combinations in the same domain are NOT allowed: - 2 or more TPM devices - 2 or more TPM Proxy devices Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 47 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 01a32f62d1..33b7d69318 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13730,6 +13730,14 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlo= pt, goto error; } =20 + /* TPM Proxy devices have 'passthrough' backend */ + if (def->model =3D=3D VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY && + def->type !=3D VIR_DOMAIN_TPM_TYPE_PASSTHROUGH) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'Passthrough' backend is required for TPM Proxy = devices")); + goto error; + } + if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) goto error; =20 @@ -21972,15 +21980,41 @@ virDomainDefParseXML(xmlDocPtr xml, if ((n =3D virXPathNodeSet("./devices/tpm", ctxt, &nodes)) < 0) goto error; =20 - if (n > 1) { + if (n > 2) { virReportError(VIR_ERR_XML_ERROR, "%s", - _("only a single TPM device is supported")); + _("a maximum of two TPM devices is supported, one o= f " + "them being a TPM Proxy device")); goto error; } =20 if (n > 0) { - if (!(def->tpm =3D virDomainTPMDefParseXML(xmlopt, nodes[0], ctxt,= flags))) - goto error; + for (i =3D 0; i < n; i++) { + virDomainTPMDefPtr dev =3D virDomainTPMDefParseXML(xmlopt, nod= es[i], ctxt, flags); + + if (!dev) + goto error; + + /* TPM Proxy devices must be held in def->tpmproxy. Error + * out if there's a TPM Proxy declared already */ + if (dev->model =3D=3D VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY) { + if (def->tpmproxy) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("only a single TPM Proxy device is su= pported")); + VIR_FREE(dev); + goto error; + } + def->tpmproxy =3D g_steal_pointer(&dev); + } else { + /* all other TPM devices goes to def->tpm */ + if (def->tpm) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("only a single TPM non-proxy device i= s supported")); + VIR_FREE(dev); + goto error; + } + def->tpm =3D g_steal_pointer(&dev); + } + } } VIR_FREE(nodes); =20 @@ -29807,6 +29841,11 @@ virDomainDefFormatInternalSetRootName(virDomainDef= Ptr def, goto error; } =20 + if (def->tpmproxy) { + if (virDomainTPMDefFormat(buf, def->tpmproxy, flags) < 0) + goto error; + } + for (n =3D 0; n < def->ngraphics; n++) { if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0) goto error; --=20 2.26.2