mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
conf: Move _virDomainTPMDef::version into _virDomainTPMDef::data::emulator
The _virDomainTPMDef structure has 'version' member, which is a bit misplaced. It's only emulator type of TPM that can have a version, even our documentation says so: ``version`` The ``version`` attribute indicates the version of the TPM. This attribute only works with the ``emulator`` backend. The following versions are supported: Therefore, move the member into that part of union that's covering emulated TPM devices. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
598ffbdd41
commit
c8992f6d97
@ -10413,15 +10413,6 @@ virDomainTPMDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
goto error;
|
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) {
|
switch (def->type) {
|
||||||
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
|
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
|
||||||
if (!(def->data.passthrough.source = virDomainChrSourceDefNew(xmlopt)))
|
if (!(def->data.passthrough.source = virDomainChrSourceDefNew(xmlopt)))
|
||||||
@ -10433,6 +10424,15 @@ virDomainTPMDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
def->data.passthrough.source->data.file.path = g_steal_pointer(&path);
|
def->data.passthrough.source->data.file.path = g_steal_pointer(&path);
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
|
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)))
|
if (!(def->data.emulator.source = virDomainChrSourceDefNew(xmlopt)))
|
||||||
goto error;
|
goto error;
|
||||||
secretuuid = virXPathString("string(./backend/encryption/@secret)", ctxt);
|
secretuuid = virXPathString("string(./backend/encryption/@secret)", ctxt);
|
||||||
@ -10454,7 +10454,7 @@ virDomainTPMDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
goto error;
|
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)
|
if ((nnodes = virXPathNodeSet("./backend/active_pcr_banks/*", ctxt, &nodes)) < 0)
|
||||||
break;
|
break;
|
||||||
for (i = 0; i < nnodes; i++) {
|
for (i = 0; i < nnodes; i++) {
|
||||||
@ -20679,14 +20679,14 @@ virDomainTPMDefCheckABIStability(virDomainTPMDef *src,
|
|||||||
return false;
|
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) {
|
switch (src->type) {
|
||||||
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
|
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) {
|
if (src->data.emulator.activePcrBanks != dst->data.emulator.activePcrBanks) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("Target active PCR banks doesn't match source"));
|
_("Target active PCR banks doesn't match source"));
|
||||||
@ -24241,9 +24241,9 @@ virDomainTPMDefFormat(virBuffer *buf,
|
|||||||
def->data.passthrough.source->data.file.path);
|
def->data.passthrough.source->data.file.path);
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
|
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'",
|
virBufferAsprintf(&backendAttrBuf, " version='%s'",
|
||||||
virDomainTPMVersionTypeToString(def->version));
|
virDomainTPMVersionTypeToString(def->data.emulator.version));
|
||||||
}
|
}
|
||||||
if (def->data.emulator.persistent_state)
|
if (def->data.emulator.persistent_state)
|
||||||
virBufferAddLit(&backendAttrBuf, " persistent_state='yes'");
|
virBufferAddLit(&backendAttrBuf, " persistent_state='yes'");
|
||||||
|
@ -1439,12 +1439,12 @@ struct _virDomainTPMDef {
|
|||||||
int type; /* virDomainTPMBackendType */
|
int type; /* virDomainTPMBackendType */
|
||||||
virDomainDeviceInfo info;
|
virDomainDeviceInfo info;
|
||||||
int model; /* virDomainTPMModel */
|
int model; /* virDomainTPMModel */
|
||||||
int version; /* virDomainTPMVersion */
|
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
virDomainChrSourceDef *source;
|
virDomainChrSourceDef *source;
|
||||||
} passthrough;
|
} passthrough;
|
||||||
struct {
|
struct {
|
||||||
|
int version; /* virDomainTPMVersion */
|
||||||
virDomainChrSourceDef *source;
|
virDomainChrSourceDef *source;
|
||||||
char *storagepath;
|
char *storagepath;
|
||||||
char *logfile;
|
char *logfile;
|
||||||
|
@ -4594,13 +4594,14 @@ qemuDomainDefTPMsPostParse(virDomainDef *def)
|
|||||||
virDomainTPMDef *tpm = def->tpms[i];
|
virDomainTPMDef *tpm = def->tpms[i];
|
||||||
|
|
||||||
/* TPM 1.2 and 2 are not compatible, so we choose a specific version here */
|
/* 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 ||
|
if (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR ||
|
||||||
tpm->model == VIR_DOMAIN_TPM_MODEL_CRB ||
|
tpm->model == VIR_DOMAIN_TPM_MODEL_CRB ||
|
||||||
qemuDomainIsARMVirt(def))
|
qemuDomainIsARMVirt(def))
|
||||||
tpm->version = VIR_DOMAIN_TPM_VERSION_2_0;
|
tpm->data.emulator.version = VIR_DOMAIN_TPM_VERSION_2_0;
|
||||||
else
|
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 (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY) {
|
||||||
|
@ -575,7 +575,8 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm,
|
|||||||
if (created &&
|
if (created &&
|
||||||
qemuTPMEmulatorRunSetup(tpm->data.emulator.storagepath, vmname, vmuuid,
|
qemuTPMEmulatorRunSetup(tpm->data.emulator.storagepath, vmname, vmuuid,
|
||||||
privileged, swtpm_user, swtpm_group,
|
privileged, swtpm_user, swtpm_group,
|
||||||
tpm->data.emulator.logfile, tpm->version,
|
tpm->data.emulator.logfile,
|
||||||
|
tpm->data.emulator.version,
|
||||||
secretuuid, incomingMigration) < 0)
|
secretuuid, incomingMigration) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -583,7 +584,8 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm,
|
|||||||
qemuTPMEmulatorReconfigure(tpm->data.emulator.storagepath,
|
qemuTPMEmulatorReconfigure(tpm->data.emulator.storagepath,
|
||||||
swtpm_user, swtpm_group,
|
swtpm_user, swtpm_group,
|
||||||
tpm->data.emulator.activePcrBanks,
|
tpm->data.emulator.activePcrBanks,
|
||||||
tpm->data.emulator.logfile, tpm->version,
|
tpm->data.emulator.logfile,
|
||||||
|
tpm->data.emulator.version,
|
||||||
secretuuid) < 0)
|
secretuuid) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -611,7 +613,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm,
|
|||||||
virCommandSetUID(cmd, swtpm_user);
|
virCommandSetUID(cmd, swtpm_user);
|
||||||
virCommandSetGID(cmd, swtpm_group);
|
virCommandSetGID(cmd, swtpm_group);
|
||||||
|
|
||||||
switch (tpm->version) {
|
switch (tpm->data.emulator.version) {
|
||||||
case VIR_DOMAIN_TPM_VERSION_1_2:
|
case VIR_DOMAIN_TPM_VERSION_1_2:
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_TPM_VERSION_2_0:
|
case VIR_DOMAIN_TPM_VERSION_2_0:
|
||||||
@ -684,7 +686,7 @@ qemuTPMEmulatorInitPaths(virDomainTPMDef *tpm,
|
|||||||
if (!tpm->data.emulator.storagepath &&
|
if (!tpm->data.emulator.storagepath &&
|
||||||
!(tpm->data.emulator.storagepath =
|
!(tpm->data.emulator.storagepath =
|
||||||
qemuTPMEmulatorStorageBuildPath(swtpmStorageDir, uuidstr,
|
qemuTPMEmulatorStorageBuildPath(swtpmStorageDir, uuidstr,
|
||||||
tpm->version)))
|
tpm->data.emulator.version)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!tpm->data.emulator.logfile) {
|
if (!tpm->data.emulator.logfile) {
|
||||||
|
@ -4760,33 +4760,34 @@ qemuValidateDomainDeviceDefTPM(virDomainTPMDef *tpm,
|
|||||||
{
|
{
|
||||||
virDomainCapsDeviceTPM tpmCaps = { 0 };
|
virDomainCapsDeviceTPM tpmCaps = { 0 };
|
||||||
|
|
||||||
switch (tpm->version) {
|
if (tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR) {
|
||||||
case VIR_DOMAIN_TPM_VERSION_1_2:
|
switch (tpm->data.emulator.version) {
|
||||||
/* TPM 1.2 + CRB do not work */
|
case VIR_DOMAIN_TPM_VERSION_1_2:
|
||||||
if (tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR &&
|
/* TPM 1.2 + CRB do not work */
|
||||||
tpm->model == VIR_DOMAIN_TPM_MODEL_CRB) {
|
if (tpm->model == VIR_DOMAIN_TPM_MODEL_CRB) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("Unsupported interface %s for TPM 1.2"),
|
_("Unsupported interface '%s' for TPM 1.2"),
|
||||||
virDomainTPMModelTypeToString(tpm->model));
|
virDomainTPMModelTypeToString(tpm->model));
|
||||||
return -1;
|
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;
|
||||||
}
|
}
|
||||||
/* 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virQEMUCapsFillDomainDeviceTPMCaps(qemuCaps, &tpmCaps);
|
virQEMUCapsFillDomainDeviceTPMCaps(qemuCaps, &tpmCaps);
|
||||||
|
@ -1212,7 +1212,7 @@ get_files(vahControl * ctl)
|
|||||||
|
|
||||||
shortName = virDomainDefGetShortName(ctl->def);
|
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:
|
case VIR_DOMAIN_TPM_VERSION_1_2:
|
||||||
tpmpath = "tpm1.2";
|
tpmpath = "tpm1.2";
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user