From nobody Sat Feb 7 11:27:55 2026 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=reject dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1726765382212675.8478408409377; Thu, 19 Sep 2024 10:03:02 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id AC8BE1599; Thu, 19 Sep 2024 13:02:58 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 92179167A; Thu, 19 Sep 2024 13:00:56 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7D147163E; Thu, 19 Sep 2024 13:00:52 -0400 (EDT) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 CD3E9146B for ; Thu, 19 Sep 2024 13:00:45 -0400 (EDT) Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48JEPKr2030695 for ; Thu, 19 Sep 2024 17:00:45 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41n3udmum1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 19 Sep 2024 17:00:44 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 48JH0i9u021204 for ; Thu, 19 Sep 2024 17:00:44 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41n3udmukx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Sep 2024 17:00:44 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 48JDkqLC024395; Thu, 19 Sep 2024 17:00:43 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 41nq1nab7d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Sep 2024 17:00:43 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 48JH0gF938404418 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Sep 2024 17:00:43 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D58458066; Thu, 19 Sep 2024 17:00:42 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0FE3558065; Thu, 19 Sep 2024 17:00:42 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 19 Sep 2024 17:00:41 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,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=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=ySb7u54Z6yDnT pGFa5FXFmSZ8ipLeDz3yLjzFrvNtqw=; b=Aty5h1l8TV061yjNLNbk7KLE+BZwe udz5IhAWYgiRQGyw2idCNL+uXS5lVXlz07kwVXr97YBUZI1HmtVNrRmruoHLNP0n E5LhfbilipLKwDN/VPMMbm6dqH1vpTYS1SZVFRpfskDk30cHodLnT7Xej2Z+89JK ucwTNYDR9xP6KxfhxLLQXa1M25dnDyHu5k7tM8pZ+2F1h4u0HtL4QJKpLzZ8zDYh Gq1AAYiuHwoInK97jQjTs4NSm1qMH5PXeOxFHvj5rGshfKzDOC/gjHpl5b49r+gV oRRb1XRSGgTEoUhvnQpbjxqHygWAKkt2hBcIPHVL+BqszprUYnfQMEEiA== From: Stefan Berger To: devel@lists.libvirt.org Subject: [RFC PATCH v1 6/6] qemu: Run swtpm_setup with --profile option if profile given Date: Thu, 19 Sep 2024 13:00:36 -0400 Message-ID: <20240919170036.1970886-7-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240919170036.1970886-1-stefanb@linux.ibm.com> References: <20240919170036.1970886-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: FrPKfuDcvoIEu99iXjxcpaGqQg0rvcjF X-Proofpoint-ORIG-GUID: aBgW-bTCmKSTTNfjcSVS-XJ071TGj8fI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-19_14,2024-09-19_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 phishscore=0 impostorscore=0 spamscore=0 priorityscore=1501 suspectscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=935 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409190112 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: EEIXUWRWG5UX22KBGIAHVVRUDUYTQUNS X-Message-ID-Hash: EEIXUWRWG5UX22KBGIAHVVRUDUYTQUNS X-MailFrom: stefanb@linux.ibm.com X-Mailman-Rule-Hits: nonmember-moderation 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 CC: marcandre.lureau@redhat.com, Stefan Berger 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: 1726765384276116600 Content-Type: text/plain; charset="utf-8" Runs swtpm_setup with the --profile option if the user provided a profile and swtpm_setup supports the option. Also use the --profile-remove-disabled option if the user provided a value in the remove_disabled attribute in the profile XML node. Signed-off-by: Stefan Berger --- src/qemu/qemu_tpm.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 2f17918cbb..ec0e456163 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -355,6 +355,8 @@ qemuTPMVirCommandAddEncryption(virCommand *cmd, * @tpmversion: The version of the TPM, either a TPM 1.2 or TPM 2 * @encryption: pointer to virStorageEncryption holding secret * @incomingMigration: whether we have an incoming migration + * @profile: optional TPM 2 profile + * @profile_remove_disabled: value for remove_disabled option parameter * * Setup the external swtpm by creating endorsement key and * certificates for it. @@ -369,7 +371,9 @@ qemuTPMEmulatorRunSetup(const char *storagepath, const char *logfile, const virDomainTPMVersion tpmversion, const unsigned char *secretuuid, - bool incomingMigration) + bool incomingMigration, + const char *profile, + const char *profile_remove_disabled) { g_autoptr(virCommand) cmd =3D NULL; int exitstatus; @@ -422,6 +426,22 @@ qemuTPMEmulatorRunSetup(const char *storagepath, "--lock-nvram", "--not-overwrite", NULL); + if (profile) { + if (!virTPMSwtpmSetupCapsGet( + VIR_TPM_SWTPM_SETUP_FEATURE_CMDARG_PROFILE)) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("swtpm_setup has no support for profiles"= )); + return -1; + } + virCommandAddArgList(cmd, + "--profile", profile, + NULL); + if (profile_remove_disabled) + virCommandAddArgList(cmd, + "--profile-remove-disable", + profile_remove_disabled, + NULL); + } } else { virCommandAddArgList(cmd, "--tpm-state", storagepath, @@ -584,7 +604,9 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, privileged, swtpm_user, swtpm_group, tpm->data.emulator.logfile, tpm->data.emulator.version, - secretuuid, incomingMigration) < 0) + secretuuid, incomingMigration, + tpm->data.emulator.profile, + tpm->data.emulator.profile_remove_disabled= ) < 0) goto error; =20 if (!incomingMigration && --=20 2.46.0