From nobody Fri Oct 18 06:19:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1720093722269645.0360863374119; Thu, 4 Jul 2024 04:48:42 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 23EA41531; Thu, 4 Jul 2024 07:48:41 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id DE3C71577; Thu, 4 Jul 2024 07:47:54 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 8931FE77; Thu, 4 Jul 2024 07:47:51 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 55F9B123A for ; Thu, 4 Jul 2024 07:47:49 -0400 (EDT) Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-67-8UhM-UEOPL-M2J_LSV05Xw-1; Thu, 04 Jul 2024 07:47:47 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D11B31955F45 for ; Thu, 4 Jul 2024 11:47:46 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.21]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E8C7E1956046; Thu, 4 Jul 2024 11:47:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720093669; h=from:from: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; bh=10smjCkAocxc1SrJISt2En0IXw+CmQjcV0T3wDub5Mw=; b=Xt9HGXQUon9vuEgLUtPhy8bHl/B/H3xZ3ZbOPmjLcwQn1Uz6Ze9iQidW3CsbGfJ03ZoyjK qVQ9vhHgpPvLhBMRFmTeYPd6U5iwsFVloRA8L0pq0uSuY1jcPihhOds7YZQBmlDuOY6LnB Qw/53u9mXB1IjYNSTFbTvtAq6snoqnA= X-MC-Unique: 8UhM-UEOPL-M2J_LSV05Xw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: devel@lists.libvirt.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH 1/2] conf: add support for 'debug' parameter on TPM emulator Date: Thu, 4 Jul 2024 12:47:38 +0100 Message-ID: <20240704114739.2873761-2-berrange@redhat.com> In-Reply-To: <20240704114739.2873761-1-berrange@redhat.com> References: <20240704114739.2873761-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: D5JQVOMC4GW6SQCZBUQUYILKDTOL6RE7 X-Message-ID-Hash: D5JQVOMC4GW6SQCZBUQUYILKDTOL6RE7 X-MailFrom: berrange@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1720093723382100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- docs/formatdomain.rst | 6 ++++-- src/conf/domain_conf.c | 7 +++++++ src/conf/domain_conf.h | 1 + src/conf/schemas/domaincommon.rng | 5 +++++ tests/qemuxmlconfdata/tpm-emulator-tpm2.xml | 2 +- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 5c09b87d2b..fbd05e089d 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -8097,7 +8097,7 @@ Example: usage of the TPM Emulator ... - + @@ -8141,7 +8141,9 @@ Example: usage of the TPM Emulator ``emulator`` For this backend type the 'swtpm' TPM Emulator must be installed on = the host. Libvirt will automatically start an independent TPM emulator f= or - each QEMU guest requesting access to it. + each QEMU guest requesting access to it. :since:`10.6.0`, the ``debu= g`` + parameter can be used to enable logging in the emulator backend, and + accepts non-zero integer values.=20 =20 ``version`` The ``version`` attribute indicates the version of the TPM. This attrib= ute diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cb1154b23f..ab313adf6e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10783,6 +10783,10 @@ virDomainTPMDefParseXML(virDomainXMLOption *xmlopt, &def->data.emulator.version) < 0) goto error; =20 + if (virXMLPropUInt(backends[0], "debug", 10, VIR_XML_PROP_NONE, + &def->data.emulator.debug) < 0) + goto error; + if (!(def->data.emulator.source =3D virDomainChrSourceDefNew(xmlop= t))) goto error; secretuuid =3D virXPathString("string(./backend/encryption/@secret= )", ctxt); @@ -24865,6 +24869,9 @@ virDomainTPMDefFormat(virBuffer *buf, } if (def->data.emulator.persistent_state) virBufferAddLit(&backendAttrBuf, " persistent_state=3D'yes'"); + if (def->data.emulator.debug !=3D 0) + virBufferAsprintf(&backendAttrBuf, " debug=3D'%u'", + def->data.emulator.debug); if (def->data.emulator.hassecretuuid) { char uuidstr[VIR_UUID_STRING_BUFLEN]; =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2818a9f1f5..1b9d07f1a4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1476,6 +1476,7 @@ struct _virDomainTPMDef { virDomainChrSourceDef *source; char *storagepath; char *logfile; + unsigned int debug; unsigned char secretuuid[VIR_UUID_BUFLEN]; bool hassecretuuid; bool persistent_state; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 844a931deb..981ad10a37 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -5913,6 +5913,11 @@ + + + + + diff --git a/tests/qemuxmlconfdata/tpm-emulator-tpm2.xml b/tests/qemuxmlcon= fdata/tpm-emulator-tpm2.xml index 79acde218b..8a613db456 100644 --- a/tests/qemuxmlconfdata/tpm-emulator-tpm2.xml +++ b/tests/qemuxmlconfdata/tpm-emulator-tpm2.xml @@ -28,7 +28,7 @@ - + --=20 2.45.1 From nobody Fri Oct 18 06:19:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1720093742334694.9549954475763; Thu, 4 Jul 2024 04:49:02 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4250D1260; Thu, 4 Jul 2024 07:49:01 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 74FCE15C3; Thu, 4 Jul 2024 07:47:57 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3C3FAE5B; Thu, 4 Jul 2024 07:47:52 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 95DA0C7F for ; Thu, 4 Jul 2024 07:47:51 -0400 (EDT) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-264-1iK5EvuMN16nxrpbnmSVEw-1; Thu, 04 Jul 2024 07:47:50 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3C88719560A2 for ; Thu, 4 Jul 2024 11:47:49 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.21]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8F39D1956046; Thu, 4 Jul 2024 11:47:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720093671; h=from:from: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; bh=dUUAT9qDzH41GSiAQOt1lnOhjlA013S8QVhJhi8kDGc=; b=P8zR0qF7ltlrWiALUNupQZGDFONU1VK4URxZP4xLSm+F4CmGE48UKcn2z0mDU9rVy5GGXk p65Veu1DaLcSTVo7M6aTPgx18O4B1N/Rr+Cqg2YPzR5I8rHCnAkdEhJXqLnNxlJlgPtkju tQ1Fq0B/krRLtjvqDtwjp3jLWUX/OTg= X-MC-Unique: 1iK5EvuMN16nxrpbnmSVEw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: devel@lists.libvirt.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH 2/2] qemu: set swtpm log level parameter Date: Thu, 4 Jul 2024 12:47:39 +0100 Message-ID: <20240704114739.2873761-3-berrange@redhat.com> In-Reply-To: <20240704114739.2873761-1-berrange@redhat.com> References: <20240704114739.2873761-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 4266SYGIFTQRP7ZFFPDBJXG64SC5WXAX X-Message-ID-Hash: 4266SYGIFTQRP7ZFFPDBJXG64SC5WXAX X-MailFrom: berrange@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1720093743177100001 Content-Type: text/plain; charset="utf-8" This wires up the emulator 'debug' parameter to control the /usr/bin/swtpm 'level' parameter for logging. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/qemu/qemu_tpm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index bf0c6bcb0d..2f17918cbb 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -611,7 +611,11 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, tpm->data.emulator.storagepath); =20 virCommandAddArg(cmd, "--log"); - virCommandAddArgFormat(cmd, "file=3D%s", tpm->data.emulator.logfile); + if (tpm->data.emulator.debug !=3D 0) + virCommandAddArgFormat(cmd, "file=3D%s,level=3D%u", tpm->data.emul= ator.logfile, + tpm->data.emulator.debug); + else + virCommandAddArgFormat(cmd, "file=3D%s", tpm->data.emulator.logfil= e); =20 virCommandAddArg(cmd, "--terminate"); =20 --=20 2.45.1