virDomainDefPtr def = vm->def;
size_t i;
+ if (qemuExtDevicesInitPaths(driver, def) < 0)
+ return -1;
+
if (def->ntpms > 0 &&
qemuExtTPMPrepareHost(driver, def) < 0)
return -1;
virDomainDefPtr def = vm->def;
size_t i;
- if (qemuExtDevicesInitPaths(driver, def) < 0)
- return -1;
-
for (i = 0; i < def->nvideos; i++) {
virDomainVideoDefPtr video = def->videos[i];
* @tpm: TPM definition for an emulator type
* @swtpmStorageDir: the general swtpm storage dir which is used as a base
* directory for creating VM specific directories
+ * @logDir: directory where swtpm writes its logs into
+ * @vmname: name of the VM
* @uuid: the UUID of the VM
*/
static int
qemuTPMEmulatorInitPaths(virDomainTPMDefPtr tpm,
const char *swtpmStorageDir,
+ const char *logDir,
+ const char *vmname,
const unsigned char *uuid)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
tpm->version)))
return -1;
+ if (!tpm->data.emulator.logfile) {
+ tpm->data.emulator.logfile = qemuTPMCreateEmulatorLogPath(logDir,
+ vmname);
+ }
+
return 0;
}
*
* @tpm: tpm definition
* @logDir: directory where swtpm writes its logs into
- * @vmname: name of the VM
* @swtpm_user: uid to run the swtpm with
* @swtpm_group: gid to run the swtpm with
* @swtpmStateDir: directory for swtpm's persistent state
static int
qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
const char *logDir,
- const char *vmname,
uid_t swtpm_user,
gid_t swtpm_group,
const char *swtpmStateDir,
VIR_DIR_CREATE_ALLOW_EXIST) < 0)
return -1;
- /* create logfile name ... */
- if (!tpm->data.emulator.logfile)
- tpm->data.emulator.logfile = qemuTPMCreateEmulatorLogPath(logDir, vmname);
-
if (!virFileExists(tpm->data.emulator.logfile) &&
virFileTouch(tpm->data.emulator.logfile, 0644) < 0) {
return -1;
if (def->tpms[i]->type != VIR_DOMAIN_TPM_TYPE_EMULATOR)
continue;
- return qemuTPMEmulatorInitPaths(def->tpms[i], cfg->swtpmStorageDir,
+ return qemuTPMEmulatorInitPaths(def->tpms[i],
+ cfg->swtpmStorageDir,
+ cfg->swtpmLogDir,
+ def->name,
def->uuid);
}
return -1;
return qemuTPMEmulatorPrepareHost(def->tpms[i], cfg->swtpmLogDir,
- def->name, cfg->swtpm_user,
+ cfg->swtpm_user,
cfg->swtpm_group,
cfg->swtpmStateDir, cfg->user,
shortName);