mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 04:55:18 +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");
|
||||
if (model != NULL &&
|
||||
(def->model = virDomainTPMModelTypeFromString(model)) < 0) {
|
||||
(def->model = virDomainTPMModelTypeFromString(model)) <= 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Unknown TPM frontend model '%s'"), model);
|
||||
goto error;
|
||||
@ -24230,8 +24230,10 @@ virDomainTPMDefFormat(virBuffer *buf,
|
||||
g_auto(virBuffer) backendAttrBuf = VIR_BUFFER_INITIALIZER;
|
||||
g_auto(virBuffer) backendChildBuf = VIR_BUFFER_INIT_CHILD(&childBuf);
|
||||
|
||||
virBufferAsprintf(&attrBuf, " model='%s'",
|
||||
virDomainTPMModelTypeToString(def->model));
|
||||
if (def->model != VIR_DOMAIN_TPM_MODEL_DEFAULT) {
|
||||
virBufferAsprintf(&attrBuf, " model='%s'",
|
||||
virDomainTPMModelTypeToString(def->model));
|
||||
}
|
||||
|
||||
virBufferAsprintf(&backendAttrBuf, " type='%s'",
|
||||
virDomainTPMBackendTypeToString(def->type));
|
||||
|
@ -1400,7 +1400,7 @@ struct _virDomainHubDef {
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
VIR_DOMAIN_TPM_MODEL_DEFAULT,
|
||||
VIR_DOMAIN_TPM_MODEL_DEFAULT = 0,
|
||||
VIR_DOMAIN_TPM_MODEL_TIS,
|
||||
VIR_DOMAIN_TPM_MODEL_CRB,
|
||||
VIR_DOMAIN_TPM_MODEL_SPAPR,
|
||||
|
Loading…
x
Reference in New Issue
Block a user