virDomainInputDefValidate: Validate model

If input device has one of virtio* models set then it has to go
onto virtio bus. Introduce such check into the validator.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2081981
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Michal Privoznik 2022-05-26 13:48:56 +02:00
parent bded22e3a7
commit b4161c2d42

View File

@ -2306,6 +2306,27 @@ virDomainInputDefValidate(const virDomainInputDef *input,
return -1;
}
switch ((virDomainInputModel)input->model) {
case VIR_DOMAIN_INPUT_MODEL_VIRTIO:
case VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL:
case VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL:
if (input->bus != VIR_DOMAIN_INPUT_BUS_VIRTIO) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("only bus 'virtio' is supported for input model '%s'"),
virDomainInputModelTypeToString(input->model));
return -1;
}
break;
case VIR_DOMAIN_INPUT_MODEL_DEFAULT:
break;
case VIR_DOMAIN_INPUT_MODEL_LAST:
default:
virReportEnumRangeError(virDomainInputModel, input->model);
return -1;
}
return 0;
}