mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 18:05:20 +00:00
conf: Report an error when default TPM model is provided
When "default" model of a TPM was provided, our parses accepts it happily even though the value is forbidden by our RNG and not documented as accepted value. This is because of < 0 vs <= 0 comparison of virDomainTPMModelTypeFromString() retval. Make the parser error out explicitly in this case. Users can always chose to not specify the attribute in which case we pick a sane default (in qemuDomainTPMDefPostParse()). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
bad581466e
commit
3f7c63bba5
@ -10377,7 +10377,7 @@ virDomainTPMDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
|
|
||||||
model = virXMLPropString(node, "model");
|
model = virXMLPropString(node, "model");
|
||||||
if (model != NULL &&
|
if (model != NULL &&
|
||||||
(def->model = virDomainTPMModelTypeFromString(model)) < 0) {
|
(def->model = virDomainTPMModelTypeFromString(model)) <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("Unknown TPM frontend model '%s'"), model);
|
_("Unknown TPM frontend model '%s'"), model);
|
||||||
goto error;
|
goto error;
|
||||||
@ -24230,8 +24230,10 @@ virDomainTPMDefFormat(virBuffer *buf,
|
|||||||
g_auto(virBuffer) backendAttrBuf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) backendAttrBuf = VIR_BUFFER_INITIALIZER;
|
||||||
g_auto(virBuffer) backendChildBuf = VIR_BUFFER_INIT_CHILD(&childBuf);
|
g_auto(virBuffer) backendChildBuf = VIR_BUFFER_INIT_CHILD(&childBuf);
|
||||||
|
|
||||||
virBufferAsprintf(&attrBuf, " model='%s'",
|
if (def->model != VIR_DOMAIN_TPM_MODEL_DEFAULT) {
|
||||||
virDomainTPMModelTypeToString(def->model));
|
virBufferAsprintf(&attrBuf, " model='%s'",
|
||||||
|
virDomainTPMModelTypeToString(def->model));
|
||||||
|
}
|
||||||
|
|
||||||
virBufferAsprintf(&backendAttrBuf, " type='%s'",
|
virBufferAsprintf(&backendAttrBuf, " type='%s'",
|
||||||
virDomainTPMBackendTypeToString(def->type));
|
virDomainTPMBackendTypeToString(def->type));
|
||||||
|
@ -1400,7 +1400,7 @@ struct _virDomainHubDef {
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
VIR_DOMAIN_TPM_MODEL_DEFAULT,
|
VIR_DOMAIN_TPM_MODEL_DEFAULT = 0,
|
||||||
VIR_DOMAIN_TPM_MODEL_TIS,
|
VIR_DOMAIN_TPM_MODEL_TIS,
|
||||||
VIR_DOMAIN_TPM_MODEL_CRB,
|
VIR_DOMAIN_TPM_MODEL_CRB,
|
||||||
VIR_DOMAIN_TPM_MODEL_SPAPR,
|
VIR_DOMAIN_TPM_MODEL_SPAPR,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user