tpm: rename 'storagepath' to 'source_path'

Mechanically replace existing 'storagepath' with 'source_path', as the
following patches introduce <source path='..'> configuration.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Marc-André Lureau 2024-10-22 18:15:17 +04:00 committed by Martin Kletzander
parent cc0aab9395
commit 6d4eb07a55
4 changed files with 28 additions and 28 deletions

View File

@ -3461,7 +3461,7 @@ void virDomainTPMDefFree(virDomainTPMDef *def)
break; break;
case VIR_DOMAIN_TPM_TYPE_EMULATOR: case VIR_DOMAIN_TPM_TYPE_EMULATOR:
virObjectUnref(def->data.emulator.source); virObjectUnref(def->data.emulator.source);
g_free(def->data.emulator.storagepath); g_free(def->data.emulator.source_path);
g_free(def->data.emulator.logfile); g_free(def->data.emulator.logfile);
virBitmapFree(def->data.emulator.activePcrBanks); virBitmapFree(def->data.emulator.activePcrBanks);
break; break;

View File

@ -1478,7 +1478,7 @@ struct _virDomainTPMDef {
struct { struct {
virDomainTPMVersion version; virDomainTPMVersion version;
virDomainChrSourceDef *source; virDomainChrSourceDef *source;
char *storagepath; char *source_path;
char *logfile; char *logfile;
unsigned int debug; unsigned int debug;
unsigned char secretuuid[VIR_UUID_BUFLEN]; unsigned char secretuuid[VIR_UUID_BUFLEN];

View File

@ -173,8 +173,8 @@ qemuTPMEmulatorCreateStorage(virDomainTPMDef *tpm,
uid_t swtpm_user, uid_t swtpm_user,
gid_t swtpm_group) gid_t swtpm_group)
{ {
const char *storagepath = tpm->data.emulator.storagepath; const char *source_path = tpm->data.emulator.source_path;
g_autofree char *swtpmStorageDir = g_path_get_dirname(storagepath); g_autofree char *swtpmStorageDir = g_path_get_dirname(source_path);
/* allow others to cd into this dir */ /* allow others to cd into this dir */
if (g_mkdir_with_parents(swtpmStorageDir, 0711) < 0) { if (g_mkdir_with_parents(swtpmStorageDir, 0711) < 0) {
@ -186,19 +186,19 @@ qemuTPMEmulatorCreateStorage(virDomainTPMDef *tpm,
*created = false; *created = false;
if (!virFileExists(storagepath) || if (!virFileExists(source_path) ||
virDirIsEmpty(storagepath, true) > 0) virDirIsEmpty(source_path, true) > 0)
*created = true; *created = true;
if (virDirCreate(storagepath, 0700, swtpm_user, swtpm_group, if (virDirCreate(source_path, 0700, swtpm_user, swtpm_group,
VIR_DIR_CREATE_ALLOW_EXIST) < 0) { VIR_DIR_CREATE_ALLOW_EXIST) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not create directory %1$s as %2$u:%3$d"), _("Could not create directory %1$s as %2$u:%3$d"),
storagepath, swtpm_user, swtpm_group); source_path, swtpm_user, swtpm_group);
return -1; return -1;
} }
if (virFileChownFiles(storagepath, swtpm_user, swtpm_group) < 0) if (virFileChownFiles(source_path, swtpm_user, swtpm_group) < 0)
return -1; return -1;
return 0; return 0;
@ -214,7 +214,7 @@ qemuTPMEmulatorCreateStorage(virDomainTPMDef *tpm,
static void static void
qemuTPMEmulatorDeleteStorage(virDomainTPMDef *tpm) qemuTPMEmulatorDeleteStorage(virDomainTPMDef *tpm)
{ {
g_autofree char *path = g_path_get_dirname(tpm->data.emulator.storagepath); g_autofree char *path = g_path_get_dirname(tpm->data.emulator.source_path);
ignore_value(virFileDeleteTree(path)); ignore_value(virFileDeleteTree(path));
} }
@ -343,7 +343,7 @@ qemuTPMVirCommandAddEncryption(virCommand *cmd,
/* /*
* qemuTPMEmulatorRunSetup * qemuTPMEmulatorRunSetup
* *
* @storagepath: path to the directory for TPM state * @source_path: path to the directory for TPM state
* @vmname: the name of the VM * @vmname: the name of the VM
* @vmuuid: the UUID of the VM * @vmuuid: the UUID of the VM
* @privileged: whether we are running in privileged mode * @privileged: whether we are running in privileged mode
@ -360,7 +360,7 @@ qemuTPMVirCommandAddEncryption(virCommand *cmd,
* certificates for it. * certificates for it.
*/ */
static int static int
qemuTPMEmulatorRunSetup(const char *storagepath, qemuTPMEmulatorRunSetup(const char *source_path,
const char *vmname, const char *vmname,
const unsigned char *vmuuid, const unsigned char *vmuuid,
bool privileged, bool privileged,
@ -413,7 +413,7 @@ qemuTPMEmulatorRunSetup(const char *storagepath,
if (!incomingMigration) { if (!incomingMigration) {
virCommandAddArgList(cmd, virCommandAddArgList(cmd,
"--tpm-state", storagepath, "--tpm-state", source_path,
"--vmid", vmid, "--vmid", vmid,
"--logfile", logfile, "--logfile", logfile,
"--createek", "--createek",
@ -424,7 +424,7 @@ qemuTPMEmulatorRunSetup(const char *storagepath,
NULL); NULL);
} else { } else {
virCommandAddArgList(cmd, virCommandAddArgList(cmd,
"--tpm-state", storagepath, "--tpm-state", source_path,
"--logfile", logfile, "--logfile", logfile,
"--overwrite", "--overwrite",
NULL); NULL);
@ -465,7 +465,7 @@ qemuTPMPcrBankBitmapToStr(virBitmap *activePcrBanks)
* qemuTPMEmulatorReconfigure * 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; * @swtpm_user: The userid to switch to when setting up the TPM;
* typically this should be the uid of 'tss' or 'root' * typically this should be the uid of 'tss' or 'root'
* @swtpm_group: The group id to switch to * @swtpm_group: The group id to switch to
@ -478,7 +478,7 @@ qemuTPMPcrBankBitmapToStr(virBitmap *activePcrBanks)
* Reconfigure the active PCR banks of a TPM 2. * Reconfigure the active PCR banks of a TPM 2.
*/ */
static int static int
qemuTPMEmulatorReconfigure(const char *storagepath, qemuTPMEmulatorReconfigure(const char *source_path,
uid_t swtpm_user, uid_t swtpm_user,
gid_t swtpm_group, gid_t swtpm_group,
virBitmap *activePcrBanks, virBitmap *activePcrBanks,
@ -510,7 +510,7 @@ qemuTPMEmulatorReconfigure(const char *storagepath,
return -1; return -1;
virCommandAddArgList(cmd, virCommandAddArgList(cmd,
"--tpm-state", storagepath, "--tpm-state", source_path,
"--logfile", logfile, "--logfile", logfile,
"--pcr-banks", activePcrBanksStr, "--pcr-banks", activePcrBanksStr,
"--reconfigure", "--reconfigure",
@ -570,7 +570,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm,
/* Do not create storage and run swtpm_setup on incoming migration over /* Do not create storage and run swtpm_setup on incoming migration over
* shared storage * shared storage
*/ */
on_shared_storage = virFileIsSharedFS(tpm->data.emulator.storagepath, sharedFilesystems) == 1; on_shared_storage = virFileIsSharedFS(tpm->data.emulator.source_path, sharedFilesystems) == 1;
if (incomingMigration && on_shared_storage) if (incomingMigration && on_shared_storage)
create_storage = false; create_storage = false;
@ -582,7 +582,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm,
secretuuid = tpm->data.emulator.secretuuid; secretuuid = tpm->data.emulator.secretuuid;
if (created && if (created &&
qemuTPMEmulatorRunSetup(tpm->data.emulator.storagepath, vmname, vmuuid, qemuTPMEmulatorRunSetup(tpm->data.emulator.source_path, vmname, vmuuid,
privileged, swtpm_user, swtpm_group, privileged, swtpm_user, swtpm_group,
tpm->data.emulator.logfile, tpm->data.emulator.logfile,
tpm->data.emulator.version, tpm->data.emulator.version,
@ -590,7 +590,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm,
goto error; goto error;
if (!incomingMigration && if (!incomingMigration &&
qemuTPMEmulatorReconfigure(tpm->data.emulator.storagepath, qemuTPMEmulatorReconfigure(tpm->data.emulator.source_path,
swtpm_user, swtpm_group, swtpm_user, swtpm_group,
tpm->data.emulator.activePcrBanks, tpm->data.emulator.activePcrBanks,
tpm->data.emulator.logfile, tpm->data.emulator.logfile,
@ -610,7 +610,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm,
virCommandAddArg(cmd, "--tpmstate"); virCommandAddArg(cmd, "--tpmstate");
virCommandAddArgFormat(cmd, "dir=%s,mode=0600", virCommandAddArgFormat(cmd, "dir=%s,mode=0600",
tpm->data.emulator.storagepath); tpm->data.emulator.source_path);
virCommandAddArg(cmd, "--log"); virCommandAddArg(cmd, "--log");
if (tpm->data.emulator.debug != 0) if (tpm->data.emulator.debug != 0)
@ -723,8 +723,8 @@ qemuTPMEmulatorInitPaths(virDomainTPMDef *tpm,
virUUIDFormat(uuid, uuidstr); virUUIDFormat(uuid, uuidstr);
if (!tpm->data.emulator.storagepath && if (!tpm->data.emulator.source_path &&
!(tpm->data.emulator.storagepath = !(tpm->data.emulator.source_path =
qemuTPMEmulatorStorageBuildPath(swtpmStorageDir, uuidstr, qemuTPMEmulatorStorageBuildPath(swtpmStorageDir, uuidstr,
tpm->data.emulator.version))) tpm->data.emulator.version)))
return -1; return -1;
@ -759,7 +759,7 @@ qemuTPMEmulatorCleanupHost(virQEMUDriver *driver,
* storage. * storage.
*/ */
if (outgoingMigration && if (outgoingMigration &&
virFileIsSharedFS(tpm->data.emulator.storagepath, cfg->sharedFilesystems) == 1) virFileIsSharedFS(tpm->data.emulator.source_path, cfg->sharedFilesystems) == 1)
return; return;
/* /*
@ -1040,7 +1040,7 @@ qemuTPMHasSharedStorage(virQEMUDriver *driver,
switch (tpm->type) { switch (tpm->type) {
case VIR_DOMAIN_TPM_TYPE_EMULATOR: case VIR_DOMAIN_TPM_TYPE_EMULATOR:
return virFileIsSharedFS(tpm->data.emulator.storagepath, return virFileIsSharedFS(tpm->data.emulator.source_path,
cfg->sharedFilesystems) == 1; cfg->sharedFilesystems) == 1;
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
case VIR_DOMAIN_TPM_TYPE_EXTERNAL: case VIR_DOMAIN_TPM_TYPE_EXTERNAL:

View File

@ -3726,7 +3726,7 @@ virSecuritySELinuxSetTPMLabels(virSecurityManager *mgr,
if (setTPMStateLabel) { if (setTPMStateLabel) {
ret = virSecuritySELinuxSetFileLabels(mgr, ret = virSecuritySELinuxSetFileLabels(mgr,
def->tpms[i]->data.emulator.storagepath, def->tpms[i]->data.emulator.source_path,
seclabel); seclabel);
} }
@ -3756,14 +3756,14 @@ virSecuritySELinuxRestoreTPMLabels(virSecurityManager *mgr,
if (restoreTPMStateLabel) { if (restoreTPMStateLabel) {
ret = virSecuritySELinuxRestoreFileLabels(mgr, ret = virSecuritySELinuxRestoreFileLabels(mgr,
def->tpms[i]->data.emulator.storagepath); def->tpms[i]->data.emulator.source_path);
} else { } else {
/* Even if we're not restoring the original label for the /* Even if we're not restoring the original label for the
* TPM state directory, we should still forget any * TPM state directory, we should still forget any
* remembered label so that a subsequent attempt at TPM * remembered label so that a subsequent attempt at TPM
* startup will not fail due to the state directory being * startup will not fail due to the state directory being
* considered as still in use */ * considered as still in use */
virSecuritySELinuxForgetLabels(def->tpms[i]->data.emulator.storagepath); virSecuritySELinuxForgetLabels(def->tpms[i]->data.emulator.source_path);
} }
if (ret == 0 && if (ret == 0 &&