From nobody Wed Dec 4 09:10:51 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=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 1731519869235663.2943555740861; Wed, 13 Nov 2024 09:44:29 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3D94517CB; Wed, 13 Nov 2024 12:44:28 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id F2307198D; Wed, 13 Nov 2024 12:40:26 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id F26EE174F; Wed, 13 Nov 2024 12:40:15 -0500 (EST) 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 CAECD17DD for ; Wed, 13 Nov 2024 12:40:07 -0500 (EST) 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 4ADE9o8x021911; Wed, 13 Nov 2024 17:40:06 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 42vwmqh0ef-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Nov 2024 17:40:06 +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 4ADFCa6B007703; Wed, 13 Nov 2024 17:40:05 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 42tm9jehnr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Nov 2024 17:40:05 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4ADHe4tD24904424 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Nov 2024 17:40:05 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AAAD858065; Wed, 13 Nov 2024 17:40:04 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EE445805E; Wed, 13 Nov 2024 17:40:04 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Nov 2024 17:40:04 +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.5 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,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,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=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=HTu5Vgq5s22SnMKTn tYaUal6L82wOe845EfXuXcXZa0=; b=URhU9y4mzg7qmr0tc+pBwjaQxNueZ+TAH syi9Vhz3Wkb65xlmqTKMXP/JkX5WvMzJ8MWcHxSUHxU6maPhRlINZ2logvXMjtsc 0K/3vK76ZcBcYsRmaO2B0b/5WEdkwvlpdS3/Q6UI4jdtE+QnmES5mnmJR5N+6EMz sV57hffd6LEyq/sQ1sywTZiP5vIwHGHp77aXWDNTlsBW2ExTkBK+81XUDqyQ55NF BjJw9XwhmmoHG303ugWs6QGnpwyx8SEcCpLMbuqCmh3vJbZ1Yf2nZy6dzbON0oKt EhoDKW6ygwlv3GGybYzWCfilpMdgIBua+WLLRfV7GdszGKNmleOZg== From: Stefan Berger To: devel@lists.libvirt.org Subject: [PATCH v4 10/11] qemu: Move adding --tpmstate to swtpm command line into own function Date: Wed, 13 Nov 2024 12:39:50 -0500 Message-ID: <20241113173951.813781-11-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241113173951.813781-1-stefanb@linux.ibm.com> References: <20241113173951.813781-1-stefanb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: pDZHR3FdeJ5bbnaQBe4zHz9Z9YAbND0V X-Proofpoint-GUID: pDZHR3FdeJ5bbnaQBe4zHz9Z9YAbND0V X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 mlxscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411130146 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: H7MKO76W5FZ7EARMMVFSYFMBN7XUXUZW X-Message-ID-Hash: H7MKO76W5FZ7EARMMVFSYFMBN7XUXUZW 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: 1731519869479116600 Content-Type: text/plain; charset="utf-8" Factor-out code related to adding the --tpmstate option to the swtpm command line into its own function. Signed-off-by: Stefan Berger --- src/qemu/qemu_tpm.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index bf07b86793..a7eee501bf 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -608,6 +608,25 @@ qemuTPMVirCommandSwtpmAddEncryption(virCommand *cmd, return 0; } =20 +static void +qemuTPMVirCommandSwtpmAddTPMState(virCommand *cmd, + const virDomainTPMEmulatorDef *emulator) +{ + virCommandAddArg(cmd, "--tpmstate"); + switch (emulator->source_type) { + case VIR_DOMAIN_TPM_SOURCE_TYPE_FILE: + virCommandAddArgFormat(cmd, "backend-uri=3Dfile://%s", + emulator->source_path); + break; + case VIR_DOMAIN_TPM_SOURCE_TYPE_DIR: + case VIR_DOMAIN_TPM_SOURCE_TYPE_DEFAULT: + case VIR_DOMAIN_TPM_SOURCE_TYPE_LAST: + virCommandAddArgFormat(cmd, "dir=3D%s,mode=3D0600", + emulator->source_path); + break; + } +} + /* * qemuTPMEmulatorBuildCommand: * @@ -691,19 +710,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, virCommandAddArgFormat(cmd, "type=3Dunixio,path=3D%s,mode=3D0600", tpm->data.emulator.source->data.nix.path); =20 - virCommandAddArg(cmd, "--tpmstate"); - switch (tpm->data.emulator.source_type) { - case VIR_DOMAIN_TPM_SOURCE_TYPE_FILE: - virCommandAddArgFormat(cmd, "backend-uri=3Dfile://%s", - tpm->data.emulator.source_path); - break; - case VIR_DOMAIN_TPM_SOURCE_TYPE_DIR: - case VIR_DOMAIN_TPM_SOURCE_TYPE_DEFAULT: - case VIR_DOMAIN_TPM_SOURCE_TYPE_LAST: - virCommandAddArgFormat(cmd, "dir=3D%s,mode=3D0600", - tpm->data.emulator.source_path); - break; - } + qemuTPMVirCommandSwtpmAddTPMState(cmd, &tpm->data.emulator); =20 virCommandAddArg(cmd, "--log"); if (tpm->data.emulator.debug !=3D 0) --=20 2.47.0