goto error;
}
- version = virXMLPropString(backends[0], "version");
- if (version &&
- (def->version = virDomainTPMVersionTypeFromString(version)) <= 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Unsupported TPM version '%s'"),
- version);
- goto error;
- }
-
switch (def->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
if (!(def->data.passthrough.source = virDomainChrSourceDefNew(xmlopt)))
def->data.passthrough.source->data.file.path = g_steal_pointer(&path);
break;
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
+ version = virXMLPropString(backends[0], "version");
+ if (version &&
+ (def->data.emulator.version = virDomainTPMVersionTypeFromString(version)) <= 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported TPM version '%s'"),
+ version);
+ goto error;
+ }
+
if (!(def->data.emulator.source = virDomainChrSourceDefNew(xmlopt)))
goto error;
secretuuid = virXPathString("string(./backend/encryption/@secret)", ctxt);
goto error;
}
}
- if (def->version == VIR_DOMAIN_TPM_VERSION_2_0) {
+ if (def->data.emulator.version == VIR_DOMAIN_TPM_VERSION_2_0) {
if ((nnodes = virXPathNodeSet("./backend/active_pcr_banks/*", ctxt, &nodes)) < 0)
break;
for (i = 0; i < nnodes; i++) {
return false;
}
- if (src->version != dst->version) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("Target TPM version doesn't match source"));
- return false;
- }
-
switch (src->type) {
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
+ if (src->data.emulator.version != dst->data.emulator.version) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Target TPM version doesn't match source"));
+ return false;
+ }
+
if (src->data.emulator.activePcrBanks != dst->data.emulator.activePcrBanks) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Target active PCR banks doesn't match source"));
def->data.passthrough.source->data.file.path);
break;
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
- if (def->version != VIR_DOMAIN_TPM_VERSION_DEFAULT) {
+ if (def->data.emulator.version != VIR_DOMAIN_TPM_VERSION_DEFAULT) {
virBufferAsprintf(&backendAttrBuf, " version='%s'",
- virDomainTPMVersionTypeToString(def->version));
+ virDomainTPMVersionTypeToString(def->data.emulator.version));
}
if (def->data.emulator.persistent_state)
virBufferAddLit(&backendAttrBuf, " persistent_state='yes'");
int type; /* virDomainTPMBackendType */
virDomainDeviceInfo info;
int model; /* virDomainTPMModel */
- int version; /* virDomainTPMVersion */
union {
struct {
virDomainChrSourceDef *source;
} passthrough;
struct {
+ int version; /* virDomainTPMVersion */
virDomainChrSourceDef *source;
char *storagepath;
char *logfile;
virDomainTPMDef *tpm = def->tpms[i];
/* TPM 1.2 and 2 are not compatible, so we choose a specific version here */
- if (tpm->version == VIR_DOMAIN_TPM_VERSION_DEFAULT) {
+ if (tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR &&
+ tpm->data.emulator.version == VIR_DOMAIN_TPM_VERSION_DEFAULT) {
if (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR ||
tpm->model == VIR_DOMAIN_TPM_MODEL_CRB ||
qemuDomainIsARMVirt(def))
- tpm->version = VIR_DOMAIN_TPM_VERSION_2_0;
+ tpm->data.emulator.version = VIR_DOMAIN_TPM_VERSION_2_0;
else
- tpm->version = VIR_DOMAIN_TPM_VERSION_1_2;
+ tpm->data.emulator.version = VIR_DOMAIN_TPM_VERSION_1_2;
}
if (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY) {
if (created &&
qemuTPMEmulatorRunSetup(tpm->data.emulator.storagepath, vmname, vmuuid,
privileged, swtpm_user, swtpm_group,
- tpm->data.emulator.logfile, tpm->version,
+ tpm->data.emulator.logfile,
+ tpm->data.emulator.version,
secretuuid, incomingMigration) < 0)
goto error;
qemuTPMEmulatorReconfigure(tpm->data.emulator.storagepath,
swtpm_user, swtpm_group,
tpm->data.emulator.activePcrBanks,
- tpm->data.emulator.logfile, tpm->version,
+ tpm->data.emulator.logfile,
+ tpm->data.emulator.version,
secretuuid) < 0)
goto error;
virCommandSetUID(cmd, swtpm_user);
virCommandSetGID(cmd, swtpm_group);
- switch (tpm->version) {
+ switch (tpm->data.emulator.version) {
case VIR_DOMAIN_TPM_VERSION_1_2:
break;
case VIR_DOMAIN_TPM_VERSION_2_0:
if (!tpm->data.emulator.storagepath &&
!(tpm->data.emulator.storagepath =
qemuTPMEmulatorStorageBuildPath(swtpmStorageDir, uuidstr,
- tpm->version)))
+ tpm->data.emulator.version)))
return -1;
if (!tpm->data.emulator.logfile) {
{
virDomainCapsDeviceTPM tpmCaps = { 0 };
- switch (tpm->version) {
- case VIR_DOMAIN_TPM_VERSION_1_2:
- /* TPM 1.2 + CRB do not work */
- if (tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR &&
- tpm->model == VIR_DOMAIN_TPM_MODEL_CRB) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Unsupported interface %s for TPM 1.2"),
- virDomainTPMModelTypeToString(tpm->model));
- return -1;
- }
- /* TPM 1.2 + SPAPR do not work with any 'type' (backend) */
- if (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("TPM 1.2 is not supported with the SPAPR device model"));
- return -1;
- }
- /* TPM 1.2 + ARM does not work */
- if (qemuDomainIsARMVirt(def)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("TPM 1.2 is not supported on ARM"));
- return -1;
+ if (tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR) {
+ switch (tpm->data.emulator.version) {
+ case VIR_DOMAIN_TPM_VERSION_1_2:
+ /* TPM 1.2 + CRB do not work */
+ if (tpm->model == VIR_DOMAIN_TPM_MODEL_CRB) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported interface '%s' for TPM 1.2"),
+ virDomainTPMModelTypeToString(tpm->model));
+ return -1;
+ }
+ /* TPM 1.2 + SPAPR do not work with any 'type' (backend) */
+ if (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("TPM 1.2 is not supported with the SPAPR device model"));
+ return -1;
+ }
+ /* TPM 1.2 + ARM does not work */
+ if (qemuDomainIsARMVirt(def)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("TPM 1.2 is not supported on ARM"));
+ return -1;
+ }
+ break;
+ case VIR_DOMAIN_TPM_VERSION_2_0:
+ case VIR_DOMAIN_TPM_VERSION_DEFAULT:
+ case VIR_DOMAIN_TPM_VERSION_LAST:
+ break;
}
- break;
- case VIR_DOMAIN_TPM_VERSION_2_0:
- case VIR_DOMAIN_TPM_VERSION_DEFAULT:
- case VIR_DOMAIN_TPM_VERSION_LAST:
- break;
}
virQEMUCapsFillDomainDeviceTPMCaps(qemuCaps, &tpmCaps);
shortName = virDomainDefGetShortName(ctl->def);
- switch (ctl->def->tpms[i]->version) {
+ switch (ctl->def->tpms[i]->data.emulator.version) {
case VIR_DOMAIN_TPM_VERSION_1_2:
tpmpath = "tpm1.2";
break;