mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-25 10:03:49 +03:00
conf: Report error when default TPM version is provided
When "default" version of 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 qemuDomainDefTPMsPostParse()). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
3f7c63bba5
commit
d5712c54a6
@ -10417,7 +10417,7 @@ virDomainTPMDefParseXML(virDomainXMLOption *xmlopt,
|
||||
if (!version) {
|
||||
def->version = VIR_DOMAIN_TPM_VERSION_DEFAULT;
|
||||
} else {
|
||||
if ((def->version = virDomainTPMVersionTypeFromString(version)) < 0) {
|
||||
if ((def->version = virDomainTPMVersionTypeFromString(version)) <= 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Unsupported TPM version '%s'"),
|
||||
version);
|
||||
@ -24244,8 +24244,10 @@ virDomainTPMDefFormat(virBuffer *buf,
|
||||
def->data.passthrough.source->data.file.path);
|
||||
break;
|
||||
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
|
||||
virBufferAsprintf(&backendAttrBuf, " version='%s'",
|
||||
virDomainTPMVersionTypeToString(def->version));
|
||||
if (def->version != VIR_DOMAIN_TPM_VERSION_DEFAULT) {
|
||||
virBufferAsprintf(&backendAttrBuf, " version='%s'",
|
||||
virDomainTPMVersionTypeToString(def->version));
|
||||
}
|
||||
if (def->data.emulator.persistent_state)
|
||||
virBufferAddLit(&backendAttrBuf, " persistent_state='yes'");
|
||||
if (def->data.emulator.hassecretuuid) {
|
||||
|
@ -1417,7 +1417,7 @@ typedef enum {
|
||||
} virDomainTPMBackendType;
|
||||
|
||||
typedef enum {
|
||||
VIR_DOMAIN_TPM_VERSION_DEFAULT,
|
||||
VIR_DOMAIN_TPM_VERSION_DEFAULT = 0,
|
||||
VIR_DOMAIN_TPM_VERSION_1_2,
|
||||
VIR_DOMAIN_TPM_VERSION_2_0,
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user