From nobody Mon Feb 9 03:01:43 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=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 1728048858836436.136596706012; Fri, 4 Oct 2024 06:34:18 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 9E5321576; Fri, 4 Oct 2024 09:34:17 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id B4681156E; Fri, 4 Oct 2024 09:33:32 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B17EF14FE; Fri, 4 Oct 2024 09:33:27 -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 940B0157F for ; Fri, 4 Oct 2024 09:33:19 -0400 (EDT) Received: from mx-prod-mc-03.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-467-yOD1hEngNmqjOP-fcssRWQ-1; Fri, 04 Oct 2024 09:33:15 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A462E1955F40; Fri, 4 Oct 2024 13:33:14 +0000 (UTC) Received: from localhost (unknown [10.39.208.33]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9B53C1955E93; Fri, 4 Oct 2024 13:33:13 +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.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, 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=redhat.com; s=mimecast20190719; t=1728048799; 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=+5naGcxz4mJd/t0x2Vz6cgiMYvxkkOEUEROCzj7aMxg=; b=dh8SrHqkdz9sOPpQ7QtWhzINZn7kD/oKwnsuTHEHpsEjoa7yVX2W6H3sm1W+ziMkrczpZW Y8qbQUMZARRv645JtY/xo3zeAHuQoDdSPpRty931HUSE3eVekeGI+1/+lWxjXhqgnF8rID OArBRds6A32ZnTj6bvd2qYA8vDQCb44= X-MC-Unique: yOD1hEngNmqjOP-fcssRWQ-1 From: marcandre.lureau@redhat.com To: devel@lists.libvirt.org Subject: [PATCH v3 2/5] tpm: rename 'storagepath' to 'source_path' Date: Fri, 4 Oct 2024 17:32:57 +0400 Message-ID: <20241004133300.166245-3-marcandre.lureau@redhat.com> In-Reply-To: <20241004133300.166245-1-marcandre.lureau@redhat.com> References: <20241004133300.166245-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: S2F7Q3HIQDZ7VFEPVAPVASWRQTKSK4C2 X-Message-ID-Hash: S2F7Q3HIQDZ7VFEPVAPVASWRQTKSK4C2 X-MailFrom: marcandre.lureau@redhat.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: mkletzan@redhat.com, stefanb@us.ibm.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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: 1728048859818116600 Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau Mechanically replace existing 'storagepath' with 'source_path', as the following patches introduce configuration. Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 2 +- src/qemu/qemu_tpm.c | 48 ++++++++++++++++----------------- src/security/security_selinux.c | 4 +-- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6d7dee7956..284a3815b3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3461,7 +3461,7 @@ void virDomainTPMDefFree(virDomainTPMDef *def) break; case VIR_DOMAIN_TPM_TYPE_EMULATOR: virObjectUnref(def->data.emulator.source); - g_free(def->data.emulator.storagepath); + g_free(def->data.emulator.source_path); g_free(def->data.emulator.logfile); virBitmapFree(def->data.emulator.activePcrBanks); break; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a15af4fae3..6b27322e3e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1478,7 +1478,7 @@ struct _virDomainTPMDef { struct { virDomainTPMVersion version; virDomainChrSourceDef *source; - char *storagepath; + char *source_path; char *logfile; unsigned int debug; unsigned char secretuuid[VIR_UUID_BUFLEN]; diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 2f17918cbb..fd633c7005 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -173,8 +173,8 @@ qemuTPMEmulatorCreateStorage(virDomainTPMDef *tpm, uid_t swtpm_user, gid_t swtpm_group) { - const char *storagepath =3D tpm->data.emulator.storagepath; - g_autofree char *swtpmStorageDir =3D g_path_get_dirname(storagepath); + const char *source_path =3D tpm->data.emulator.source_path; + g_autofree char *swtpmStorageDir =3D g_path_get_dirname(source_path); =20 /* allow others to cd into this dir */ if (g_mkdir_with_parents(swtpmStorageDir, 0711) < 0) { @@ -186,19 +186,19 @@ qemuTPMEmulatorCreateStorage(virDomainTPMDef *tpm, =20 *created =3D false; =20 - if (!virFileExists(storagepath) || - virDirIsEmpty(storagepath, true) > 0) + if (!virFileExists(source_path) || + virDirIsEmpty(source_path, true) > 0) *created =3D true; =20 - if (virDirCreate(storagepath, 0700, swtpm_user, swtpm_group, + if (virDirCreate(source_path, 0700, swtpm_user, swtpm_group, VIR_DIR_CREATE_ALLOW_EXIST) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not create directory %1$s as %2$u:%3$d"), - storagepath, swtpm_user, swtpm_group); + source_path, swtpm_user, swtpm_group); return -1; } =20 - if (virFileChownFiles(storagepath, swtpm_user, swtpm_group) < 0) + if (virFileChownFiles(source_path, swtpm_user, swtpm_group) < 0) return -1; =20 return 0; @@ -214,7 +214,7 @@ qemuTPMEmulatorCreateStorage(virDomainTPMDef *tpm, static void qemuTPMEmulatorDeleteStorage(virDomainTPMDef *tpm) { - g_autofree char *path =3D g_path_get_dirname(tpm->data.emulator.storag= epath); + g_autofree char *path =3D g_path_get_dirname(tpm->data.emulator.source= _path); =20 ignore_value(virFileDeleteTree(path)); } @@ -343,7 +343,7 @@ qemuTPMVirCommandAddEncryption(virCommand *cmd, /* * qemuTPMEmulatorRunSetup * - * @storagepath: path to the directory for TPM state + * @source_path: path to the directory for TPM state * @vmname: the name of the VM * @vmuuid: the UUID of the VM * @privileged: whether we are running in privileged mode @@ -360,7 +360,7 @@ qemuTPMVirCommandAddEncryption(virCommand *cmd, * certificates for it. */ static int -qemuTPMEmulatorRunSetup(const char *storagepath, +qemuTPMEmulatorRunSetup(const char *source_path, const char *vmname, const unsigned char *vmuuid, bool privileged, @@ -413,7 +413,7 @@ qemuTPMEmulatorRunSetup(const char *storagepath, =20 if (!incomingMigration) { virCommandAddArgList(cmd, - "--tpm-state", storagepath, + "--tpm-state", source_path, "--vmid", vmid, "--logfile", logfile, "--createek", @@ -424,7 +424,7 @@ qemuTPMEmulatorRunSetup(const char *storagepath, NULL); } else { virCommandAddArgList(cmd, - "--tpm-state", storagepath, + "--tpm-state", source_path, "--logfile", logfile, "--overwrite", NULL); @@ -465,7 +465,7 @@ qemuTPMPcrBankBitmapToStr(virBitmap *activePcrBanks) * qemuTPMEmulatorReconfigure * * - * @storagepath: path to the directory for TPM state + * @source_path: 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 @@ -478,7 +478,7 @@ qemuTPMPcrBankBitmapToStr(virBitmap *activePcrBanks) * Reconfigure the active PCR banks of a TPM 2. */ static int -qemuTPMEmulatorReconfigure(const char *storagepath, +qemuTPMEmulatorReconfigure(const char *source_path, uid_t swtpm_user, gid_t swtpm_group, virBitmap *activePcrBanks, @@ -510,7 +510,7 @@ qemuTPMEmulatorReconfigure(const char *storagepath, return -1; =20 virCommandAddArgList(cmd, - "--tpm-state", storagepath, + "--tpm-state", source_path, "--logfile", logfile, "--pcr-banks", activePcrBanksStr, "--reconfigure", @@ -568,7 +568,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, /* Do not create storage and run swtpm_setup on incoming migration over * shared storage */ - on_shared_storage =3D virFileIsSharedFS(tpm->data.emulator.storagepath= ) =3D=3D 1; + on_shared_storage =3D virFileIsSharedFS(tpm->data.emulator.source_path= ) =3D=3D 1; if (incomingMigration && on_shared_storage) create_storage =3D false; =20 @@ -580,7 +580,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, secretuuid =3D tpm->data.emulator.secretuuid; =20 if (created && - qemuTPMEmulatorRunSetup(tpm->data.emulator.storagepath, vmname, vm= uuid, + qemuTPMEmulatorRunSetup(tpm->data.emulator.source_path, vmname, vm= uuid, privileged, swtpm_user, swtpm_group, tpm->data.emulator.logfile, tpm->data.emulator.version, @@ -588,7 +588,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, goto error; =20 if (!incomingMigration && - qemuTPMEmulatorReconfigure(tpm->data.emulator.storagepath, + qemuTPMEmulatorReconfigure(tpm->data.emulator.source_path, swtpm_user, swtpm_group, tpm->data.emulator.activePcrBanks, tpm->data.emulator.logfile, @@ -608,7 +608,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, =20 virCommandAddArg(cmd, "--tpmstate"); virCommandAddArgFormat(cmd, "dir=3D%s,mode=3D0600", - tpm->data.emulator.storagepath); + tpm->data.emulator.source_path); =20 virCommandAddArg(cmd, "--log"); if (tpm->data.emulator.debug !=3D 0) @@ -721,8 +721,8 @@ qemuTPMEmulatorInitPaths(virDomainTPMDef *tpm, =20 virUUIDFormat(uuid, uuidstr); =20 - if (!tpm->data.emulator.storagepath && - !(tpm->data.emulator.storagepath =3D + if (!tpm->data.emulator.source_path && + !(tpm->data.emulator.source_path =3D qemuTPMEmulatorStorageBuildPath(swtpmStorageDir, uuidstr, tpm->data.emulator.version))) return -1; @@ -753,7 +753,7 @@ qemuTPMEmulatorCleanupHost(virDomainTPMDef *tpm, * storage. */ if (outgoingMigration && - virFileIsSharedFS(tpm->data.emulator.storagepath) =3D=3D 1) + virFileIsSharedFS(tpm->data.emulator.source_path) =3D=3D 1) return; =20 /* @@ -954,7 +954,7 @@ qemuTPMEmulatorStart(virQEMUDriver *driver, virCommandSetErrorFD(cmd, &errfd); =20 if (incomingMigration && - virFileIsSharedFS(tpm->data.emulator.storagepath) =3D=3D 1) { + virFileIsSharedFS(tpm->data.emulator.source_path) =3D=3D 1) { /* security labels must have been set up on source already */ setTPMStateLabel =3D false; } @@ -1023,7 +1023,7 @@ qemuTPMHasSharedStorage(virDomainDef *def) =20 switch (tpm->type) { case VIR_DOMAIN_TPM_TYPE_EMULATOR: - return virFileIsSharedFS(tpm->data.emulator.storagepath) =3D= =3D 1; + return virFileIsSharedFS(tpm->data.emulator.source_path) =3D= =3D 1; case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: case VIR_DOMAIN_TPM_TYPE_EXTERNAL: case VIR_DOMAIN_TPM_TYPE_LAST: diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 31df4d22db..470a73e740 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -3640,7 +3640,7 @@ virSecuritySELinuxSetTPMLabels(virSecurityManager *mg= r, =20 if (setTPMStateLabel) { ret =3D virSecuritySELinuxSetFileLabels(mgr, - def->tpms[i]->data.emula= tor.storagepath, + def->tpms[i]->data.emula= tor.source_path, seclabel); } =20 @@ -3670,7 +3670,7 @@ virSecuritySELinuxRestoreTPMLabels(virSecurityManager= *mgr, =20 if (restoreTPMStateLabel) { ret =3D virSecuritySELinuxRestoreFileLabels(mgr, - def->tpms[i]->data.e= mulator.storagepath); + def->tpms[i]->data.e= mulator.source_path); } =20 if (ret =3D=3D 0 && --=20 2.45.2.827.g557ae147e6