From nobody Sat Feb 7 14:29:05 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 1727379223522599.1334315974715; Thu, 26 Sep 2024 12:33:43 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4E6D713E5; Thu, 26 Sep 2024 15:33:38 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 695B412F8; Thu, 26 Sep 2024 15:32:23 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id DE0E112A8; Thu, 26 Sep 2024 15:32:16 -0400 (EDT) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 CD30112AD for ; Thu, 26 Sep 2024 15:32:15 -0400 (EDT) Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48QESNbQ018950 for ; Thu, 26 Sep 2024 19:32:15 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41skjs04hf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 26 Sep 2024 19:32:15 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 48QJWEeX000332 for ; Thu, 26 Sep 2024 19:32:14 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 41skjs04hc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2024 19:32:14 +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 48QIrcYK005816; Thu, 26 Sep 2024 19:32:14 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 41tapmrs8n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2024 19:32:13 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 48QJWDDH26870358 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Sep 2024 19:32:13 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3B14758059; Thu, 26 Sep 2024 19:32:13 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BEDC958053; Thu, 26 Sep 2024 19:32:12 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 26 Sep 2024 19:32:12 +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=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=yjOwD1cIKvaiv oVXfWOEdHZ/gDw91Wa8Eo3GA/dHDJA=; b=tr+ZVG2fypIMsAACX1mLTHdLNEFbG xWvU0axN/6CTa2dPXw3C356qsLkrEZoxnrO7evp+H9p8VwU4/1L5G547j3MNWY/u 5jGhMmrPNLDmSsFE6FaYMmWgNExk0zbO0yEa5oIriXr6vl3WmquPu/jQpBUmMOKr EVuoDam6F75yDNUdv4jkOTIhBvOHQWhi2zYRLHcx3KtE1egFF+OQJRJXhajg2gAg wKDT8F/uRMBA2qTv/Ru8SBL1CE56SRMo5xRrCzrSFJQkhh7lnj2NGZvDKAYeUX0i dQNZjTGD1D6JW9CCfSBlZ7ZQnt3z2XunbX15LPEUZWy/IuXZg4PJP7zCQ== From: Stefan Berger To: devel@lists.libvirt.org Subject: [RFC PATCH v2 2/8] qemu: Pass virQEMUDriverConfig rather than some of its fields Date: Thu, 26 Sep 2024 15:32:02 -0400 Message-ID: <20240926193208.8192-3-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20240926193208.8192-1-stefanb@linux.ibm.com> References: <20240926193208.8192-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 2cfaqh_U7rbBIdE9g5M-cRI78E54zXPL X-Proofpoint-ORIG-GUID: _1QOydQgHW-BkbKNIFR4cLgQWxD90Tn4 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-26_04,2024-09-26_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 priorityscore=1501 spamscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 clxscore=1011 malwarescore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409260135 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: XCMLAIYG3BH5LDJWV5E5RYO4E3UVV5KI X-Message-ID-Hash: XCMLAIYG3BH5LDJWV5E5RYO4E3UVV5KI 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: 1727379225011116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Stefan Berger Reviewed-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_tpm.c | 47 +++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 592fcc62fa..e8e7e8b5c1 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -347,9 +347,7 @@ qemuTPMVirCommandAddEncryption(virCommand *cmd, * @vmname: the name of the VM * @vmuuid: the UUID of the VM * @privileged: whether we are running in privileged mode - * @swtpm_user: The userid to switch to when setting up the TPM; - * typically this should be the uid of 'tss' or 'root' - * @swtpm_group: The group id to switch to + * @cfg: virQEMUDriverConfig * @emulator: emulator parameters * @secretuuid: UUID describing virStorageEncryption holding secret * @incomingMigration: whether we have an incoming migration @@ -362,8 +360,7 @@ qemuTPMEmulatorRunSetup(const char *storagepath, const char *vmname, const unsigned char *vmuuid, bool privileged, - uid_t swtpm_user, - gid_t swtpm_group, + const virQEMUDriverConfig *cfg, const virDomainTPMEmulatorDef *emulator, const unsigned char *secretuuid, bool incomingMigration) @@ -391,8 +388,8 @@ qemuTPMEmulatorRunSetup(const char *storagepath, virUUIDFormat(vmuuid, uuid); vmid =3D g_strdup_printf("%s:%s", vmname, uuid); =20 - virCommandSetUID(cmd, swtpm_user); - virCommandSetGID(cmd, swtpm_group); + virCommandSetUID(cmd, cfg->swtpm_user); /* should be uid of 'tss' or '= root' */ + virCommandSetGID(cmd, cfg->swtpm_group); =20 switch (emulator->version) { case VIR_DOMAIN_TPM_VERSION_1_2: @@ -463,9 +460,7 @@ qemuTPMPcrBankBitmapToStr(virBitmap *activePcrBanks) * * * @storagepath: path to the directory for TPM state - * @swtpm_user: The userid to switch to when setting up the TPM; - * typically this should be the uid of 'tss' or 'root' - * @swtpm_group: The group id to switch to + * @cfg: virQEMUDriverConfig * @emulator: emulator parameters * @secretuuid: The secret's UUID needed for state encryption * @@ -473,8 +468,7 @@ qemuTPMPcrBankBitmapToStr(virBitmap *activePcrBanks) */ static int qemuTPMEmulatorReconfigure(const char *storagepath, - uid_t swtpm_user, - gid_t swtpm_group, + const virQEMUDriverConfig *cfg, const virDomainTPMEmulatorDef *emulator, const unsigned char *secretuuid) { @@ -493,8 +487,8 @@ qemuTPMEmulatorReconfigure(const char *storagepath, =20 cmd =3D virCommandNew(swtpm_setup); =20 - virCommandSetUID(cmd, swtpm_user); - virCommandSetGID(cmd, swtpm_group); + virCommandSetUID(cmd, cfg->swtpm_user); /* should be uid of 'tss' or '= root' */ + virCommandSetGID(cmd, cfg->swtpm_group); =20 virCommandAddArgList(cmd, "--tpm2", NULL); =20 @@ -528,8 +522,7 @@ qemuTPMEmulatorReconfigure(const char *storagepath, * @vmname: The name of the VM * @vmuuid: The UUID of the VM * @privileged: whether we are running in privileged mode - * @swtpm_user: The uid for the swtpm to run as (drop privileges to from r= oot) - * @swtpm_group: The gid for the swtpm to run as + * @cfg: virQEMUDriverConfig * @incomingMigration: whether we have an incoming migration * * Create the virCommand use for starting the emulator @@ -541,8 +534,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, const char *vmname, const unsigned char *vmuuid, bool privileged, - uid_t swtpm_user, - gid_t swtpm_group, + const virQEMUDriverConfig *cfg, bool incomingMigration) { g_autoptr(virCommand) cmd =3D NULL; @@ -565,7 +557,8 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, create_storage =3D false; =20 if (create_storage && - qemuTPMEmulatorCreateStorage(tpm, &created, swtpm_user, swtpm_grou= p) < 0) + qemuTPMEmulatorCreateStorage(tpm, &created, + cfg->swtpm_user, cfg->swtpm_group) < = 0) return NULL; =20 if (tpm->data.emulator.hassecretuuid) @@ -573,16 +566,13 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, =20 if (created && qemuTPMEmulatorRunSetup(tpm->data.emulator.storagepath, vmname, vm= uuid, - privileged, swtpm_user, swtpm_group, - &tpm->data.emulator, + privileged, cfg, &tpm->data.emulator, secretuuid, incomingMigration) < 0) goto error; =20 if (!incomingMigration && - qemuTPMEmulatorReconfigure(tpm->data.emulator.storagepath, - swtpm_user, swtpm_group, - &tpm->data.emulator, - secretuuid) < 0) + qemuTPMEmulatorReconfigure(tpm->data.emulator.storagepath, cfg, + &tpm->data.emulator, secretuuid) < 0) goto error; =20 unlink(tpm->data.emulator.source->data.nix.path); @@ -608,8 +598,8 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, =20 virCommandAddArg(cmd, "--terminate"); =20 - virCommandSetUID(cmd, swtpm_user); - virCommandSetGID(cmd, swtpm_group); + virCommandSetUID(cmd, cfg->swtpm_user); + virCommandSetGID(cmd, cfg->swtpm_group); =20 switch (tpm->data.emulator.version) { case VIR_DOMAIN_TPM_VERSION_1_2: @@ -926,8 +916,7 @@ qemuTPMEmulatorStart(virQEMUDriver *driver, =20 if (!(cmd =3D qemuTPMEmulatorBuildCommand(tpm, vm->def->name, vm->def-= >uuid, driver->privileged, - cfg->swtpm_user, - cfg->swtpm_group, + cfg, incomingMigration))) return -1; =20 --=20 2.46.1