uid_t swtpm_user,
gid_t swtpm_group)
{
- const char *storagepath = tpm->data.emulator.storagepath;
- g_autofree char *swtpmStorageDir = g_path_get_dirname(storagepath);
+ const char *source_path = tpm->data.emulator.source_path;
+ g_autofree char *swtpmStorageDir = g_path_get_dirname(source_path);
/* allow others to cd into this dir */
if (g_mkdir_with_parents(swtpmStorageDir, 0711) < 0) {
*created = false;
- if (!virFileExists(storagepath) ||
- virDirIsEmpty(storagepath, true) > 0)
+ if (!virFileExists(source_path) ||
+ virDirIsEmpty(source_path, true) > 0)
*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) {
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;
}
- if (virFileChownFiles(storagepath, swtpm_user, swtpm_group) < 0)
+ if (virFileChownFiles(source_path, swtpm_user, swtpm_group) < 0)
return -1;
return 0;
static void
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));
}
/*
* 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
* certificates for it.
*/
static int
-qemuTPMEmulatorRunSetup(const char *storagepath,
+qemuTPMEmulatorRunSetup(const char *source_path,
const char *vmname,
const unsigned char *vmuuid,
bool privileged,
if (!incomingMigration) {
virCommandAddArgList(cmd,
- "--tpm-state", storagepath,
+ "--tpm-state", source_path,
"--vmid", vmid,
"--logfile", logfile,
"--createek",
NULL);
} else {
virCommandAddArgList(cmd,
- "--tpm-state", storagepath,
+ "--tpm-state", source_path,
"--logfile", logfile,
"--overwrite",
NULL);
* 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
* 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,
return -1;
virCommandAddArgList(cmd,
- "--tpm-state", storagepath,
+ "--tpm-state", source_path,
"--logfile", logfile,
"--pcr-banks", activePcrBanksStr,
"--reconfigure",
/* Do not create storage and run swtpm_setup on incoming migration over
* 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)
create_storage = false;
secretuuid = tpm->data.emulator.secretuuid;
if (created &&
- qemuTPMEmulatorRunSetup(tpm->data.emulator.storagepath, vmname, vmuuid,
+ qemuTPMEmulatorRunSetup(tpm->data.emulator.source_path, vmname, vmuuid,
privileged, swtpm_user, swtpm_group,
tpm->data.emulator.logfile,
tpm->data.emulator.version,
goto error;
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,
virCommandAddArg(cmd, "--tpmstate");
virCommandAddArgFormat(cmd, "dir=%s,mode=0600",
- tpm->data.emulator.storagepath);
+ tpm->data.emulator.source_path);
virCommandAddArg(cmd, "--log");
if (tpm->data.emulator.debug != 0)
virUUIDFormat(uuid, uuidstr);
- if (!tpm->data.emulator.storagepath &&
- !(tpm->data.emulator.storagepath =
+ if (!tpm->data.emulator.source_path &&
+ !(tpm->data.emulator.source_path =
qemuTPMEmulatorStorageBuildPath(swtpmStorageDir, uuidstr,
tpm->data.emulator.version)))
return -1;
* storage.
*/
if (outgoingMigration &&
- virFileIsSharedFS(tpm->data.emulator.storagepath, cfg->sharedFilesystems) == 1)
+ virFileIsSharedFS(tpm->data.emulator.source_path, cfg->sharedFilesystems) == 1)
return;
/*
switch (tpm->type) {
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
- return virFileIsSharedFS(tpm->data.emulator.storagepath,
+ return virFileIsSharedFS(tpm->data.emulator.source_path,
cfg->sharedFilesystems) == 1;
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
case VIR_DOMAIN_TPM_TYPE_EXTERNAL: