From nobody Sun Feb 8 11:25:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1589398290; cv=none; d=zohomail.com; s=zohoarc; b=OptGlzySE33S2oqJeJKH5QiiTCwuZSaYiVvuGiB/qygRXpKGAbtJEp+xZ7be6rvCrGWUFAhS9mSVhZx+Iw0p9v17bfGiab96JUqJAwO+dUMk/QyVclSY6TBNJMKmlDqcIz/d8AOOEnDCLAqzLLN8Dv4fwCDY2IGh2G9FHTOCZqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589398290; 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=fwqHS031BTNY7s5ufY/ZvRXz9rN+Kl+ohGbdD+LkgfY=; b=mZDeh1x15Wl0pphlaPIdr5JeICpio2EvL+wiwOf2m095LBb419Bq7WfEzxqyGK4eXb86FL7veuPc5cvmPxoDAAY1M6Rp3o+cv3TIsvUsCJBPrIY6nC3YgSlfa3vbz9vshY70iXCYf8YYq/zuiSsq9YgoRG4FTgV54H1s5nbjMv8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1589398290740530.87171149891; Wed, 13 May 2020 12:31:30 -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-117-yaReqeJ8Pn2D8yBZaQXrxA-1; Wed, 13 May 2020 15:31:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7988B80B730; Wed, 13 May 2020 19:31:19 +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 5B02E7529E; Wed, 13 May 2020 19:31:19 +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 2D8754E981; Wed, 13 May 2020 19:31:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04DJVCVC021938 for ; Wed, 13 May 2020 15:31:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 11E331182E4; Wed, 13 May 2020 19:31:12 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 934771108F9 for ; Wed, 13 May 2020 19:31:11 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 52E5818A6660 for ; Wed, 13 May 2020 19:31:11 +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-309-dEYTQ0GmMmiedqZOvlf0sQ-1; Wed, 13 May 2020 15:31:08 -0400 Received: by mail-qt1-f194.google.com with SMTP id 4so845781qtb.4 for ; Wed, 13 May 2020 12:31:08 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:fbf2:bc5e:c314:af31:7070]) by smtp.gmail.com with ESMTPSA id n20sm478880qtk.89.2020.05.13.12.31.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 12:31:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589398289; 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=fwqHS031BTNY7s5ufY/ZvRXz9rN+Kl+ohGbdD+LkgfY=; b=YBrCMm0IHY6Z5zgo5pxZvncK3UOkAmO4vQ8PV2/eoU4ThstQTZjSwPZopBRM7c+pZYynN1 t+fIR0875S2W8mx5cyTx18I/A2tY2lncCd6CSwS8lH/3dhyxQzu0FatKkfpmPMkt09W0xD QLGnB5V+Nk1vAPH2NP9EokWruy19BtI= X-MC-Unique: yaReqeJ8Pn2D8yBZaQXrxA-1 X-MC-Unique: dEYTQ0GmMmiedqZOvlf0sQ-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=fwqHS031BTNY7s5ufY/ZvRXz9rN+Kl+ohGbdD+LkgfY=; b=Wt0NXyVidIP8Rw5OmMNygZJ+tTeseJObyW0XSEGg212gSta2vKhL5kPx71RII7yvFD GsaGiz8qnj1uEiuqcyHAO28DfdvwUkBzuJZ5J/O6pL1i2hIyEY1e4GTBqjfdvr42mUnb YPwBx54e9A/6Ym6p66gtkdV+u/az04tXAFeimG7G/BebK3Vs5fDTpN9SaFhkWexlfzNi A0pGI6+pCH9hb93a6K6hSgwbWcIgD7WP60vbMcLGZ8cI1mKKfPG+C1Eqa8YByV94ls+K XhaFWpe7EdTyOvLyxvlzK+ld7vOJcnUtRKc21UZkGGqz2DNz/NZqQb16c9kxfVGgSQyJ cyUA== X-Gm-Message-State: AOAM531R86fTeyQtHmxEIgIVmXSAqnXoUQ8D4AhD3gYhWUUwCwvOLhHA AbIzYkEM80Iz9TFaTH6dWBH2k/gd X-Google-Smtp-Source: ABdhPJzLTeVosJ7Kz3rzZWnUAfW/yg0PEZEL/k3A9iZ6qo8OGCBfsD5N0bqUnVgQUJQzSLyG+mvWng== X-Received: by 2002:ac8:46d3:: with SMTP id h19mr754398qto.133.1589398267953; Wed, 13 May 2020 12:31:07 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 5/9] domain_conf.c: XML parsing for VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY Date: Wed, 13 May 2020 16:30:40 -0300 Message-Id: <20200513193044.3401170-6-danielhb413@gmail.com> In-Reply-To: <20200513193044.3401170-1-danielhb413@gmail.com> References: <20200513193044.3401170-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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.11 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" 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 Reviewed-by: Stefan Berger --- src/conf/domain_conf.c | 45 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 01a32f62d1..8164cd58c9 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,39 @@ 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++) { + g_autoptr(virDomainTPMDef) dev =3D NULL; + + if (!(dev =3D virDomainTPMDefParseXML(xmlopt, nodes[i], ctxt, = flags))) + 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")); + 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")); + goto error; + } + def->tpm =3D g_steal_pointer(&dev); + } + } } VIR_FREE(nodes); =20 @@ -29807,6 +29839,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