mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
domain_conf.c: move virDomainControllerDefValidate() to domain_validate.c
Next patch will add more validations to this function. Let's move it to domain_validate.c beforehand. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
388ad4432d
commit
84da28a86d
@ -6211,43 +6211,6 @@ virDomainNetDefValidate(const virDomainNetDef *net)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virDomainControllerDefValidate(const virDomainControllerDef *controller)
|
||||
{
|
||||
if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
|
||||
const virDomainPCIControllerOpts *opts = &controller->opts.pciopts;
|
||||
|
||||
if (controller->idx > 255) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller index %d too high, maximum is 255"),
|
||||
controller->idx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Only validate the target index if it's been set */
|
||||
if (opts->targetIndex != -1) {
|
||||
|
||||
if (opts->targetIndex < 0 || opts->targetIndex > 30) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("PCI controller target index '%d' out of "
|
||||
"range - must be 0-30"),
|
||||
opts->targetIndex);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((controller->idx == 0 && opts->targetIndex != 0) ||
|
||||
(controller->idx != 0 && opts->targetIndex == 0)) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("Only the PCI controller with index 0 can "
|
||||
"have target index 0, and vice versa"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virDomainHostdevDefValidate(const virDomainHostdevDef *hostdev)
|
||||
{
|
||||
|
@ -517,3 +517,40 @@ virDomainDefTunablesValidate(const virDomainDef *def)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virDomainControllerDefValidate(const virDomainControllerDef *controller)
|
||||
{
|
||||
if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
|
||||
const virDomainPCIControllerOpts *opts = &controller->opts.pciopts;
|
||||
|
||||
if (controller->idx > 255) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller index %d too high, maximum is 255"),
|
||||
controller->idx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Only validate the target index if it's been set */
|
||||
if (opts->targetIndex != -1) {
|
||||
|
||||
if (opts->targetIndex < 0 || opts->targetIndex > 30) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("PCI controller target index '%d' out of "
|
||||
"range - must be 0-30"),
|
||||
opts->targetIndex);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((controller->idx == 0 && opts->targetIndex != 0) ||
|
||||
(controller->idx != 0 && opts->targetIndex == 0)) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("Only the PCI controller with index 0 can "
|
||||
"have target index 0, and vice versa"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -43,3 +43,4 @@ int virDomainRNGDefValidate(const virDomainRNGDef *rng,
|
||||
int virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard,
|
||||
const virDomainDef *def);
|
||||
int virDomainDefTunablesValidate(const virDomainDef *def);
|
||||
int virDomainControllerDefValidate(const virDomainControllerDef *controller);
|
||||
|
Loading…
x
Reference in New Issue
Block a user